electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

PIC Code - PWM (50% Duty Cycle)


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC Code - PWM (50% Duty Cycle)
Author Message
devonsc



Joined: 30 Nov 2004
Posts: 116
Helped: 1


Post30 Nov 2004 20:15   

PIC Code - PWM (50% Duty Cycle)


Hi there,

I'm a newbie in using PIC microcontroller and would like to ask something regarding the duty cycle of a PWM coding.

If its not too much trouble, can anyone briefly explain how do I determine the duty cycle of a PWM duty cycle in the coding? Is it true that 255 (decimal) is equivalent to 100% duty cycle while 0 (decimal) is equivalent to 0% duty cycle? If this is right, does it mean that I should write:

movlw d'127'

for a duty cycle of 50%? Advice needed..Please? Thanks in advance..
Back to top
nicleo



Joined: 06 Sep 2004
Posts: 717
Helped: 60


Post01 Dec 2004 3:23   

PIC Code - PWM (50% Duty Cycle)


Which PIC microcontroller that you're using? Some PIC microcontrollers, e.g. PIC16F877A, has built-in PWM module.

The following article might help:
http://ww1.microchip.com/downloads/en/DeviceDoc/31014a.pdf

Here has many links on using PWM of PIC microcontroller:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1490&filterID=409
Back to top
IanP



Joined: 05 Oct 2004
Posts: 6492
Helped: 1542
Location: West Coast


Post01 Dec 2004 3:43   

Re: PIC Code - PWM (50% Duty Cycle)


Your guess is correct: for 50% the number is 127d.
Back to top
devonsc



Joined: 30 Nov 2004
Posts: 116
Helped: 1


Post02 Dec 2004 12:45   

Re: PIC Code - PWM (50% Duty Cycle)


Thanks a lot.

By the way, I'm using PIC 16F876.
Back to top
Google
AdSense
Google Adsense




Post02 Dec 2004 12:45   

Ads




Back to top
btbass



Joined: 20 Jul 2001
Posts: 1187
Helped: 113
Location: Oberon


Post04 Dec 2004 0:03   

PIC Code - PWM (50% Duty Cycle)


The PIC16f876 has 2 PWM modules with a resolution of 10bits. So your period could have a count of 1024. The data sheet gives formulas for calculating the duty cycle based on the frequency and resolution.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC Code - PWM (50% Duty Cycle)
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
PWM duty cycle using PIC (3)
pwm- duty cycle (3)
50% duty cycle PWM to 470uF cannot give 5V DC (11)
PWM - Duty cycle - Is finer adjustment possible? (2)
UCC28C43 PWM IC- don't understand It's duty cycle control (2)
How to get 1/3 duty cycle from a 50% duty cycle clock? (14)
Need code to correct duty cycle using PID tuning (3)
Confused...Duty Ratio VS Duty Cycle (2)
duty cycle (7)
50% duty cycle (8)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS