Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

MCTE 4105

MECHATRONICS LAB III


SEM II || SESSION 19/20

TITLE: EXPERIMENT 6: MOTOR CONTROL

SEC 1 || GROUP 9

NO NAMES MATRIC NO.


1. MUHAMMAD AIMAN BIN ZAINAL ABIDIN
1625449
2. MUHAMMAD AMMAR FITRI BIN RAMLAN
1626197
3. MUHAMMAD ARIF BIN KAMARUDDIN
1619589
4. WAN AHMAD IZUDDIN BIN WAN JUSOH
1626873

PLEASE LEAVE THIS PART BLANK

DATE OF SUBMISSION TOTAL MARKS

21st July 2020

N CONTENT MARKS
O
1 OBJECTIVES
1.1 To demonstrate microprocessor interfacing and control of a DC
motor.
2. COMPONENTS NEEDED
1. Personal Computer
2. Breadboard
3. DC Motor
4. HD74LS48P
5. Arduino UNO / ATMEGA328
3. SCHEMATIC DIAGRAM (ONLY FOR DLD & MICROP)
TASK 1 AND 2:
4 FLOW CHART (ONLY MICROP)
Task 1: Drive the DC motor in clockwise and counter clockwise direction.

Task 2: Control Speed of the motor using PWM.


5 CODING (ONLY FOR MICROP)
Task 1: Drive the dc motor in clockwise and counterclockwise direction.

START
LDI R16, $FF
OUT DDRB, R16
LDI R21, 0B00000010 //register number 2 as binary as r21
OUT PORTB, R21
CALL DELAY
LDI R21, 0B00000001 //register number 1 as binary as r21(motor moves opposite)
OUT PORTB, R21
CALL DELAY
RJMP START
DELAY:
LDI R18, 200
LDI R19, 150
LDI R20, 50
L2:
DEC R20
BRNE L2
DEC R19
BRNE L2
DEC R18
BRNE L2
NOP
RET

Task 2: Control speed of the motor using PWM

LDI R27, $FF


OUT DDRB, R27
OUT DDRD, R27
START:
LDI R16, 0B01110101
OUT TCCR0A, R16
LDI R16, 0B01110101
OUT TCCR0B, R16
CALL SPEED1
OUT OCR0A, R16
CALL DELAY
CALL SPEED2
OUT OCR0A, R16
OUT OCR0B, R17
CALL DELAY
CALL SPEED3
OUT OCR0A, R16
OUT OCR0B, R17
CALL DELAY
JMP START
DELAY:
LDI R18, 200
LDI R19, 150
LDI R20, 50
L2:
DEC R20
BRNE L2
DEC R19
BRNE L2
DEC R18
BRNE L2
NOP
RET
SPEED1:
LDI R16, 255 // SPEED 1 = PWM = 255 (FULL SPEED)
RET
SPEED2: // SPEED 2 = PWM = 105 (FULL SPEED)
LDI R16, 255
LDI R17, 150
RET
SPEED3: // SPEED 3 = PWM = 55 (FULL SPEED)
LDI R16, 255
LDI R17, 200
RET

8. DISCUSSION

In this experiment, we will use dc motor as output to see how the


microprocessor can control directly to the output. In the first task, we will
set the dc motor so that it can rotate clockwise and counter-clockwise. We
set the pin 2 to high thus giving the motor power to move in one direction
with the set-up circuit. When we apply pin 1 to HIGH and pin 2 to LOW,
the motor will move in opposite direction.

For the second task, we do experiment on moving the dc motor


according to speed that we set by using Pulse Width Modulation, PWM. In
Atmel application which use assembly language, PWM is controlled with
OC0A and OC0B pin while TCCR0A and TCCR0B in timer and counter
control register is set according to program. Duty cycle is time interval
when it is in ‘on’ state. The digital signal is 50% duty cycle when it is only
exactly is half time of its state thus its signal looks like square wave. The
digital signal is higher than 50% duty cycle when it has more period in live
state while the digital signal is lower than 50% duty cycle when it has more
period in dead state. So, the speed can be increase by increasing the duty
cycle.
Task 1:

Task2:
Video for Experiment 6:

https://youtu.be/SgwqPejrCR8

9. CONCLUSION
To conclude, the motor moving according to the code show that
the experiment achieve its objectives. We can control the speed of the DC
motor by differ the value of its counter and timer.

You might also like