Top Banner
ROBO INDIA http://roboindia.com
22
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Servo motor and AVR  Atmel Atmega 16

ROBO INDIAhttp://roboindia.com

Page 2: Servo motor and AVR  Atmel Atmega 16
Page 3: Servo motor and AVR  Atmel Atmega 16

• Servo motor is nothing but a simple motor based on servo mechanism.

• Servomechanism is a closed loop feedback systems uses +ve feedback to control its motion.

• With the help of servomechanism, servo motor give precise control of angular position.

Page 4: Servo motor and AVR  Atmel Atmega 16

• Motor have a dedicated encoder

• Simplest servomotors use position-only sensing via a potentiometer

Click here to visit -ROBO INDIA

Page 5: Servo motor and AVR  Atmel Atmega 16

TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);

//NON Inverted PWM

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

//PRESCALER=64 MODE 14(FAST PWM)

ICR1=4999;

//fPWM=50Hz (Period = 20ms Standard).

DDRD|=(1<<PD4)|(1<<PD5);

//PWM Pins as Out

Click here to visit -ROBO INDIA

Page 6: Servo motor and AVR  Atmel Atmega 16

TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);

• COM1A1 = 1

• COM1B1 = 1

• WGM11 = 1

1 0 1 0 0 0 1 0

Click here to visit -ROBO INDIA

Page 7: Servo motor and AVR  Atmel Atmega 16

TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);

• WGM10 = 0 //Used in Waveform Generation

• WGM11 = 1 //Used in Waveform Generation

• COM1A1 = 1

• COM1B1 = 1

1 0 1 0 0 0 1 0

Click here to visit -ROBO INDIA

Page 8: Servo motor and AVR  Atmel Atmega 16

• The COM1A1,COM1A0,COM1B1 and COM1B0 control OC1A and OC1B

1 0 1 0 0 0 1 0

Click here to visit -ROBO INDIA

Page 9: Servo motor and AVR  Atmel Atmega 16

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

• WGM12 = 1

• WGM13 = 1

• CS11 = 1

• CS10 = 1

0 0 0 1 1 0 1 1

Click here to visit -ROBO INDIA

Page 10: Servo motor and AVR  Atmel Atmega 16

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

• WGM10 = 0 // TCCR1A

• WGM11 = 1 // TCCR1A

• WGM12 = 1 // TCCR1B

• WGM13 = 1 // TCCR1B

0 0 0 1 1 0 1 1

Click here to visit -ROBO INDIA

Page 11: Servo motor and AVR  Atmel Atmega 16

• WGM10 = 0 // TCCR1A

• WGM11 = 1 // TCCR1A

• WGM12 = 1 // TCCR1B

• WGM13 = 1 // TCCR1B

Click here to visit -ROBO INDIA

Page 12: Servo motor and AVR  Atmel Atmega 16

• FAST PWM Mode

• TOP Value = ICR1

//Timer count from 0 to ICR1

Click here to visit -ROBO INDIA

Page 13: Servo motor and AVR  Atmel Atmega 16

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

CS12 = 1 : CS11 = 1 : CS10 = 0

0 0 0 1 1 0 1 1

Click here to visit -ROBO INDIA

Page 14: Servo motor and AVR  Atmel Atmega 16

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

• Prescaler is 64.

• Means16MHz/64 = 250khz (4 uS period)

0 0 0 1 1 0 1 1

Click here to visit -ROBO INDIA

Page 15: Servo motor and AVR  Atmel Atmega 16

𝑓𝑝𝑤𝑚 =𝑓𝑐𝑝𝑢

𝑛(1 + 𝑇𝑂𝑃)

Click here to visit -ROBO INDIA

Page 16: Servo motor and AVR  Atmel Atmega 16

𝑓𝑝𝑤𝑚 =𝑓𝑐𝑝𝑢

𝑛(1 + 𝑇𝑂𝑃)

fpwm = 20ms (50 Hz)

fcpu = 16000000Hz

n = 64

TOP = 4999 // RESULT

Click here to visit -ROBO INDIA

Page 17: Servo motor and AVR  Atmel Atmega 16

𝑓𝑝𝑤𝑚 =𝑓𝑐𝑝𝑢

𝑛(1 + 𝑇𝑂𝑃)

fpwm = 20ms (50 Hz)

fcpu = 16000000Hz

n = 64

TOP = 4999 // RESULT

Click here to visit -ROBO INDIA

Page 18: Servo motor and AVR  Atmel Atmega 16

𝑓𝑝𝑤𝑚 =𝑓𝑐𝑝𝑢

𝑛(1 + 𝑇𝑂𝑃)

fpwm = 20ms (50 Hz)

fcpu = 16000000Hz

n = 64

TOP = 4999 // RESULT

Click here to visit -ROBO INDIA

Page 19: Servo motor and AVR  Atmel Atmega 16

𝑓𝑝𝑤𝑚 =𝑓𝑐𝑝𝑢

𝑛(1 + 𝑇𝑂𝑃)

fpwm = 20ms (50 Hz)

fcpu = 16000000Hz

n = 64

TOP = 4999 // RESULT

Click here to visit -ROBO INDIA

Page 20: Servo motor and AVR  Atmel Atmega 16

TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11);

//NON Inverted PWM

TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10);

//PRESCALER=64 MODE 14(FAST PWM)

ICR1=4999;

//fPWM=50Hz (Period = 20ms Standard).

DDRD|=(1<<PD4)|(1<<PD5);

//PWM Pins as Out

Click here to visit -ROBO INDIA

Page 21: Servo motor and AVR  Atmel Atmega 16

• Servo Angle 0 need 0.388ms(388uS) pulse

Value of OCR1A = 388us/4us = 97

• Servo Angle 90 need 1.264ms(1264uS) pulse

Value of OCR1A = 1264us/4us = 316

• Servo Angle 180 need 2.140ms(2140uS) pulse

Value of OCR1A = 2140us/4us = 535

Click here to visit -ROBO INDIA

Page 22: Servo motor and AVR  Atmel Atmega 16

To share your views and queries please write us-

Website: http://roboindia.comEmail- [email protected]

Click here to visit -ROBO INDIA