Continue to Site

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.

PWM signal problem

Status
Not open for further replies.

iznalgnaij

New Member
I need to use PIC16F877A to generate a PWM signal to control my motor driver--MD22(**broken link removed**, the RC servo mode of MD22 need a PWM signal which has PWM period of 20ms and duty cycle range from 1ms to 2ms.
I look for the frequency problem online regarding PIC16F877A, but it seems that the lowest PWM frequency I can get is about 488Hz.
How can I generate the PWM signal in this case?

I need some help...
thank you
 
You can make a timer interrupt that goes as long as you want and base some code that manually turns a pin high and low off of that to make slow PWM.
 
dknguyen said:
You can make a timer interrupt that goes as long as you want and base some code that manually turns a pin high and low off of that to make slow PWM.
I am a bird to this PIC programming, is there any example code which show how to write this kind of interrupt?
 
iznalgnaij:

Just use a slower xtal oscillator (32.768 kHz would work), or maybe an RC osc; read up on the different osc types (this is all explained in the PIC16F877A data sheet). The duty cycle pulse is no problem no matter what xtal you use. The Period=P is:

P=[(PR2+1)4(Tosc)(PSV)] where PSV=prescale value

Ex. If use a 32.768 kHz xtal, with PSV=1 then PR2+1=163.84 ->164
Period(actual) = 20.0195 mS, 0.002 % difference from 20 mS
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top