PIC18F4431 PWM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
trisb
Flowcode V4 User
Posts: 40
Joined: Sat Mar 06, 2010 5:25 am
Location: Chicago USA, & Oxford & Northampton UK
Has thanked: 6 times
Contact:

PIC18F4431 PWM

Post by trisb »

HI, Guys,

Looking for a bit of help and a point in the right direction.

I am looking at building some equipment that requires me to give 8 PWM output signals.

I have chosen to use the PIC18F4431 as the has the number of PWM outputs I need, how ever when looking at flow code it will only allow me to us 2.

Is there a way to change this, or how do I go about implementing to other PWM outputs in to my software.

I will be using the ADC inputs to control the duty cycle form 0 to 100%.

Any help with the above will be very appreciated.

Thanks

Tristan

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: PIC18F4431 PWM

Post by medelec35 »

Hi Tristan,
Take a look at all of this thread, as it may help?
http://www.matrixmultimedia.com/mmforum ... 19&start=0

Martin
Martin

trisb
Flowcode V4 User
Posts: 40
Joined: Sat Mar 06, 2010 5:25 am
Location: Chicago USA, & Oxford & Northampton UK
Has thanked: 6 times
Contact:

Re: PIC18F4431 PWM

Post by trisb »

Hi, Martin,

Thanks for the reply, I did come across this one and it looks great. you spent some time on this.

I have a question for you.

In the flow code you have a calculation as follows:

Steps = ((ADC2*40)/(40/10))
ccpxcon = (Steps AND 3)*16+12
ccprxl = Steps>>2

Am i right in saying ccpxcon & ccprxl, should be for example ccp5con & ccpr5l if I am using the pwm 5 on pin 37 (RB5) on the PIC18F4431 chip.

And the C Code would be:

ccpr5l = FCV_CCPR5L;
ccp5con = FCV_CCP5CON ;

am I understanding this right???


Thanks

Tristan

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: PIC18F4431 PWM

Post by medelec35 »

I just had a look at the the data sheet for PIC18F4431, and I don't think its possible the way that's described in the link I posted.
I should have looked at the data sheet before I replied. Sorry about that.
Martin

trisb
Flowcode V4 User
Posts: 40
Joined: Sat Mar 06, 2010 5:25 am
Location: Chicago USA, & Oxford & Northampton UK
Has thanked: 6 times
Contact:

Re: PIC18F4431 PWM

Post by trisb »

No Problem.

I have been looking at other chips and based on how I think your example shows, an i right in saying that If the chip has multiple CCP pins it should work.

I am now looking to use a 18F66K22. and will be dropping to 7 PWM outputs. I will use a second chip for the 8th PWM,

Thanks

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: PIC18F4431 PWM

Post by medelec35 »

Hi Tristan
trisb wrote: I have been looking at other chips and based on how I think your example shows, an i right in saying that If the chip has multiple CCP pins it should work.
Yes your correct. Its only the chips with multiple CCP channels that will work with the posted method.
Luckily this is easy to find the ideal chips.
Go to:
http://www.microchip.com/maps/microcontroller.aspx
and just unselect 16 and 32 bits so that just 8 bit is selected.
Then select 3 (or any min number of channels required) for 'from' and all for 'to' column. of 'Input Capture'
You will then get a list of microcontrollers you can use.
Best to create a flowchart with desired target device, to make sure its compatible with Flowcode (just compile to hex) before ordering chip.
I used a 16F737, but that's getting a bit old in the tooth now.

Martin
Martin

Post Reply