Page 1 of 1

PIC18F4431 PWM

Posted: Tue Aug 16, 2011 5:49 pm
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

Re: PIC18F4431 PWM

Posted: Tue Aug 16, 2011 5:58 pm
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

Re: PIC18F4431 PWM

Posted: Tue Aug 16, 2011 6:23 pm
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

Re: PIC18F4431 PWM

Posted: Tue Aug 16, 2011 6:39 pm
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.

Re: PIC18F4431 PWM

Posted: Tue Aug 16, 2011 7:21 pm
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

Re: PIC18F4431 PWM

Posted: Tue Aug 16, 2011 8:00 pm
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