Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: joystick on June 17, 2011, 10:41:24 PM
-
I want to control servo motor by generating PWM using timers in AT mega128 (using C language) .
I want to know since L293D has 2 input pins for one motor , on which pin should I send PWM input to move the shaft in the desired direction ?
As to rotate ,suppose, rightward I will send a PWM of 50Hz frequency with a duty cycle of 10%(let) on one pin then what input should I send to the other pin of the motor to move the shaft rightward ?
Thanks
-
You don't need an L293D to control a servo, they already have driver circuitry in them. All you need to do is feed the control line a 50Hz carrier, and vary the duty cycle between 1 - 2 ms.
There's a good introduction to pwm here: http://www.societyofrobots.com/member_tutorials/node/228 (http://www.societyofrobots.com/member_tutorials/node/228) The registers will probably change a bit with the 128, but the ideas are the same, just check the data sheet for how to set them up for your chip.
Also check the data sheet section for the timer you're going to use (whatever the 16 bit timer is on the 128). The data sheet will give you the formulas for determine the values needed to setup the timer. The tutorial also goes into this.
Joe
-
yepp ! thanks .. I got that :)