HoChiMinh City University of Technology Mechatronics Department
HoChiMinh City University of Technology ME2009 - Control System Technology
Faculty Mechanical of Engineering Lab Assignment 2
Mechatronics Department
Control a DC Motor with Arduino
REPORT
Date:………………… Group: B Duration: 5 class hours
Full Name Student ID Signature Grade
Bùi Minh Hoàng 2013215
Đặng Long Khang Huy 2010277
Lê Đức Huy 2010284
Trần An Khang 1913707
Nguyễn Đắc Thành 1814017
Bùi Nguyễn Quốc Thịnh 2014587
Task 1. Check the below answers: (0.5 points)
• Can you install Arduino IDE successful? Yes No
• Can you connect Mega 2560 board with PC successful? Yes No
• Can you make Led at Pin 13 on the board flash every 1 second? Yes No
• Can you install the Encoder Library successful? Yes No
• Can you run the code in section 3.6 Photoelectric Sensor? Yes No
Task 2. Typing and run the example in section 3.5 Potentiometer and answers the
question below (1 point)
Potentiometer to ADC has a minimum ADC value: adc _ max =.............
Potentiometer to ADC has a maximum ADC value: adc _ min =.............
The resolution of AD convert of Arduino 2560 is n = ........... bits
Task 3. Wire program to read signal of A and B channel of the encoder, determine the
resolution of the encoder (1 point)
Number of pulse per round of encoder : res _ encoder =............. (ppr)
Determine the equation to calculate the speed of motor if the Arduino receives pulses
in 100 milliseconds.
speed = ................................................................................. (rpm)
ME2009 Control system technology 31
HoChiMinh City University of Technology Mechatronics Department
speed = ................................................................................. (degree/s)
Task 4. Typing and run the example in section 3.3 Method control of DC motor (1 point)
• Can you run the code in section successful? Yes No
• Modify your code to add a value 30 to a pwm_value variable every 1 second. If the to
pwm_value > 255, it will be set to 0. (Hint: use For loop and delay function)
0% 25% 50% 75% 100%
Task 5. Use your code in task 4 then modify it to reverse the direction of rotation of motor
as having an obstacle in front of the photoelectric sensor? (1 point)
0% 25% 50% 75% 100%
Task 6. Write a program to change the speed of motor depend on the value ADC of the
potentiometer. As we turn the potentiometer from minimum value to maximum value,
why is the speed of motor changed many times? Please fix this problem? (1 point)
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
0% 25% 50% 75% 100%
Task 7. Write a program to control the motor to the angle = 900 (1.5 point)
0% 25% 50% 75% 100%
Task 8. Write a program to control the motor rotate to angle 900 if we put an obstacle in
front of the photoelectric sensor; otherwise, the motor will return to 00 (1.5 points)
0% 25% 50% 75% 100%
Task 9. Write a program to control the speed of motor = 500 rpm (1.5 point)
0% 25% 50% 75% 100%
ME2009 Control system technology 32