Академический Документы
Профессиональный Документы
Культура Документы
(https://electrosome.com/cart/)
(https://electrosome.com)
Interfacing Servo Motor with Atmega32 Microcontroller
B Y L I G O G E O RG E (HTTP S : / / E L E CTRO S O ME . CO M/ A UTHO R/ L I JO P P A NS / ) / 1 CO MME NT
(HTTP S : / / E L E CTRO S O ME . CO M/ I NTE RFA CI NG S E RV O MO TO RWI THA TME G A 3 2
MI CRO CO NTRO L L E R/ # CO MME NTS )
Servo Motor is a DC Motor equipped with error
sensing negative feedback to control the exact
angular position of the shaft. Unlike DC Motors
it will not rotate continuously. It is used to make
angular rotations such as 090°, 0180° etc.
Stepper Motors
(https://electrosome.com/steppermotor/) can
also be used for making precise angular
rotations. But Servo Motors are preferred in
angular motion applications like robotic arm,
since controlling of servo motors are simple,
(https://electrosome.com/wp
needs no extra drivers like stepper motor content/uploads/2012/06/ServoMotor.gif)
(https://electrosome.com/steppermotor/) and
Servo Motor (https://electrosome.com/servomotor/)
only angular motion is possible.
Operation of Hobby Servo Motor is very simple, it has only three wires, two of them (Red and
Black) used to provide power and the third wire is used to provide control signals. Pulse
Width Modulated (https://electrosome.com/pwmpulsewidthmodulation/) (PWM
(https://electrosome.com/pwmpulsewidthmodulation/)) waves are used as control signals
and the angular position is determined by the width of the pulse at the control input. In this
tutorial we are using a servo motor having angle of rotation from 0180° and angular position
can be controlled by varying the pulse width between 1ms to 2ms.
Note : Please refer the datasheet of your Servo Motor, before using the program in this
tutorial. Angular range and control pulse width are different for different servo motors.
Product Support Online
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 1/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
(https://electrosome.com/wpcontent/uploads/2012/06/ServoAngularRotation
PulseWidthModulation.jpg)
Controlling Angular Position of Servo Motor using Pulse Width Modulation (https://electrosome.com/pwm
pulsewidthmodulation/)
Circuit Diagram
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 2/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
(https://electrosome.com/wpcontent/uploads/2013/05/InterfacingServoMotorwith
Atmega32MicrocontrollerCircuitDiagram.jpg)
Interfacing Servo Motor with Atmega32 Microcontroller – Circuit Diagram
8 MHz Crystal is used to provide the required clock for Atmega32 Microcontroller and 22pF
capacitors are used to stabilize the operation of the crystal. 10KΩ resistor and 10μF capacitor
is used to provide the required Power On Reset (POR) to the microcontroller. Control of servo
motor is connected to the first pin of PORTC (RC0), which is declared as an output pin in the
program.
Atmel Studio C Program
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 3/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
#ifndef F_CPU
#define F_CPU 8000000UL // 8 MHz clock speed
#endif
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRC = 0x01; //Makes RC0 output pin
PORTC = 0x00;
while(1)
{
//Rotate Motor to 0 degree
PORTC = 0x01;
_delay_us(1000);
PORTC = 0x00;
_delay_ms(2000);
//Rotate Motor to 90 degree
PORTC = 0x01;
_delay_us(1500);
PORTC = 0x00;
_delay_ms(2000);
//Rotate Motor to 180 degree
PORTC = 0x01;
_delay_us(2000);
PORTC = 0x00;
_delay_ms(2000);
}
}
You can download Atmel Studio files and Proteus files here…
Related Posts:
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 4/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
Interfacing Stepper
Motor with 8051
using Keil C –… Generating PWM
Servo Motor (https://electrosome.com/interfacing
Using 555 Timer IC
(https://electrosome.com/servo
steppermotor8051 (https://electrosome.com/pwm
motor/) keilcat89c51/) using555timeric/)
Interfacing DC Motor
with Atmega32
Microcontroller Stepper Motor or
(https://electrosome.com/interfacing
Step Motor
dcmotoratmega32 (https://electrosome.com/stepper
l293d/) motor/)
Like 3,460 people like this.
electroSome
Follow +1
+ 589
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 5/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
0 Comments electroSome
1 Login
Start the discussion…
Be the first to comment.
ALSO ON ELECTROSOME WHAT'S THIS?
Custom Characters on LCD using PIC – Generating PWM with PIC Microcontroller
MikroC using HiTech C
2 comments • 6 months ago 24 comments • 2 years ago
Interfacing EM18 RFID reader with Using Push Button Switch – MPLAB XC8
Raspberry Pi 6 comments • a year ago
11 comments • 5 months ago
RECENT COMMENTS
sir, one motor is working both on black and white path... i [..]
VRSHA (MAILTO:VARSHA.PANWAR9@GMAIL.COM)
on Line Follower Robot – without using Microcontroller (https://electrosome.com/linefollowerrobotwithout
microcontroller/#comment5061)
how can we connect a relay to this circuit
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 6/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
NASAR KHAN (MAILTO:EMAILTONASARKHAN@GMAIL.COM)
on Simple Water Level Indicator (https://electrosome.com/simplewaterlevelindicator/#comment5060)
Hi, Can you tell me the purpose of using HT12E & HT12D?
VISHWA (MAILTO:VISHWANATH.M90@GMAIL.COM)
on Water Level Indicator and Controller using PIC Microcontroller (https://electrosome.com/waterlevel
indicatorcontrollerpic/#comment5056)
Whats the voltage to get maximum range?
CHETHAN MURTHY (MAILTO:CHETHANMURTHYHS@GMAIL.COM)
on Wireless Transmitter and Receiver using ASK RF Module (https://electrosome.com/wirelesstransmitter
andreceiverusingaskrfmodule/#comment5054)
Its not a programmable IC
CHETHAN MURTHY (MAILTO:CHETHANMURTHYHS@GMAIL.COM)
on Wireless Transmitter and Receiver using ASK RF Module (https://electrosome.com/wirelesstransmitter
andreceiverusingaskrfmodule/#comment5053)
Hello sir can I add a water temperature sensor?
PANDAN (MAILTO:BRENDAN.2PARPAN@GMAIL.COM)
on Water Level Indicator and Controller using PIC Microcontroller (https://electrosome.com/waterlevel
indicatorcontrollerpic/#comment5046)
CAN U PLZ SHARE MORE PHOTOGRAPHS OF THIS PROJECT.... i mean how [..]
VRSHA (MAILTO:VARSHA.PANWAR9@GMAIL.COM)
on Line Follower Robot – without using Microcontroller (https://electrosome.com/linefollowerrobotwithout
microcontroller/#comment5045)
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 7/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
int count=1; if(button==0&&count==1) { led=1; count++; while(botton==0); }
if(button==0&&count==2) { led=0; count=1; [..]
KARTHI (MAILTO:KARTHIVOC6@GMAIL.COM)
on Using Push Button Switch with Atmega32 and Atmel Studio (https://electrosome.com/pushbuttonswitch
atmega32microcontrolleratmelstudio/#comment5044)
RECENT POSTS
GENERATING PWM WITH PIC MICROCONTROLLER – MPLAB XC8
(HTTPS://ELECTROSOME.COM/PWMPICMICROCONTROLLERMPLABXC8/)
BY (HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELECTROSOME.COM)
GETTING STARTED WITH DIPTRACE (HTTPS://ELECTROSOME.COM/GETTING
STARTEDWITHDIPTRACE/)
BY FEBIN MATHEW (HTTPS://ELECTROSOME.COM/AUTHOR/FEBIN/)
INTERFACING EM18 RFID READER WITH ARDUINO UNO
(HTTPS://ELECTROSOME.COM/EM18RFIDREADERARDUINOUNO/)
BY VIVEK KARTHA (HTTPS://ELECTROSOME.COM/AUTHOR/VIVEK_KARTHA/)
INTERFACING DS18B20 TEMPERATURE SENSOR WITH RASPBERRY PI
(HTTPS://ELECTROSOME.COM/DS18B20SENSORRASPBERRYPIPYTHON/)
BY VIVEK KARTHA (HTTPS://ELECTROSOME.COM/AUTHOR/VIVEK_KARTHA/)
ACCESS RASPBERRY PI DIRECTLY FROM WINDOWS PC
(HTTPS://ELECTROSOME.COM/RASPBERRYPIETHERNETDIRECTWINDOWS
PC/)
BY VIVEK KARTHA (HTTPS://ELECTROSOME.COM/AUTHOR/VIVEK_KARTHA/)
INTERFACING EM18 RFID READER WITH RASPBERRY PI
(HTTPS://ELECTROSOME.COM/EM18RFIDREADERRASPBERRYPI/)
BY VIVEK KARTHA (HTTPS://ELECTROSOME.COM/AUTHOR/VIVEK_KARTHA/)
USING UART ON RASPBERRY PI – PYTHON (HTTPS://ELECTROSOME.COM/UARTRASPBERRYPI
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 8/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
PYTHON/)
BY VIVEK KARTHA (HTTPS://ELECTROSOME.COM/AUTHOR/VIVEK_KARTHA/)
CUSTOM CHARACTERS ON LCD USING PIC – MPLAB XC8
(HTTPS://ELECTROSOME.COM/CUSTOMCHARACTERSLCDPICMPLABXC8/)
BY (HTTPS://ELECTROSOME.COM/AUTHOR/LIJOPPANS/)LIGO GEORGE (HTTP://WWW.ELECTROSOME.COM)
SUBSCRIBE US
EMAIL
SUBMIT
PRODUCTS
DC TO DC ADJUSTABLE BUCK CONVERTER
Rs.199.00
(HTTPS://ELECTROSOME.COM/SHOP/DCBUCKCONVERTERLM2596S/)
LPG LNG GAS SENSOR MODULE MQ6
Rs.350.00 Rs.299.00
(HTTPS://ELECTROSOME.COM/SHOP/LPGLNGGASSENSORMODULEMQ6/)
WHITE SCREW MOUNT WHEEL 7X2CM
Rs.70.00 Rs.55.00
(HTTPS://ELECTROSOME.COM/SHOP/WHITESCREWMOUNTWHEEL7X2/)
32.768KHZ CRYSTAL OSCILLATOR
Rs.5.00
(HTTPS://ELECTROSOME.COM/SHOP/32768KHZCRYSTAL/)
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 9/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
GY273 TRIPLE AXIS MAGNETOMETER
Rs.460.00 Rs.399.00
(HTTPS://ELECTROSOME.COM/SHOP/GY273TRIPLEAXISMAGNETOMETER/)
CMOS VGA CAMERA MODULE OV7670
Rs.1,200.00 Rs.899.00
(HTTPS://ELECTROSOME.COM/SHOP/CMOSVGACAMERAMODULEOV7670/)
NORMALLY OPEN DOOR REED SWITCH
Rs.115.00 Rs.99.00
(HTTPS://ELECTROSOME.COM/SHOP/NORMALLYOPENDOORREEDSWITCH/)
AIR QUALITY SENSOR MODULE MQ135
Rs.450.00 Rs.429.00
(HTTPS://ELECTROSOME.COM/SHOP/AIRQUALITYSENSORMODULEMQ135/)
SUBSCRIBE US
SUBMIT
electroSome
Like Page
Follow 589
(https://electrosome.com)
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 10/11
7/15/2015 Interfacing Servo Motor with Atmega32 Atmel AVR Microcontroller
(https://www.positivessl.com)
Terms and conditions (https://electrosome.com/termsconditions/) /
Privacy Policy (https://electrosome.com/privacypolicy/) / Shipping Policy (https://electrosome.com/shippingpolicy/) /
Refund Policy (https://electrosome.com/refundpolicy/) / About Us (https://electrosome.com/aboutus/)
electroSome Discover... Develop... Deliver...
https://electrosome.com/interfacingservomotorwithatmega32microcontroller/ 11/11