Author Topic: control servo motor using inbuilt timers in ATmega128  (Read 3635 times)

0 Members and 1 Guest are viewing this topic.

Offline joystickTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
control servo motor using inbuilt timers in ATmega128
« 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

Offline joe61

  • Supreme Robot
  • *****
  • Posts: 417
  • Helpful? 16
Re: control servo motor using inbuilt timers in ATmega128
« Reply #1 on: June 18, 2011, 10:05:41 PM »
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 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

Offline joystickTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: control servo motor using inbuilt timers in ATmega128
« Reply #2 on: June 18, 2011, 11:54:18 PM »
yepp ! thanks .. I got that  :)

 

SMF spam blocked by CleanTalk