Page 1 of 1

Hobby servo control PIC 18F14K50

Posted: Mon Jun 11, 2012 8:46 am
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

Re: Hobby servo control PIC 18F14K50

Posted: Mon Jun 11, 2012 9:36 am
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

Re: Hobby servo control PIC 18F14K50

Posted: Wed Jun 27, 2012 7:19 am
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