Previous in Forum: Choose the Program. What Program?   Next in Forum: What's the Best XDSL Technology?
Close
Close
Close
3 comments
Rate Comments: Nested
Participant

Join Date: Dec 2008
Posts: 2

PWM Programming in C

12/15/2008 8:14 AM

im using 16f877a so using pwm how i can control the speed of the motor using clanguage coding

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Engineering Fields - Electrical Engineering - New Member

Join Date: Sep 2006
Location: El Lago, Texas, USA
Posts: 2639
Good Answers: 65
#1

Re: PWM Programming in C

12/15/2008 5:36 PM

A PWM circuit can be made easily with a counter. Make a counter that counts from 1 to 100 (for instance) over and over. Your PWM value is a number between 1 and 100. Let's say you want a 25% duty cycle. While the count is between 1 and 25, you output a one (motor on). While the count is between 26 and 100, you output a zero (motor off). It works the same for any variable PWM value that you want.

You will also need to make the counter so that it counts at the correct frequency for your motor. You can do this with a second counter that controls when the first counter increments.

Register to Reply
Participant

Join Date: Dec 2008
Posts: 2
#2

Re: PWM Programming in C

12/16/2008 1:18 AM

i need c coding for that portion

Register to Reply Off Topic (Score 5)
Power-User

Join Date: Jul 2008
Location: United States of America
Posts: 429
Good Answers: 3
#3

Re: PWM Programming in C

12/19/2008 5:13 PM

If you have been programming or know how to program the 16F877A in assembly language then may be you can convert some of the codes at the below link into the C -paradigm: http://www.piclist.com/techref/microchip/16f877adsamp.htm

Goodluck

__________________
EditorGBAnalysts - Give a boy fish and he will eat may be for a day, but teach him how to fish and he will eat everyday.
Register to Reply
Register to Reply 3 comments
Copy to Clipboard

Users who posted comments:

bhankiii (1); dinesh kumar (1); editorgbanalysts (1)

Previous in Forum: Choose the Program. What Program?   Next in Forum: What's the Best XDSL Technology?

Advertisement