Servo Motor

June 2, 2017

Introduction

A servo motor is a rotary actuator that allows for precise control of angular position, velocity, and acceleration. It consists of a suitable motor coupled to a sensor for position feedback.

evive has two dedicated servo motor outputs pins.

evive servo output channel

Controlling Servo Angle

Servo is controlled on the concept of PWM (Pulse Width Modulation). The refresh interval (the minimum time to refresh servos in microseconds) is 20000, which means that the servo is refreshing at a frequency of 50Hz. For most of the servos, a certain range of PWM correspond to the range of angle servo can rotate. Minimum pulse width is the shortest time for the pulse has been HIGH and the maximum pulse width is the longest time for which the pulse is HIGH. Hence if the range of motor angular position is from 0 to 180, the minimum pulse width corresponds to 0 and the maximum pulse width corresponds to 180.

Signal pin of servo 1 is connected to digital pin 44 and servo 2 is connected to digital pin 45.

Circuit Diagram

evive Servo Fritzing circuit diagram

 

Controlling servo through the evive menu

You can directly connect servo and control angle using inbuilt potentiometers using the evive menu. You just have to navigate to control submenu, select servo and then select which servo you want to control (Servo 1 or Servo 2 or both servo).

Servo Select Menu 2 Servo Control Panel 1 & 2

Controlling servo using servo library

There is a servo library which can be used to control the servo motor. The available functions are provided in the table below:

FunctionReturn data typeComment
attach(int pin);unit8_tAttach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
attach(int pin, int min, int max);unit8_tAs above but also sets min and max values for writes
detach();void 
write(int value);voidIf value is < 200 its treated as an angle, otherwise as pulse width in microseconds
writeMicroseconds(int value);voidWrite pulse width in microseconds
read();IntegerReturns current pulse width as an angle between 0 and 180 degrees
readMicroseconds();IntegerReturns current pulse width in microseconds for this servo (was read_us() in first release)
attached();boolReturn true if this servo is attached, otherwise false

Example

The sample code is given below which uses the library:

Share this Documentation
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Tutorials & Projects
Sun Tracker

DIY Solar Tracker

Learn how to make a light tracker of your own that always points in the direction of the light falling on it.

evive 5V Relay circuit Fritzing Diagram

Relay

Introduction A relay is an electrically operated switch which uses an electromagnet to mechanically operate…
Simple Robotic Arm

Robotic Arm with Two Motors

In this project, we will make the robotic arm without any end effectors. There will be only two servo motors in the robot. We will control this robot using two potentiometers.

Attach the Motors to the Base

DC Motor Driver

evive has a dedicated pair of DC Motor Driver pin outputs, which can be used…
All articles loaded
No more articles to load
Featured Projects
DIY Mini Safe Locker Using Servo

DIY Mini Safe Locker Using Servo

Make your own DIY mini-safe locker using components from the evive Starter Kit and control it using evive’s slide switch!

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart