You are on page 1of 12

Course: CPE400 Section:CPE41S2

Name/s:Fermin Clyde, Gagabi Rome, Lim Sean, Zurbano, Gene Date Performed:11-4-
2022
Date Submitted:11-4-
2022
Instructor:Engr. Mortos

Laboratory Activity No. 9


Working on Servo Motors

1. Objective(s):

The activity aims to covers the discussions on how to interface motors including servo motors in
Arduino. It also includes the discussions on topic about its components and functions.

2. Intended Learning Outcomes (ILOs):

At the end of the activity student shall able to:

• Use Arduino to control the movement of Servo motor


• Apply digital input, iterations and if statements on the program
• Manipulate C/C++ code to implement the required output sequence

3. Materials
• Hook-up wires
• Servo Motor
• Potentiometer
4. Discussion
Electric Motor

An electric motor converts electrical energy into mechanical energy. It operates by means of receiving
power in rotary motion when current flows within a magnetic field. Motors are broadly classified by
the type of drive power used (source) – AC or DC Motor. They can also be further divided by the
rotational principle.

40
Figure 6.1 – Electric Motors

How does the motor works (source:rohm.com)

Motor Rotation Using a Magnet/Magnetic Force

Around a permanent magnet having a rotational axis:

① When the outer magnets rotate (referred to as a rotating magnetic field),② The N and S
poles attract and repel each other, ③ Causing the magnet with the rotational axis (center) to
turn.

Figure 6.2- Electric Motor

Alternatively, supplying current to a conductor generates a magnetic field around, creating a


rotational magnetic field (magnetic force). This results in the same effect as rotating a magnet.

Figure 6.3- Magnetic Line f Force in Electric Motor

If we wind a conductive wire into a coil the magnetic force is combined, generating a large
magnetic flux along with North and South poles.

41
Figure 6.4- Electric motor coil winded with a conductive wire

Actual Motor Operation

Here we see an actual method used for rotating a motor by generating a rotational magnetic field
from a 3-phase AC source and conductive coils (3-phase AC is an AC signal with phases shifted
120°).

Figure 6.5 – Graph of rotating Electric Motor

• The synthetic magnetic field in ① above is shown in ① below


• The synthetic magnetic field in ② above is shown in ② below
• The synthetic magnetic field in ③ above is shown in ③ below

Figure 6.5 – Electric Motor Internal Connection

As mentioned above, the 3 phase coils (U, V, and W) are wrapped around an iron core, positioned
120° apart, with the higher voltage generated at the North pole(N) and the lower voltage at the
South pole(S). Since each phase varies sinusoidally, the pole (N/S) generated from each coil will
continue to change, along with the magnetic field.

If we look at just the North pole phase, it switches in order from the U coil → V coil → W coil →
U coil, enabling rotation.

DC Motor

42
Figure 6.7 – Structure of DC motor

This DC or direct current motor works on the principal, when a current carrying conductor is placed
in a magnetic field, it experiences a torque and has a tendency to move.This is known as motoring
action. If the direction of current in the wire is reversed, the direction of rotation also reverses.
When magnetic field and electric field interact they produce a mechanical force, and based on that
the working principle of DC motor is established.

Figure 6.6 – Fleming’s Left Hand Rule

The direction of rotation of a this motor is given by Fleming’s left hand rule, which states that if the
index finger, middle finger and thumb of your left hand are extended mutually perpendicular to
each other and if the index finger represents the direction of magnetic field, middle finger indicates
the direction of current, then the thumb represents the direction in which force is experienced by
the shaft of the DC motor. (electrical4u.com)

Servo Motor

There are some special types of application of electrical motor where rotation of the motor is
required for just a certain angle not continuously for long period of time. For these applications,
some special types of motor are required with some special arrangement which makes the motor
to rotate a certain angle for a given electrical input (signal). For this purpose servo motor comes
into picture. This is normally a simple DC motor which is controlled for specific angular rotation
with the help of additional servomechanism (a typical closed loop feedback control system). Now
day’s servo system has huge industrial applications.

Figure 6.7 – Servo Motors


43
Electric Relays

A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or
off a much larger electric current. The heart of a relay is an electromagnet (a coil of wire that becomes
a temporary magnet when electricity flows through it). You can think of a relay as a kind of electric
lever: switch it on with a tiny current and it switches on (“leverages”) another appliance using a much
bigger current. Why is that useful? As the name suggests, many sensors are incredibly sensitive
pieces of electronic equipment and produce only small electric currents. But often we need them to
drive bigger pieces of apparatus that use bigger currents. Relays bridge the gap, making it possible
for small currents to activate larger ones. That means relays can work either as switches (turning
things on and off) or as amplifiers (converting small currents into larger ones). (explainthatstuff.com)

How Does Relay Works?

(a) (b)
Figure 6.8 – Relay on Actions. (a) Unactive connection; (b) Active connection

When power flows through the first circuit (1), it activates the electromagnet (brown), generating a
magnetic field (blue) that attracts a contact (red) and activates the second circuit (2). When the power
is switched off, a spring pulls the contact back up to its original position, switching the second circuit
off again.

This is an example of a “normally open” (NO) relay: the contacts in the second circuit are not
connected by default, and switch on only when a current flows through the magnet. Other relays are
“normally closed” (NC; the contacts are connected so a current flows through them by default) and
switch off only when the magnet is activated, pulling or pushing the contacts apart. Normally open
relays are the most common.
5. Procedures

44
Part I: Interfacing Servo Motor to Arduino
Servo motors have three wires: power, ground, and signal. The power wire is typically red and should
be connected to the 5V pin on the Arduino board.
The ground wire is typically black or brown and
should be connected to a ground pin on the board.
The signal pin is typically yellow or orange and
should be connected to pin9 on the board.

The potentiometer should be wired so that its two


outer pins are connected to power (+5V) and
ground, and its middle pin is connected to analog
input 0 on the board.
Figure 6.8 – Servo Motor Connection

1. Connect the circuit of the following configuration


Servo Motor Pin Arduino Pin
+5v Pin (Red) +5V
Grnd (Black or Brown) Grnd
Input (Orange) Pin9

1. Upload the following code in your Arduino

#include <Servo.h> //include servo motor library


Servo myservo; // create servo object to control a servo

voidsetup(){
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

voidloop(){
myservo.write(45); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
myservo.write(90); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

2. What happen to the program?

45
______________________________________________________________________________
______________________________________________________________________________

3. Upload the following code in your Arduino

#include <Servo.h> //include servo motor library


Servo myservo; // create servo object to control a servo

intpotpin=0; // analog pin used to connect the potentiometer


intval; // variable to read the value from the analog pin

voidsetup(){
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

voidloop(){
val=analogRead(potpin); // reads the value of the potentiometer (value between
//0 and 1023)
val=map(val,0,1023,0,180); // scale it to use it with the servo (value between 0 and
//180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

4. Run the code and rotate the potentiometer. Observed what will happen to the servo motor as the
potentiometer is being rotated.
5. Change the value of 180 on the map function, to 90. What happened to the behavior of the servo
motor?
______________________________________________________________________________
______________________________________________________________________________

46
6. Supplemental Activity
1. Create an Arduino Program that uses delay sequence to control the angle of the
rotation of the servo motor. Table below shows the corresponding angle.

Sequence Servo motor Output rotation Angle


1 180
2 120
3 90
4 45
5 0

CODE:
#include <Servo.h>
Servo myservo;
void setup(){
myservo.attach(3);
}
void loop(){
myservo.write(180);
delay(1000);

myservo.write(120);
delay(1000);

myservo.write(90);
delay(1000);

myservo.write(45);
delay(1000);

myservo.write(0);
delay(1000);
47
}
OUTPUT:
180:

120:

90:

48
45:

49
0:

7. Conclusion:

What conclusion can you make based on the activity?


We conclude that servo motors are simple. This can be operated with or without a 9v battery supply and can
function through Arduino alone by including its interface which is servo.h and using specific codes such as
myservo, etc.

50
8. Assessment (Rubric for Laboratory Performance):

Intended Learning Unsatisfactory Satisfactory Exemplary


Score
Outcomes 1 2 3
Use Arduino to Unable to use Able to use Able to use Arduino
control the Arduino to Arduino to control to control the
movement of Servo control the the movement of movement of Servo
motor movement of Servo motor but motor without errors
Servo motor a with errors
Apply digital input, Unable to apply Able to apply Able to apply digital
iterations and if digital input, digital input, input, iterations and if
statements on the iterations and if iterations and if statements on the
program statements on statements on the program without
the program program errors
but with errors
Manipulate C/C++ Unable to Able to Able to manipulate
code to implement manipulate manipulate C/C++ C/C++ code to
the required output C/C++ code to code to implement implement the
sequence implement the the required required output
required output output sequence sequence without
sequence but with errors errors
Other comments/observation: Total Score
RATING = (total score) x 100%
9
Evaluated by: Date:

__________________
Printed Name and Signature of Faculty Member

51

You might also like