Lab 5 Servo Motor PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Center for Advanced Studies in Engineering, Islamabad

Industrial Automation Lab

Experiment # 05: Position Control of Servo Motor Using PIC18

Name of Student: …………………………………………………….

Roll No.: ……………………………………………………………….

Date of Experiment: ………………………………………………….

Report submitted on: ……………………………………………….

Marks obtained: ……………………………………

Remarks: ……………………………………………

Instructor’s Signature: ……………………………...

Spring 2020-Semester VI

Sir Syed CASE Institute of Technology Industrial Automation Lab 1


Position Control of Servo Motor using PIC18

Objectives:
• Controlling the position of servo motor via PWM signal.

Introduction to Servo Motor


What is Servo Motor
A servo motor is an electrical device which can push or rotate an object with great precision.

Applications of Servo Motor:


Nowadays, RC servos are become more popular in
• Robotics,
o Creating humanoid robot
o Biologically inspired robot
o Robotic arm
• The camera auto focus uses a servo motor built into the camera that corrects precisely
the position of lens to sharpen the out-of-focus images.
• Antenna positioning systems

Why Servo Motor:


This is because its’ ability to rotate and maintain and certain location, position or angle according
to control pulses from a single wire.

Servo Mechanism:
Inside a typical RC servo contains a
• Motor
• Gearbox
• Potentiometer to measure the position of the output gear
• Electronic circuit that controls the motor to make the output gear move to the desired
position.
Because all of these components are packaged into a compact, low-cost unit, RC servos are great
actuators for robots.

It is a closed loop system where it uses positive feedback system to control motion and final
position of the shaft. Here the device is controlled by a feedback signal generated by comparing
output signal and reference input signal.
Here reference input signal is compared to reference output signal and the third signal is
produces by feedback system.

Third signal acts as input signal to control device. This signal is present as long as feedback signal
is generated or there is difference between reference input signal and reference output signal.
So the main task of servo mechanism is to maintain output of a system at desired value at
presence of noises.

Industrial Automation Lab 2


Working principle of Servo Motors
A servo consists of a Motor (DC or AC), a potentiometer, gear assembly and a controlling circuit.

• First of all we use gear assembly to reduce RPM and to increase torque of motor.
• Say at initial position of servo motor shaft, the position of the potentiometer knob is such
that there is no electrical signal generated at the output port of the potentiometer.
• Now an electrical signal is given to another input terminal of the error detector amplifier.
• Now difference between these two signals,
o One comes from potentiometer
o Another comes from other source,
o will be processed in feedback mechanism and output will be provided in term of
error signal.
• This error signal acts as the input for motor and motor starts rotating.
• Now motor shaft is connected with potentiometer and as motor rotates so the
potentiometer and it will generate a signal.
• So as the potentiometer’s angular position changes, its output feedback signal changes.
• After sometime the position of potentiometer reaches at a position that the output of
potentiometer is same as external signal provided.
• At this condition, there will be no output signal from the amplifier to the motor input as
there is no difference between external applied signal and the signal generated at
potentiometer, and in this situation motor stops rotating.

How RC Servo Motor Works


• Servo motor is controlled by PWM (Pulse with Modulation) which is provided by the
control wires/Signal wire used to send pulse.
• The parameters for this pulse are that it has a minimum pulse, a maximum pulse, and a
repetition rate.
• Servo motor can turn 90 degree from either direction form its neutral position
• The servo expects to see a pulse every 20 ms and the length of the pulse will determine
how far the motor turns
o 1.5ms pulse will make the motor turn to the 90° position,
o Pulse is shorter than 1.5ms shaft moves to 0°
o Pulse longer than 1.5ms than it will turn the servo to 180°
• All servo motors work directly with your +5V supply rails but we have to be careful on the
amount of current the motor would consume,
o if you are planning to use more than two servo motors a proper servo shield
should be designed.

• PWM period = [(PR2) + 1] • 4 • TOSC • (TMR2 prescale value)

Industrial Automation Lab 3


Figure-1: Servo Motor Control

Industrial Automation Lab 4


Industrial Automation Lab 5
Experimental Work
Task 1
In this experiment, you will have to write a code which will generate a PWM of 50Hz with a
variable high time ranging from 1ms to 2ms.the resulting signal will control the servo motor
against high time values. Your code should be able to control the motor according to figure given
below

Characteristic Schematics are attached. Use the diagram given below to connect the hardware
properly.

Buttons PIC-18F4520 Servo motor

Button 1 =>0◦
Button 2 => 45◦
Button 3 => 90◦
Button 4 => 180◦

Industrial Automation Lab 6


Department of Electrical and Computer Engineering

Industrial Automation Spring 2020

Name: ________________________________ LAB No___________ Roll No: _________________

Rubric Good Satisfactory Poor Marks


(75-100 %) (50-75 %) (0-50 %)

On-Chip resource Judicious use of on- Not careful in using on- Not careful in using 1
management chip resources like chip resources like on-chip resources
RAM, code size, RAM, code size, timers, like RAM, code size,
timers, interrupts interrupts etc or timers, interrupts etc
etc and judiciously carelessly selected and carelessly
selecting the data data type of variables. selected data type of
type of variables. variables.
Code indentation and Proper indentation Indentation of code or No indentation of 1
descriptive variable of code with partially descriptive code and no
name descriptive variable variable names. descriptive variable
names. names.

Lab Report Writing The report is well The report is not The report is not 1
formatted with all formatted or the formatted and the
the queries queries asked are not queries asked are
answered in a answered clearly. answered incorrectly
thoughtful manner. or not clearly.

Task Completion Task completed by Partially complete task None of the 5


fulfilling all the by fulfilling some requirements are
requirements. requirements. fulfilled.

Neat and clean wiring All the components Few but not all the All the components 2
of circuit are wired in a neat, components are wired are not wired in a
clean and safe in a neat, clean and safe neat, clean and safe
manner. manner. manner.

Industrial Automation Lab 7

You might also like