Hobby servo control PIC 18F14K50

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
dproffer
Posts: 5
Joined: Thu May 24, 2012 2:03 am
Has thanked: 2 times

Hobby servo control PIC 18F14K50

Post by dproffer »

Hello,

I am trying to control a single hobby servo using a PIC18F14K50 in Flowcode 5. The documentation for this chip indicates it has 4 PWM outputs. Trying to compile a simple Flowcode 5 program to sweep the servo yields the cryptic errors below.

I am using professional flow code 5.2. In searching the forums, there seem to be some posts that imply that these errors are generated when the target micro controller does not have necessary PWM support. In searching the web, there are numerous example of the 18F14K50 driving up to 8 hobby servos in C.

I am not finding any documentation on how to configure the servo component or what the limits are to use it, where can this be found on Flowcode web site?

I am making my way through the videos posted on the Flowcode web site, but have not found any that seems to explain servos. Side question, it it just me or are many of the videos 'silent movies' with NO audio?

Thanks for your help!
Dave

Code: Select all


Dave servo motor control v0.c
Starting preprocessor: C:\PROGRA~1\Flowcode\v5\Tools\boostc\pp.exe "Dave servo motor control v0.c" -i C:\PROGRA~1\Flowcode\v5\Tools\boostc\include -d _PIC18F14K50 -la -c2 -o "Dave servo motor control v0.pp" -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX 


.....

Dave servo motor control v0.c(407:2): error: unknown identifier 'ccp2con'
Dave servo motor control v0.c(407:2): error: invalid operand 'ccp2con'
Dave servo motor control v0.c(407:10): error: failed to generate expression
Dave servo motor control v0.c(409:21): error: unknown identifier 'CCP2IE'
Dave servo motor control v0.c(409:21): error: invalid operand 'CCP2IE'
Dave servo motor control v0.c(409:16): error: failed to generate expression
Dave servo motor control v0.c(409:16): error: invalid operand '<<'
Dave servo motor control v0.c(409:10): error: failed to generate expression
Dave servo motor control v0.c(523:2): error: unknown identifier 'ccpr2h'
Dave servo motor control v0.c(523:2): error: invalid operand 'ccpr2h'
Dave servo motor control v0.c(523:9): error: failed to generate expression
Dave servo motor control v0.c(524:2): error: unknown identifier 'ccpr2l'
Dave servo motor control v0.c(524:2): error: invalid operand 'ccpr2l'
Dave servo motor control v0.c(524:9): error: failed to generate expression
Dave servo motor control v0.c(531:24): error: unknown identifier 'CCP2IF'
Dave servo motor control v0.c(531:24): error: invalid operand 'CCP2IF'
Dave servo motor control v0.c(531:19): error: failed to generate expression
Dave servo motor control v0.c(531:19): error: invalid operand '<<'
Dave servo motor control v0.c(531:14): error: failed to generate expression
Dave servo motor control v0.c(531:55): error: unknown identifier 'CCP2IE'
Dave servo motor control v0.c(531:55): error: invalid operand 'CCP2IE'
Dave servo motor control v0.c(531:50): error: failed to generate expression
Dave servo motor control v0.c(531:50): error: invalid operand '<<'
Dave servo motor control v0.c(531:45): error: failed to generate expression
Dave servo motor control v0.c(531:14): error: invalid operand '& '
Dave servo motor control v0.c(531:45): error: invalid operand '& '
Dave servo motor control v0.c(531:34): error: failed to generate expression
Dave servo motor control v0.c success

failure
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.


FINISHED

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Hobby servo control PIC 18F14K50

Post by Benj »

Hello Dave,

If you right click the servo component on the panel then the help file should help you to get started.

The 18F14K50 only has one CCP PWM channel so the Flowcode PWM component will only have access to this one channel.

An example of software driven PWM can be seen here.
http://www.matrixmultimedia.com/article.php?a=52

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Hobby servo control PIC 18F14K50

Post by medelec35 »

Hi Dave,

Servo component in Flowcode uses two CCP channels to work.
Since as Ben stated 18F14K50 only has one cpp channel so only ccp1con and anything requiring ccp1xxx will work.
if ccp2con, CCP2IE etc. are required as in the case of servos, then flowchart will fail to compile, showing errors related to missing ccp2 channel.

There are workarounds for this.
For example see:
http://www.matrixmultimedia.com/article.php?a=435
Only near the end of all the posts of 'Discuss this Article', resolution of servo has increased, but it should give you a general idea.

Martin
Martin

Post Reply