PWM Outputs

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Michaelt
Posts: 38
Joined: Sun Sep 23, 2012 9:46 am
Has thanked: 13 times
Contact:

PWM Outputs

Post by Michaelt »

Hello Matrix

I am programming a Pic 16f1936 and using all pins on the chip. I would like to setup 2 Pwm channels Pin 24 RB3/CCP2 and pin 26 RB5/CCP3.

My problem is that if i setup the macro to pin2 = CCP2 both RC1/CCP2 and and RB3/CCP2 is pwm'ed, is it possible to only use one of each of the ccp2 and ccp3 pins??

Hope this is understandable

Best Regards
From Michael

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

Re: PWM Outputs

Post by medelec35 »

Hi Michael,
If its not commercially sensitive, would you like to post your flowchart so we can take a look for you?

Martin
Martin

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: PWM Outputs

Post by Kenrix2 »

Your trying to use alternate pins for CCP2 and CCP3. Flowcode will set the correct pins as outputs when you check the box "Use alternative pin" but it does not set the bits in the APFCON:ALTERNATE PIN FUNCTION CONTROL REGISTER so you have to do it manually. Drop a "c code icon" into your program before enabling the PWM and put this in it:

set_bit(apfcon,CCP3SEL);
set_bit(apfcon,CCP2SEL);

Michaelt
Posts: 38
Joined: Sun Sep 23, 2012 9:46 am
Has thanked: 13 times
Contact:

Re: PWM Outputs

Post by Michaelt »

here is a copy of the flowchart witch is far from finished, The pwm is in the temperature_output_control macro.

i just wanted to test the pwm outputs witch control 2 12v fans. but instead of driving the fan the lcd display starts going cracy because CCP3 is both outputted to pin 17 and 26 and i am only interested in port 26(RB5). and for ccp2 i want pin 24(RB3).
Attachments
Beer_Dispenser_V1.0.fcf
(50.25 KiB) Downloaded 311 times

Michaelt
Posts: 38
Joined: Sun Sep 23, 2012 9:46 am
Has thanked: 13 times
Contact:

Re: PWM Outputs

Post by Michaelt »

Kenrix im not sure i fully understand the procedure u describe,, does that tell the pic only to use the desired pins??

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: PWM Outputs

Post by Kenrix2 »

Attached is a program to show how to do it so you can test it in hardware. In your program PWM FanIntake and PWM FanExhaust are using the same channels.
Attachments
16F1936_PWM_alt_pin_test.fcf
(9 KiB) Downloaded 329 times

Michaelt
Posts: 38
Joined: Sun Sep 23, 2012 9:46 am
Has thanked: 13 times
Contact:

Re: PWM Outputs

Post by Michaelt »

Thanks a lot for your help it is working perfect now :)

thanks again for a fantastic service

Best Regards
Michael

Post Reply