# Re: [piclist] 18F4331 and PWM

## Mar 21, 2007

----------------------------

#10344 Mar 21, 2007

Hi. Well, after getting my new PIC, it didn't take longto get it going! Was a little worried at first! I can now receive using USARTand then using the values taken put that in the PWM unit and there i have adimming LED! Beats having a DA and few Op-amps! My question is about the PWM maths. I have read thedatasheet but can't figure out how to calculate the frequency of the PWM. Maybecause its 12:30 in the morning! Can anyone point me in the direction to anequation to figure this? It is working, well, at first i set all the prescallerto max so got a flashing LED rather than a dimming! So upped the pre and got agood dim! Just would like to figure the freq. Cheers,Paul

----------------------------

#10346 Mar 22, 2007

Hey I have managed to figure out most of the PWM stuffbut am still in need of a little help. I am using the Power Control PWM Moduleon the PIC18F4331, i have managed to get the frequency from the calculation onthe datasheet, it wasn't 100% clear cause couldn't figure out what PTMRPS was,but it turned out to be the Prescaler! Anyway, i have tried using the PWMResolution equation, but i can't seem to get the same answers as the exampletable, i have not done a lot with LOG but just used it on the calculator. Idon't seem to get the correct Resolutions? Do anyone have any experience on thePWM side of this PIC? Help would be great! Cheers----- Original Message -----From:Paul LTo: piclist@yahoogroups.comSent: Thursday, March 22, 2007 12:40AMSubject: [piclist] 18F4331 and PWM

Hi. Well, after getting my new PIC, it didn't takelong to get it going! Was a little worried at first! I can now receive usingUSART and then using the values taken put that in the PWM unit and there ihave a dimming LED! Beats having a DA and few Op-amps! My question is about the PWM maths. I have readthe datasheet but can't figure out how to calculate the frequency of the PWM.Maybe cause its 12:30 in the morning! Can anyone point me in the direction toan equation to figure this? It is working, well, at first i set all theprescaller to max so got a flashing LED rather than a dimming! So upped thepre and got a good dim! Just would like to figure the freq. Cheers,Paul