0% found this document useful (0 votes)
19 views7 pages

Labsheet 4 IntroMecha 2 1

Lab tutorial

Uploaded by

Faris Izzat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views7 pages

Labsheet 4 IntroMecha 2 1

Lab tutorial

Uploaded by

Faris Izzat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FACULTY OF ELECTRICAL & AUTOMATION

ENGINEERING TECHNOLOGY

INTRODUCTION TO MECHATRONICS
(BMT 2112)

LAB 4
SIMULATION OF ARDUINO IN PROTEUS:
CONTROLLING DC MOTOR

No. CO PO Marks (%)


1 .../...
2 .../...
3 .../...
Total Marks .../...

Update: September 2018 (MHO)


TITLE: SIMULATION OF ARDUINO IN PROTEUS – CONTROLLING DC MOTOR
INTRODUCTION TO MECHATRONICS (BMT 2112)
1.0 OBJECTIVES
i. To learn the method of controlling DC motor with Arduino board
ii. To understand the pulse-width modulation (PWM) function of the PWM
output pins to control speed of dc motor

2.0 THEORY
The lab deals with one type of motor which is DC motor and how they can be operated
with Arduino. There are many things that can be done using motors. We can make a
mobile car move, make a robot turn and others. If the motor is small enough, it can be
directly connected to the Arduino pin and simply turning the pin to High or Low will
control the motor. However, the DC motor that usually used are operated using high
voltage and it could kill the digital pin thus probably burn the Arduino. The solutions
available are to use the transistors or the H-Bridge L293D driver. In this lab, we will
explore using the L293D driver and configure the program to control the direction and
speed of the DC motor.

3.0 LIST OF COMPONENTS


No. Component Quantity
1 Arduino UNO board 1
2 L293D driver 1
3 DC Motor 1
4.0 PROCEDURE 4.1 Controlling Direction of DC Motor
a) Open the ISIS Proteus software and search for Arduino UNO board and L293D
motor driver.
b) Connect the wiring of the L293D (refer Figure 1) according to the following
configuration:
• Pin Vs to +12V supply
• Pin Vass to +5V supply
• Both pin Gnd to ground terminal
• Pin EN1 to +5V supply
• Pin IN1 to pin 7 on Arduino  Pin IN2 to pin 6 on Arduino

Figure 1

Update: September 2018 (MHO) Page 2


INTRODUCTION TO MECHATRONICS (BMT 2112)
c) Next, search for dc motor. Select the dc motor named ACTIVE Simple DC Motor
model. Refer to Figure 2.

Figure 2

d) Place the dc motor next to L293D. Connect one terminal of the dc motor to pin
OUT1, and connect another terminal to pin OUT2. Refer to Figure 3.

Figure 3

e) Type the following program in Arduino IDE software:

Update: September 2018 (MHO) Page 3


INTRODUCTION TO MECHATRONICS (BMT 2112)

f) Save the program with appropriate name and compile the program.
g) Copy the required hex file program and paste it inside the Proteus software.
h) Run the simulation and observe the dc motor direction.
i) Stop the simulation. Type the following program. The program just an addition of
codes from the previous program:

j) Save the program and run again the simulation in Proteus.


k) Observe the direction of the dc motor and record your observation in Table A.
Table A
Direction of Digital Value of
DC Motor IN1 IN2
Clockwise 1 0
Anti-clockwise 0 1

Update: September 2018 (MHO) Page 4


INTRODUCTION TO MECHATRONICS (BMT 2112)
Stop 0 0
4.2 Controlling the Speed of DC Motor
The speed of the DC motor can be change via the EN1 pin using analogWrite()
function. The speed can be set from value of 0 to 255.

a) Use the same circuit as in Figure 3 but this time connect EN1 pin of L293D to pin
5 of the Arduino. Refer to Figure 4.

Figure 4

b) Write the following program in the Arduino IDE software:

Update: September 2018 (MHO) Page 5


INTRODUCTION TO MECHATRONICS (BMT 2112)
c) Save the program with appropriate name and compile the program.
d) Copy the required hex file program and paste it inside the Proteus software.
e) Run the simulation and record your observation in Table B.

Table B
Value at EN1 pin DC motor speed
(Slow / Fast)
60 SLOW
255 FAST
4.3 Exercise
With the knowledge you have obtained from previous lab and in this lab, produce the
circuit and the program to control the following dc motor application:
• Pressing pushbutton A will rotate the dc motor at slow speed (60)
• Pressing pushbutton B will rotate the dc motor at medium speed (130)
• Pressing pushbutton C will rotate the dc motor at full speed (255)
• The dc motor must be stop first before changing to another speed by
pressing pushbutton D

5.0 RESULTS AND DISCUSSION


In 4.1, to determine the direction of motor, I’ve connect between driver and Arduino
from IN 1 to pin 7 for clockwise also IN 2 for anti clockwise. First 5 second, IN 1 is
on and IN 2 is off then the motor spin in clockwise. After 5 second the motor is stop
for 2 second when both IN is off. After that it continue spinning but this time its anti
clockwise for 5 second then its stop again for 2 second.

In 4.2, to determine the speed of motor, I’ve connect between driver and Arduino from
EN 1 to pin 5. The range speed is 0 to 255. For the first spin the speed is 60 and its
code like ‘ analogWrite (EN 1,60). For second one the speed goes from 60 to
maximum which 255 and its code like ‘ analogWrite (EN 1,255)

In exercise 4.3, to control the direction and the speed, I’ve used 4 push button and its
b1, b2, b3, and b4. For b1 I’ve code it to rotate the dc motor at slow speed (60). For b2
I’ve code it to rotate the dc motor at medium speed (130). For b3 I’ve code it to rotate
the dc motor at full speed (255). For b1 I’ve code it for the dc motor must be stop first
before changing to another speed.

Update: September 2018 (MHO) Page 6


INTRODUCTION TO MECHATRONICS (BMT 2112)

6.0 CONCLUSION

The lab deals with one type of motor which is DC motor and how they can be operated
with Arduino. There are many things that can be done using motors. We can make a
mobile car move, make a robot turn and others. If the motor is small enough, it can be
directly connected to the Arduino pin and simply turning the pin to High or Low will
control the motor. However, the DC motor that usually used are operated using high
voltage and it could kill the digital pin thus probably burn the Arduino. The solutions
available are to use the transistors or the H-Bridge L293D driver. In this lab, we will
explore using the L293D driver and configure the program to control the direction and
speed of the DC motor.

Update: September 2018 (MHO) Page 7

You might also like