Featured post

Objectives and content

Monday 29 August 2016

Servo Motor

Servo Motor

Servo motors functions as electromechanical actuators that do not rotate continuously like DC/AC motors. Application of servo found in positioning or holding some object. Applying pulses at an equal interval servo motor rotates to a particular angular position and then stopped. Direction of rotation depends on the width of the pulse as given in the datasheet of the model. Most common use is to position the rudder of aircrafts and boats etc. Servos can be used effectively here because the rudders do not need to move full 360 degrees nor they require continuous rotation like a wheel. Servos are DC motors with built in gearing and feedback control loop circuitry.

Design steps:

1. Observe following pinout.
2. pulse width of 1ms to 2ms is used to set angular position of servo motor.
3. pulse rate in this 5 Volt servo is 50 Hz.
4. System clock taken 16 MHz and reduced to 2 MHz using prescaler.
5. Count taken to the register ICR1 is 2000000/50 = 40000 to generate 50 Hz rectangular pulse.
6. OCR1B register is loaded with ICR1-4499 to produce 2.5 ms pulse width.
7. delay for 2 seconds.
8. OCR1B register is loaded with ICR1-1299 to produce 0.65 ms pulse width.
9. delay for 2 seconds.
10. COM1B1 and COM1B0 are set so that on compare match of OCR1B and ICR1 rising edge will appear at pin 18 i.e. OC1B till ICR1 reaches its final count.

Circuit:



Code:

#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
TCCR1A |= 1<<WGM11 | 1<<COM1B1| 1<<COM1B0;
TCCR1B |= 1<<WGM12 | 1<<WGM13 | 1<<CS11;
// initialize timer
DDRD |= 0xFF;
ICR1 = 39999;
while (1)
{
OCR1B = ICR1-4799;// 2.4 ms for 0 deg
_delay_ms(2000);
OCR1B = ICR1-3049;// 1.525 ms for 90 deg
_delay_ms(2000);
OCR1B = ICR1-1299;// .65 ms for 180 deg
_delay_ms(2000);
OCR1B = ICR1-3049;// 1.525 ms for 90 deg
_delay_ms(2000);
}
}


No comments:

Post a Comment