Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - PWM EXAMPLE - 0 TO 90% EXTERNALLY ADJUSTABLE DUTY CYCLE

(you are viewing a thread; or go back to list of threads)

PWM EXAMPLE - 0 TO 90% EXTERNALLY ADJUSTABLE DUTY CYCLE (by MOSTAFA QUARRASH)
I USED THE SIMPLE PWM TO BUILD AN ADJUSTABLE ONE .
PLEASE REVISE IT IF YOU LIKE IT >
ALSO IF IT IS OK I'LL BE HAPPY IF YOU ADD IT TO THE PUBLIC EXAMPLES LIBRARY .
THANK YOU A LOT .
Sat Aug 8 2009, 03:04:19, download attachment pwm- VARIBLE.ld
(no subject) (by Jonathan Westhues)
Looks okay to me.

I don't plan to update the stuff on the main page very often. It seems better just to post examples and other information on this forum.
Sat Aug 8 2009, 03:18:43
(no subject) (by MOSTAFA QUARRASH)
FANTASTIC !!!!!!!
YOU ACCEPTED MY EXAMPLE AND IT WILL STAY HERE UN-REMOVED .
THAT IS ALL I MEANT BY ADDING IT TO PUBLIC EXAMPLE LIBRARY .
I MEAN THAT I JUST LIKED TO EXPRESS MY THANKS FOR YOUR GREAT HELP BY ADDING SOME THING THAT MAY BE HELP-FULL TO OTHER PEOPLE YOU HELP . THANK YOU A LOT .
Sat Aug 8 2009, 03:44:48
(no subject) (by S A Khan)
Problem with PWM 0 to 60, 500 KHz. When I transfer to PIC this program is not work accordingly! My development board is EasyPIC5. My requirement is: when I press increase button then duty cycle is increase 1, same to decrease. I don’t know why this is not working? Output 500 KHz is OK, after pressing increases button ten time then duty cycle increase 10 (not 1, 2,3, 4----10, like 10, 20, 30-----60). If PWM output is set to 50 KHz everything is fine.
Sorry for my poor English.
Thank you
Tue Jan 19 2010, 03:22:15, download attachment PWM.ld
(no subject) (by MGP)
@Mostafa, i think that you have made a error, because of rung 8 the variable 'duty' always remains 0 (zero)

I have attached a changed version.
Tue Jan 19 2010, 07:19:04, download attachment pwm-VARIBLE[mostafa].ld
(no subject) (by Jonathan Westhues)
The PIC PWM hardware achieves the desired output frequency by dividing the CPU clock frequency (f_osc/4) by an integer. In your case, the crystal is 20 MHz, so the CPU is running at 5 MIPS.

This means that the PWM clock is obtained by dividing the CPU clock by 10, to get 0.5 MHz = 500 kHz. The duty cycle is specified in units of CPU clocks, so there's only ten available steps on the duty cycle. If the CPU clock were faster, then you would have more resolution, but it's already running as fast as possible.

So that's just the way the processor's peripheral works, and there's nothing any software could do to change it. LDmicro normally hides that complexity from you (by letting you specify the duty cycle in percent, and not in CPU clock cycles; the conversion happens automatically), but there's nothing it can do to avoid that hardware limitation.
Tue Jan 19 2010, 07:19:27
(no subject) (by S A Khan)
Thank you Jonathan Westhues
Tue Jan 19 2010, 08:27:48
(no subject) (by S A Khan)
Dear Jonathan
Thank you for your kind information. AVR MCU can do this? At this moment of time I have no AVR MCU for test, if AVR can I will go for AVR.
Tue Jan 19 2010, 09:24:00
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):