Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to make Hardware PWM controlled by PIC18Fxxx

Status
Not open for further replies.

prowede

New Member
I am a newbie in electronics
I want to make a LED lamp which can adjust the intensity by control the PWM

I have use a stupid method to make the PWM
that's use 555+ reference DC level into comparator, by adjusting the DC level I can change the duty cycle

But now i want to use the PIC to control the duty cycle
I know there is a software PWM function in PIC, but my programming is not so good(i just know C but not asm), so i prefer using hardware PWM controlled by PIC

But I have not idea in how to control the duty cycle by PIC
Or other hardware approach i have to use for PWM?

Can anyone give some ideas or suggestions?

THANKS A LOT!
 
Last edited:

prowede

New Member
prowede said:
I am a newbie in electronics
I want to make a LED lamp which can adjust the intensity by control the PWM

I have use a stupid method to make the PWM
that's use 555+ reference DC level into comparator, by adjusting the DC level I can change the duty cycle

But now i want to use the PIC to control the duty cycle
I know there is a software PWM function in PIC, but my programming is not so good(i just know C but not asm), so i prefer using hardware PWM controlled by PIC

But I have not idea in how to control the duty cycle by PIC
Or other hardware approach i have to use for PWM?

Can anyone give some ideas or suggestions?

THANKS A LOT!

Do any one have comments?
 

prowede

New Member
bananasiong said:
asm? Nigel's tutorial of course!
http://winpicprog.co.uk/pic_tutorial8.htm

Just need some setting on CCP and timer 2.

I have also seen this b4

Actually i am quite confusing between" hardware PWM" and "software PWM"

Because now i have achieve to generate a PWM but hardware only, but can not be adjust by PIC

So if i use CCP, and timer2 for PWM in PIC, is it actually just control the ON/OFF duration in a fix period?
 

bananasiong

New Member
Hi,
Hardware PWM is the PWM done by the hardware, ie the PIC itself.
Software PWM is the PWM done in the software, set the particular pin high, delay, low and delay.

CCP module is the hardware PWM that built-in in the PIC. The PWM period (frequency) is fixed by the value in PR2, and the duty cycle is determined by CCPR1L and CCP1CON. Once these setting are done, then the PWM will be generated on the CCP pin.
To adjust the duty cycle, just change the value in CCPR1L and CCP1CON.
 

prowede

New Member
bananasiong said:
Hi,
Hardware PWM is the PWM done by the hardware, ie the PIC itself.
Software PWM is the PWM done in the software, set the particular pin high, delay, low and delay.

CCP module is the hardware PWM that built-in in the PIC. The PWM period (frequency) is fixed by the value in PR2, and the duty cycle is determined by CCPR1L and CCP1CON. Once these setting are done, then the PWM will be generated on the CCP pin.
To adjust the duty cycle, just change the value in CCPR1L and CCP1CON.

O....this reli help me so much
THANKS!!!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Top