0% found this document useful (0 votes)
28 views32 pages

DC Motor With Speed Control - C2 - G1

The project report details the design and implementation of a DC motor control system using the 8051 microcontroller, focusing on speed control through Pulse Width Modulation (PWM) and bidirectional rotation. Key features include user input via a keypad, an LCD for displaying motor status, and an overload protection system with alerts. The report outlines the objectives, required components, circuit diagram, working principles, and the code used for the microcontroller's operation.

Uploaded by

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

DC Motor With Speed Control - C2 - G1

The project report details the design and implementation of a DC motor control system using the 8051 microcontroller, focusing on speed control through Pulse Width Modulation (PWM) and bidirectional rotation. Key features include user input via a keypad, an LCD for displaying motor status, and an overload protection system with alerts. The report outlines the objectives, required components, circuit diagram, working principles, and the code used for the microcontroller's operation.

Uploaded by

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

ISLAMIC UNIVERSITY OF

TECHNOLOGY

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

Project Report

DC Motor with Speed Control

Group No: G1-C2

Course Code: EEE 4706

Course Name: Microcontroller based system design lab

Group Members:
Student ID Name
Jarin Tasnim Rahman
200021316

200021318 Humayra Tasnim Farah


200021342 Al Mahee Khan
200021356 Tietibieka Moussine
200021358 Afia Tahsin Chowdhury
200021364 Vessah Gbetnkom Njimboket
Abd-Ganyr

1
Contents

1. Objective –​ 3
2. Required Components –​ 4
3. Circuit Diagram –​ 4
4. Features –​ 5
5. Working Principle –​ 7
6. Code –​ 8
7. Hardware Implementation –​ 26
8. Problems Faced During Implementation-​ 29
9. Conclusion​ 30

2
1. Objective –
The project focuses on a DC motor control system based on the 8051 microcontroller (AT89C52).
In this project, a DC motor operating within a voltage range of 3–6V is utilized, which also
supports bidirectional rotation.

The speed of the motor is regulated using Pulse Width Modulation (PWM), a technique that
controls the effective voltage supplied to the motor by varying the duty cycle of on and off signals.
This allows efficient speed control without significant power loss.

Since the power requirement of a DC motor is much higher than what a microcontroller can directly
provide, and the motor’s back electromotive force could potentially damage the microcontroller,
L293D motor driver IC is used. It is capable of supplying a voltage between 4.5V to 6V and a
maximum current of 600mA to the motor. The IC is based on the H-Bridge concept and can control
two DC motors independently using its 16 pins.

The project also incorporates a keypad for user input, an LCD and a buzzer for protection alerts.

Goals of the project:


●​ Bidirectional Control of DC Motor: The project allows the user to select the motor's
rotation (Clockwise or anticlockwise) using a keypad.
●​ Speed Control at Predefined levels: Provide predefined speed levels Low, Medium, High)
through specific buttons on the keypad. PWM is used to control the speed of the motor here.
●​ Manual Motor Stop and Restart: Enable the user to manually stop the motor anytime by
pressing a designated key. Also allow restarting the motor by reselecting the direction and
speed after shutdown.
●​ Overload Protection System: Simulate an overload protection feature to monitor motor
operation. If an overload condition occurs (motor exceeds defined limits), trigger a buzzer
alarm.

3
2. Required Components –

Components Quantity Price (in BDT)

1 L298N H-Bridge Dual Motor Driver 1 183

2 4v 2000 RPM DC Motor 2 80

3 DC-DC 12V to 3.3V & 5V Power Supply 1 110


Module

4 Active Buzzer 5 V 1 18

5 Female to Female Jumper Wires 20 piece 55

6 AT89C52 microcontroller 1 —

7 External 12V supply 1 450

Total 896

3. Circuit Diagram –

4
Components Function

AT89C51 Microcontroller Controls the overall operation. Reads keypad inputs,


displays information on the LCD, and sends command
to LCD, motor driver, buzzer and LED.

Keypad Allows to enter password, set motor speed levels,


direction, manual on and restart.

LCD Shows motor direction, speed (RPM level), and system


messages.

L293D Motor Driver IC Takes low-power control signals from the


microcontroller and drives the DC motor with higher
current.

DC motor Rotates clockwise and anticlockwise at different speeds.

Buzzer Sends alert when overload is detected.

LED Visual Detector when overload is detected.

Reset Circuit (R1+ C1) Ensures the microcontroller starts properly during
power-up.

Crystal Oscillator Provides a stable clock signal for the microcontroller's


operation.

4. Features –
Mandatory Features:
1.​ Choosing pre-defined motor speed using keypad and displaying the rpm on LCD:
Motor speed levels were pre-defined as high, low and med according to the rpm. By pressing a
button, the user can choose a speed level in which the dc motor will operate. The rpm level will also
be displayed in the display. The rpm levels were determined by assuming:
●​ Low level = 25% duty cycle or 500 rpm
●​ Mid level = 50% duty cycle or 1000 rpm
●​ High level= 75% duty cycle or 1500 rpm
Here, estimated rpm = Max rpm of the dc motor x Duty cycle

2.​ Selecting anticlockwise or clockwise direction using keypad and displaying selected
rotation on LCD display: Motor direction can be chosen manually using keyboard by pressing
keyboard buttons. Hence, the direction of rotation can be controlled. Selected direction is displayed

5
on the LCD.

3.​ Overload protection system: If the motor starts rotating at a rpm speed higher than 2000
rpm, then a buzzer is activated and the motor will automatically shut down its operation.

Additional Features:
1.​ Password Protection: A password system is implemented to prevent unauthorized access.
Users must enter the correct password to access the system. The password set in our case is
123ABC.

2.​ Manually turning the motor off and restarting the motor: By pressing a specific button
on the keypad, the user can manually turn off the motor when needed. Once the motor is turned off,
a confirmation message is displayed on the LCD screen. To restart the motor, the user can press
another button on the keypad, after which the system will prompt the user to enter the desired RPM
level for the DC motor operation.

6
5. Working Principle –

Fig: Flowchart of the general procedure

7
Working Procedure:

This flowchart outlines the operation of a password-protected DC motor speed control system
using an 8051 microcontroller. Here’s a detailed breakdown of the process:

●​ Start & Initialization:​


The system begins by displaying an activation message ("SPEED-CONTROLLED DC
MOTOR") on the LCD. The LED lights up. The microcontroller initializes ports, sets up
the LCD, and prepares for user input.
●​ Password Verification:​
The user is prompted to enter a 6-digit password via keypad. The system checks the
entered password against a pre-stored value ('1','2','3','A','B','C').
○​ If incorrect, it displays "WRONG PASSWORD" and loops back for re-entry.
○​ If correct, it shows "MOTOR ACTIVE" and proceeds to the motor control menu.
●​ Feature Selection:​
The user selects motor operations using the keypad:
○​ Keys 1/2/3: Set motor speed levels (LOW/MED/HIGH, corresponding to PWM
duty cycles of 25%, 50%, and 75%).
○​ Key "ON/C": Rotates the motor clockwise (sets logic P1.3=1, P1.4=0).
○​ Key "=" (Anticlockwise): Reverses direction (P1.4=1, P1.3=0).
○​ Key "A" (Overload): Runs the motor at 100% duty cycle (3000 RPM), triggering
a buzzer and LED to indicate overload.
○​ Key "0": Stop the motor (P1.0=0).
○​ Key "B" (Restart): Resets the system to speed and function selections.
●​ Motor Operation:
○​ The motor runs at the selected speed (500 RPM for MED,1000 RPM for MED,
1500 RPM for MED), with real-time feedback displayed on the LCD.
○​ Buzzer rings and LED activate during operation (e.g., LED lights off at 2000 RPM).
○​ Direction changes (clockwise/anticlockwise) are reflected immediately.
●​ Shutdown & Reset:​
Pressing "0" stops the motor, while "B" restarts the entire process, requiring speed
initiations.
○​ This system integrates secure access, variable speed control, and bidirectional
motor operation, with visual/audible alerts for overload conditions.

8
6. Code –
1.​ORG 0000H
2.​MOV SP, #70H
3.​MOV PSW, #00H
4.​;-------------------------------------------------------------
5.​RS EQU P1.1
6.​EN EQU P1.2
7.​LED EQU P1.6 ; Define BUZZER pin as P1.5
8.​BUZ EQU P1.5
9.​;-------------------------------------------------------------
10.​ INITIALIZATION:
11.​ MOV P0, #00H
12.​ MOV P1, #00H
13.​ MOV P2, #00H
14.​ MOV P3, #0FEH
15.​ CLR P1.6
16.​ CLR P1.5
17.​ ;-------------------------------------------------------------
18.​ DATABASE:
19.​ MOV 40H, #'1' ;PASSWORD
20.​ MOV 41H, #'2'
21.​ MOV 42H, #'3'
22.​ MOV 43H, #'A'
23.​ MOV 44H, #'B'
24.​ MOV 45H, #'C'
25.​ ;-------------------------------------------------------------
-
26.​ LCD_INIT:
27.​ MOV R2, #38H ;INITIALIZING LCD, 2 LINES, 5X7 MATRIX
28.​ ACALL COMMAND ;CALLING COMMAND SUBROUTINE
29.​ MOV R2, #0EH ;DISPLAY ON, CURSOR ON
30.​ ACALL COMMAND
31.​ MOV R2, #01H ;CLEARING SCREEN
32.​ ACALL COMMAND
33.​ MOV A,#06H ;INCREMENT CURSOR POSITION
34.​ ACALL COMMAND
35.​ MOV R2, #80H ;CURSOR AT START OF 1ST LINE
36.​ ACALL COMMAND
37.​ MOV A,#3CH
38.​ ACALL COMMAND
39.​
40.​ MOV DPTR,#START1 ;Display Starting message
41.​ ACALL LCD_PRINT ;Subroutine for displaying in LCD
42.​ MOV DPTR,#START2

9
43.​ ACALL LCD_PRINT
44.​
45.​ ;Password
Part--------------------------------------------------
46.​ ;-------------------------------------------------------------
--
47.​ PASSWORD:
48.​ MOV R0, #30H
49.​ MOV R1, #40H
50.​ MOV R2, #0H
51.​
52.​ MOV R3, #6 ;password 6 digits
53.​ MOV R2, #01H ;clear the screen
54.​ ACALL COMMAND
55.​ MOV DPTR, #PASS_MSG ;Prompt for entering password
56.​ LCALL LCD_PRINT
57.​
58.​
59.​
60.​
61.​
62.​ ;KEYPAD
INPUT---------------------------------------------------
63.​ ;SCANNING
COLUMNS-----------------------------------------------
64.​
65.​ L1:
66.​ JNB P3.0, C1 ;Scanning each column for keypress
67.​ JNB P3.1, C2
68.​ JNB P3.2, C3
69.​ JNB P3.3, C4
70.​ SJMP L1
71.​ ;-------------------------------------------------------------
--
72.​
73.​ ;-------------------------------------------------------------
--
74.​ ;SCANNING FOR INPUT IN COLUMN
1---------------------------------------------
75.​ C1:
76.​ JNB P3.4, JUMP_TO_1 ;Number 1 is pressed
77.​ JNB P3.5, JUMP_TO_2 ;Number 2 is pressed
78.​ JNB P3.6, JUMP_TO_3
79.​ JNB P3.7, JUMP_TO_A
80.​ SETB P3.0 ;for checking the next column

10
81.​ CLR P3.1 ;JNB 3.0, C1 is not satisfied
82.​ SJMP L1 ;So, execute next line--check C2
83.​ ;SCANNING FOR INPUT IN COLUMN
2---------------------------------------------
84.​ C2:
85.​ JNB P3.4, JUMP_TO_4 ;These are ordered same as the
86.​ JNB P3.5, JUMP_TO_5 ;physical keypad columns
87.​ JNB P3.6, JUMP_TO_6
88.​ JNB P3.7, JUMP_TO_B
89.​ SETB P3.1
90.​ CLR P3.2
91.​ SJMP L1
92.​ ;SCANNING FOR INPUT IN COLUMN
3---------------------------------------------
93.​ C3:
94.​ JNB P3.4, JUMP_TO_7
95.​ JNB P3.5, JUMP_TO_8
96.​ JNB P3.6, JUMP_TO_9
97.​ JNB P3.7, JUMP_TO_C
98.​ SETB P3.2
99.​ CLR P3.3
100.​ SJMP L1
101.​
102.​
103.​ ;SCANNING FOR INPUT IN COLUMN
4---------------------------------------------
104.​ C4:
105.​ JNB P3.4, JUMP_TO_F
106.​ JNB P3.5, JUMP_TO_0
107.​ JNB P3.6, JUMP_TO_E
108.​ JNB P3.7, JUMP_TO_D
109.​ SETB P3.3
110.​ CLR P3.0
111.​ LJMP L1
112.​
113.​ ;-------------------------------------------------------------
--
114.​ JUMP_TO_0: LJMP NUM_0 ;JNB gives a short jump
115.​ JUMP_TO_1: LJMP NUM_1 ;the numbers will be out of range
116.​ JUMP_TO_2: LJMP NUM_2 ;so, this part is used to redirect
117.​ JUMP_TO_3: LJMP NUM_3 ;using LJMP
118.​ JUMP_TO_4: LJMP NUM_4
119.​ JUMP_TO_5: LJMP NUM_5
120.​ JUMP_TO_6: LJMP NUM_6
121.​ JUMP_TO_7: LJMP NUM_7

11
122.​ JUMP_TO_8: LJMP NUM_8
123.​ JUMP_TO_9: LJMP NUM_9
124.​ JUMP_TO_A: LJMP NUM_A
125.​ JUMP_TO_B: LJMP NUM_B
126.​ JUMP_TO_C: LJMP NUM_C
127.​ JUMP_TO_D: LJMP NUM_D
128.​ JUMP_TO_E: LJMP NUM_E
129.​ JUMP_TO_F: LJMP NUM_F
130.​
131.​ ;-------------------------------------------------------------
--
132.​ NUM_0: ;Number 0 is pressed
133.​ JNB P3.5,NUM_0 ;Wait for key release
134.​ ACALL ASTERISK ;PRINT '*'
135.​ MOV @R0,#'0' ;Store '0' in RAM location 30H
136.​ INC R0 ;R0 = 31H, for storing the next input
137.​ DEC R3 ;1 digit has been entered
138.​ CJNE R3, #0, L2 ;If R3 is not 0, take another input
139.​ LJMP OUT
140.​
141.​ NUM_1: ;number 1 is pressed
142.​ JNB P3.4,NUM_1
143.​ ACALL ASTERISK
144.​ MOV @R0, #'1' ;Store the input in RAM
145.​ INC R0 ;go to next RAM location
146.​ DEC R3 ;for counting the number of i/p
147.​ CJNE R3, #0, L2 ;max number of input reached?NO-take more
148.​ LJMP OUT ;Yes-jump to label 'OUT'
149.​
150.​ NUM_2:
151.​ JNB P3.5,NUM_2
152.​ ACALL ASTERISK
153.​ MOV @R0, #'2'
154.​ INC R0
155.​ DEC R3
156.​ CJNE R3, #0, L2 ;L2 is used to redirect to L1
157.​ LJMP OUT
158.​
159.​ NUM_3:
160.​ JNB P3.6,NUM_3
161.​ ACALL ASTERISK
162.​ MOV @R0, #'3'
163.​ INC R0
164.​ DEC R3
165.​ CJNE R3, #0, L2 ;L1 is out of range, so L2 is used to

12
166.​ ;redirect
167.​ LJMP OUT
168.​
169.​ NUM_4:
170.​ JNB P3.4,NUM_4
171.​ ACALL ASTERISK
172.​ MOV @R0, #'4'
173.​ INC R0
174.​ DEC R3
175.​ CJNE R3, #0, L2
176.​ LJMP OUT
177.​
178.​ NUM_5:
179.​ JNB P3.5,NUM_5
180.​ ACALL ASTERISK
181.​ MOV @R0, #'5'
182.​ INC R0
183.​ DEC R3
184.​ CJNE R3, #0, L2
185.​ LJMP OUT
186.​
187.​ NUM_6:
188.​ JNB P3.6,NUM_6
189.​ ACALL ASTERISK
190.​ MOV @R0,#'6'
191.​ INC R0
192.​ DEC R3
193.​ CJNE R3, #0, L2
194.​ LJMP OUT
195.​
196.​ NUM_7:
197.​ JNB P3.4,NUM_7
198.​ ACALL ASTERISK
199.​ MOV @R0, #'7'
200.​ INC R0
201.​ DEC R3
202.​ CJNE R3, #0, L2
203.​ LJMP OUT
204.​
205.​ ;-------------------------------------------------------------
--
206.​ L2: LJMP L1 ;redirecting to L1,
207.​ ;placed here for maximum coverage
208.​ ;-------------------------------------------------------------
--

13
209.​
210.​ NUM_8:
211.​ JNB P3.5,NUM_8
212.​ ACALL ASTERISK
213.​ MOV @R0, #'8'
214.​ INC R0
215.​ DEC R3
216.​ CJNE R3, #0, L2
217.​ LJMP OUT
218.​
219.​ NUM_9:
220.​ JNB P3.6,NUM_9
221.​ ACALL ASTERISK
222.​ MOV @R0, #'9'
223.​ INC R0
224.​ DEC R3
225.​ CJNE R3, #0, L2
226.​ LJMP OUT
227.​
228.​ NUM_F:
229.​ JNB P3.4,NUM_F ;'*' in physical keypad
230.​ ACALL ASTERISK
231.​ MOV @R0, #'F'
232.​ INC R0
233.​ DEC R3
234.​ CJNE R3, #0, L2
235.​ LJMP OUT
236.​
237.​
238.​ NUM_E:
239.​ JNB P3.6,NUM_E ;'#' in physical keypad
240.​ ACALL ASTERISK
241.​ MOV @R0, #'E'
242.​ INC R0
243.​ DEC R3
244.​ CJNE R3, #0, L2
245.​ LJMP OUT
246.​
247.​ NUM_D:
248.​ JNB P3.7,NUM_D
249.​ ACALL ASTERISK
250.​ MOV @R0, #'D'
251.​ INC R0
252.​ DEC R3
253.​ CJNE R3, #0, L2

14
254.​ LJMP OUT
255.​
256.​ NUM_C:
257.​ JNB P3.7,NUM_C
258.​ ACALL ASTERISK
259.​ MOV @R0, #'C'
260.​ INC R0
261.​ DEC R3
262.​ CJNE R3, #0, L2
263.​ LJMP OUT
264.​
265.​ NUM_B:
266.​ JNB P3.7,NUM_B
267.​ ACALL ASTERISK
268.​ MOV @R0, #'B'
269.​ INC R0
270.​ DEC R3
271.​ CJNE R3, #0, L3 ;redirecting the jump to L1
272.​ LJMP OUT
273.​
274.​ NUM_A:
275.​ JNB P3.7,NUM_A
276.​ ACALL ASTERISK
277.​ MOV @R0, #'A'
278.​ INC R0
279.​ DEC R3
280.​ CJNE R3, #0, L3
281.​ LJMP OUT
282.​
283.​ L3: LJMP L1 ;L2 is also beyond short jump reach
284.​ ;So, redirecting using L3
285.​
286.​ ;-------------------------------------------------------------
--
287.​ ASTERISK: ;Displays an '*' on the LCD panel
288.​ MOV R2, #'*'
289.​ ACALL DISPLAY ;Display subroutine
290.​ RET
291.​
292.​ ;LCD display
subroutine-----------------------------------------
293.​
294.​ LCD_PRINT:
295.​ LOOP:
296.​ CLR A

15
297.​ MOVC A, @A+DPTR
298.​ MOV R2, A
299.​ JZ EXIT ;stop writing when null char is detected
300.​ ACALL DISPLAY ;main display part
301.​ ACALL DELAY ;giving a short delay for LCD
302.​ INC DPTR
303.​ LJMP LOOP
304.​ EXIT:
305.​ MOV R2, #0C0H ;go to the 2nd line of LCD
306.​ ACALL COMMAND
307.​ RET
308.​
309.​ ;-------------------------------------------------------------
--
310.​ DISPLAY:
311.​ MOV P2, R2 ;subroutine for displaying in LCD
312.​ SETB RS ;RW is grounded in Hardware
313.​ SETB EN
314.​ ACALL DELAY
315.​ CLR EN
316.​ RET
317.​ ;-------------------------------------------------------------
--
318.​ COMMAND:
319.​ MOV P2, R2 ;giving instructions to LCD
320.​ CLR RS
321.​ SETB EN
322.​ ACALL DELAY
323.​ CLR EN
324.​ RET
325.​ ;-------------------------------------------------------------
--
326.​
327.​ DELAY:
328.​ MOV 52H, #90 ;50 ms delay (approx)
329.​ D1: MOV 51H, #255
330.​ DJNZ 51H, $
331.​ DJNZ 52H, D1
332.​ RET
333.​ ;-------------------------------------------------------------
--
334.​ ;Checking if the i/p part is
done-------------------------------
335.​
336.​ OUT: SJMP AUTH ;go to verification part

16
337.​
338.​ ;-------------------------------------------------------------
--
339.​ AUTH:
340.​ ACALL DELAY
341.​ MOV R5, #6 ;6 digit password
342.​ MOV R0, #30H ;RAM location of the entered info
343.​ MOV R1, #40H ;RAM location of the saved info
344.​
345.​
346.​
347.​ NEXT:
348.​ MOV A, @R0
349.​ MOV B, @R1
350.​ CJNE A,B, NOPE ;not same?--wrong password.
351.​ INC R0 ;same---carry on
352.​ INC R1
353.​ DJNZ R5, NEXT ;compare all 9 digits
354.​ ;-------------------------------------------------------------
--
355.​
356.​ DECISION: ;password matches
357.​ MOV R2, #01H
358.​ ACALL COMMAND
359.​ MOV DPTR, #ACPT_MSG ;display MOTOR ACTIVE
360.​ ACALL LCD_PRINT
361.​ LJMP MOTOR_ROTATION ;Start Motor part
362.​
363.​ NOPE: ;does not match
364.​ MOV R2, #01H
365.​ ACALL COMMAND
366.​ MOV DPTR, #DENY_MSG ;Display 'Wrong Password'
367.​ ACALL LCD_PRINT
368.​ MOV DPTR, #TRY_AGN ;Display 'Try Again'
369.​ ACALL LCD_PRINT
370.​ LJMP PASSWORD ;Enter password again
371.​
372.​
373.​ ;MOTOR
PART------------------------------------------------------
374.​ ;-------------------------------------------------------------
--
375.​ MOTOR_ROTATION:
376.​ SETB P1.3 ;Input to motor driver
377.​ CLR P1.4 ;Clockwise direction

17
378.​
379.​ ;-------------------------------------------------------------
--
380.​ STARTUP_MOTOR:
381.​ MOV R2, #01H
382.​ ACALL COMMAND
383.​ MOV DPTR, #INT_MSG ;print 'ENTER RPM LEVEL'
384.​ LCALL LCD_PRINT
385.​ MOV DPTR, #PROMPT1 ;show different controls
386.​ LCALL LCD_PRINT
387.​ LCALL DELAY
388.​ MOV DPTR, #PROMPT2
389.​ LCALL LCD_PRINT
390.​
391.​ ;keyboard RPM Input
Scanning------------------------------------
392.​ ;-------------------------------------------------------------
--
393.​ ;SCANNING ALL COLUMN
------------------------------------------
394.​ ML:
395.​ JNB P3.0, CC1 ;logic same as the password part
396.​ JNB P3.1, CC2
397.​ JNB P3.2, CC3
398.​ JNB P3.3, CC4
399.​ SJMP ML
400.​ ;-------------------------------------------------------------
--
401.​ ;SCANNING COLUMN1
----------------------------------------------
402.​ CC1:
403.​ JNB P3.4, JMP_TO_1
404.​ JNB P3.5, JMP_TO_2
405.​ JNB P3.6, JMP_TO_3
406.​ JNB P3.7, JMP_TO_A
407.​ SETB P3.0
408.​ CLR P3.1
409.​ SJMP ML
410.​ ;SCANNING COLUMN2
---------------------------------------------
411.​ CC2:
412.​ JNB P3.4, JMP_TO_4
413.​ JNB P3.5, JMP_TO_5
414.​ JNB P3.6, JMP_TO_6
415.​ JNB P3.7, JMP_TO_B

18
416.​ SETB P3.1
417.​ CLR P3.2
418.​ SJMP ML
419.​ ;SCANNING COLUMN3
---------------------------------------------
420.​ CC3:
421.​ JNB P3.4, JMP_TO_7
422.​ JNB P3.5, JMP_TO_8
423.​ JNB P3.6, JMP_TO_9
424.​ JNB P3.7, JMP_TO_C
425.​ SETB P3.2
426.​ CLR P3.3
427.​ SJMP ML
428.​ ;SCANNING COLUMN4
---------------------------------------------
429.​ CC4:
430.​ JNB P3.4, JMP_TO_F
431.​ JNB P3.5, JMP_TO_0
432.​ JNB P3.6, JMP_TO_E
433.​ JNB P3.7, JMP_TO_D
434.​ SETB P3.3
435.​ CLR P3.0
436.​ LJMP ML
437.​
438.​ ;-------------------------------------------------------------
--
439.​ JMP_TO_0: LJMP M_0 ;MOTOR OFF
440.​ JMP_TO_1: LJMP M_1 ;LEVEL 1
441.​ JMP_TO_2: LJMP M_2 ;LEVEL 2
442.​ JMP_TO_3: LJMP M_3 ;LEVEL 3
443.​ JMP_TO_4: LJMP ML ;NOT NEEDED
444.​ JMP_TO_5: LJMP ML ;continue scanning
445.​ JMP_TO_6: LJMP ML
446.​ JMP_TO_7: LJMP ML
447.​ JMP_TO_8: LJMP ML
448.​ JMP_TO_9: LJMP ML
449.​
450.​ JMP_TO_A: LJMP M_A ;LEVEL 4
451.​ JMP_TO_B: LJMP M_B
452.​ JMP_TO_C: LJMP ML
453.​ JMP_TO_D: LJMP ML
454.​ JMP_TO_E: LJMP M_E ;CLOCKWISE
455.​ JMP_TO_F: LJMP M_F ;ANTI-CLOCKWISE
456.​

19
457.​ ;-------------------------------------------------------------
--
458.​
459.​ M_0:
460.​ JNB P3.5,M_0 ;wait for key release
461.​ MOV R2, #01H
462.​ ACALL COMMAND ;clear LCD screen
463.​ MOV DPTR, #OFF_MSG
464.​ ACALL LCD_PRINT
465.​ LJMP MOTOR_0 ;MOTOR OFF STATE
466.​
467.​
468.​
469.​ M_1:
470.​ JNB P3.4,M_1
471.​ MOV R2, #01H
472.​ ACALL COMMAND
473.​ MOV DPTR, #LVL1
474.​ ACALL LCD_PRINT
475.​ MOV R2, #01H
476.​ ACALL COMMAND
477.​ MOV DPTR, #RPM1
478.​ ACALL LCD_PRINT
479.​ LJMP MOTOR_1 ;RPM LEVEL 1
480.​
481.​
482.​ M_2:
483.​ JNB P3.5,M_2
484.​ MOV R2, #01H
485.​ ACALL COMMAND
486.​ MOV DPTR, #LVL2
487.​ ACALL LCD_PRINT
488.​ MOV R2, #01H
489.​ ACALL COMMAND
490.​ MOV DPTR, #RPM2
491.​ ACALL LCD_PRINT
492.​ LJMP MOTOR_2 ;RPM LEVEL 2
493.​
494.​
495.​
496.​ M_3:
497.​ JNB P3.6,M_3
498.​ MOV R2, #01H
499.​ ACALL COMMAND
500.​ MOV DPTR, #LVL3

20
501.​ ACALL LCD_PRINT
502.​ MOV R2, #01H
503.​ ACALL COMMAND
504.​ MOV DPTR, #RPM3
505.​ ACALL LCD_PRINT
506.​ LJMP MOTOR_3 ;RPM LEVEL 3
507.​
508.​ M_A:
509.​ JNB P3.7,M_A
510.​ MOV R2, #01H
511.​ ACALL COMMAND
512.​ MOV DPTR, #LVL4
513.​ ACALL LCD_PRINT
514.​ LJMP MOTOR_4 ;RPM LEVEL 4
515.​
516.​
517.​ ;-------------------------------------------------------------
--
518.​ M_F:
519.​ JNB P3.4,M_F
520.​ MOV R2, #01H
521.​ ACALL COMMAND
522.​ MOV DPTR, #ANTICLK ;Display 'Anticlockwise'
523.​ ACALL LCD_PRINT
524.​ SETB P1.4 ;anticlockwise rotation
525.​ CLR P1.3
526.​ LJMP ML ;scan for new input
527.​
528.​ M_E:
529.​ JNB P3.6,M_E
530.​ MOV R2, #01H
531.​ ACALL COMMAND
532.​ MOV DPTR, #CLKWISE
533.​ ACALL LCD_PRINT
534.​ SETB P1.3 ;clockwise rotation (In1=1,In2=0)
535.​ CLR P1.4
536.​ LJMP ML
537.​
538.​
539.​ M_B:
540.​ JNB P3.7, M_B
541.​ MOV R2, #01H
542.​ ACALL COMMAND
543.​ MOV DPTR, #RESTART ;display 'Motor off'
544.​ ACALL LCD_PRINT

21
545.​ LJMP MOTOR_ROTATION
546.​
547.​
548.​
549.​
550.​
551.​ ;-------------------------------------------------------------
--
552.​ ;Delay subroutine for PWM
553.​ ;-------------------------------------------------------------
--
554.​ DELAYM:
555.​ MOV R5, #1
556.​ Hl: MOV R4, #100
557.​ H2: MOV R3, #255
558.​ H3: DJNZ R3, H3
559.​ DJNZ R4, H2
560.​ DJNZ R5, Hl
561.​ RET
562.​ ;-------------------------------------------------------------
--
563.​
564.​ LC: MOV P3, #0FEH ;INITIAL CONDITION
565.​ LJMP ML ;SCAN KEYPAD AGAIN
566.​ ;-------------------------------------------------------------
--
567.​ MOTOR_0:
568.​
569.​ CLR P1.0 ;MOTOR OFF
570.​ CLR P1.5
571.​ JNB P3.4,LL ;JNB IS SHORT JUMP,
572.​ JNB P3.5,LL ;SO LL IS USED AS AN INTERMEDIATE STAGE
573.​ JNB P3.6,LL
574.​ SETB P3.0
575.​ CLR P3.3 ;CHECK ROW 4 (* 0 # D)
576.​
577.​ JNB P3.4,LC ;'*' PRESSED
578.​ JNB P3.5,LC ;'0' PRESSED
579.​ JNB P3.6,LC ;'#' PRESSED
580.​ SETB P3.3
581.​ CLR P3.0 ;AGAIN CHECK ROW 1(1 2 3 A)
582.​ JB P3.7,LL
583.​ SJMP MOTOR_0
584.​

22
585.​ ;-------------------------------------------------------------
--
586.​ LL: LJMP ML ;JUMP TO L1
587.​ ;-------------------------------------------------------------
--
588.​
589.​ MOTOR_1:
590.​ CLR LED ;25% DUTY CYCLE
591.​ CLR P1.5
592.​ SETB P1.0
593.​ ACALL DELAYM
594.​ CLR P1.0
595.​ ACALL DELAYM
596.​ ACALL DELAYM
597.​ ACALL DELAYM
598.​
599.​ JNB P3.4,LL ;CHECK FOR NEW INPUT
600.​ JNB P3.5,LL ;KEY 1,2,3,A FOR LEVEL 1-4
601.​ JNB P3.6,LL
602.​ JNB P3.7,LL
603.​ SETB P3.0
604.​ CLR P3.3
605.​
606.​ JNB P3.4,ACL1 ;'*' FOR ANTI-CLOCKWISE
607.​ JNB P3.5,LC ;GO OUT WHEN '0' IS PRESSED
608.​ JNB P3.6,CL1 ;# FOR CLOCKWISE
609.​ SETB P3.3
610.​ CLR P3.0
611.​
612.​ SJMP MOTOR_1
613.​ ;-------------------------------------------------------------
--
614.​ CL1:ACALL CL_MAIN ;FOR CLOCKWISE ROTATION
615.​ SJMP MOTOR_1 ;CONTINUE SAME RPM LEVEL
616.​ ACL1:ACALL ACL_MAIN
617.​ SJMP MOTOR_1
618.​ ;-------------------------------------------------------------
--
619.​ MOTOR_2:
620.​ CLR LED ;50% DUTY CYCLE
621.​ CLR P1.5
622.​ SETB P1.0
623.​ ACALL DELAYM
624.​ ACALL DELAYM
625.​ CLR P1.0

23
626.​ ACALL DELAYM
627.​ ACALL DELAYM
628.​ JNB P3.4,LL
629.​ JNB P3.5,LL
630.​ JNB P3.6,LL
631.​ JNB P3.7,LL
632.​ SETB P3.0
633.​ CLR P3.3
634.​ JNB P3.4,ACL2 ;'*' pressed
635.​ JNB P3.5,LC1
636.​ JNB P3.6,CL2
637.​ SETB P3.3
638.​ CLR P3.0
639.​
640.​ SJMP MOTOR_2
641.​ ;-------------------------------------------------------------
--
642.​ CL2: ACALL CL_MAIN
643.​ SJMP MOTOR_2
644.​ ACL2: ACALL ACL_MAIN ;rotation anticlockwise
645.​ SJMP MOTOR_2 ;continue with the same RPM
646.​
647.​ ;-------------------------------------------------------------
--
648.​ LC1: LJMP ML ;used as a redirect
649.​ ;-------------------------------------------------------------
--
650.​
651.​ ;CLOCKWISE
ROTATION---------------------------------------------
652.​ CL_MAIN:
653.​ MOV R2, #01H
654.​ ACALL COMMAND
655.​ MOV DPTR, #CLKWISE
656.​ ACALL LCD_PRINT
657.​ SETB P1.3
658.​ CLR P1.4
659.​ RET
660.​
661.​ ;ANTI-CLOCKWISE
ROTATION----------------------------------------
662.​ ACL_MAIN:
663.​ MOV R2, #01H
664.​ ACALL COMMAND
665.​ MOV DPTR, #ANTICLK

24
666.​ ACALL LCD_PRINT
667.​ SETB P1.4
668.​ ACALL DELAY
669.​ CLR P1.3
670.​ RET
671.​
672.​ ;-------------------------------------------------------------
--
673.​
674.​
675.​
676.​ MOTOR_3: ;75% DUTY CYCLE
677.​ CLR LED
678.​ CLR P1.5
679.​ SETB P1.0
680.​ ACALL DELAYM
681.​ ACALL DELAYM
682.​ ACALL DELAYM
683.​ CLR P1.0
684.​ ACALL DELAYM
685.​
686.​ JNB P3.4,LL1
687.​ JNB P3.5,LL1
688.​ JNB P3.6,LL1
689.​ JNB P3.7,LL1
690.​ SETB P3.0
691.​ CLR P3.3
692.​
693.​ JNB P3.4,ACL3
694.​ JNB P3.5,LC1
695.​ JNB P3.6,CL3
696.​ SETB P3.3
697.​ CLR P3.0
698.​
699.​ SJMP MOTOR_3
700.​ ;-------------------------------------------------------------
--
701.​ CL3:ACALL CL_MAIN
702.​ SJMP MOTOR_3
703.​ ACL3:ACALL ACL_MAIN
704.​ SJMP MOTOR_3
705.​ ;-------------------------------------------------------------
--
706.​
707.​ MOTOR_4: ;KEY 'A'

25
708.​ SETB LED
709.​ CLR BUZ
710.​ ACALL DELAY
711.​ SETB BUZ
712.​ CLR P1.0 ;100% DUTY CYCLE
713.​ SETB P1.3
714.​ CLR P1.4
715.​ SETB LED ;ON BUZZER WHEN MOTOR EACH 3000RPM
716.​ ACALL DELAYM
717.​ ACALL DELAYM
718.​ ACALL DELAYM
719.​ ACALL DELAYM
720.​ JNB P3.4,LL1
721.​ JNB P3.5,LL1
722.​ JNB P3.6,LL1
723.​ JNB P3.7,LL1
724.​ SETB P3.0
725.​ CLR P3.3
726.​
727.​ JNB P3.4,ACL4
728.​ JNB P3.5,GO
729.​ JNB P3.6,CL4
730.​ SETB P3.3
731.​ CLR P3.0
732.​
733.​ CLR P1.0
734.​
735.​ SJMP MOTOR_4
736.​ ;-------------------------------------------------------------
--
737.​ CL4:ACALL CL_MAIN
738.​ SJMP MOTOR_4
739.​ ACL4:ACALL ACL_MAIN
740.​ SJMP MOTOR_4
741.​
742.​ ;-------------------------------------------------------------
--
743.​ LL1:LJMP ML
744.​ ;-------------------------------------------------------------
--
745.​ GO : LJMP LC1
746.​ ;Display
messages----------------------------------------------------
747.​
748.​ INT_MSG: DB 'ENTER RPM LEVEL',0 ;INITIAL MESSAGE

26
749.​ OFF_MSG: DB 'MOTOR OFF',0
750.​ LVL1: DB 'LOW SPEED',0
751.​ RPM1 : DB '500 RPM',0
752.​ LVL2: DB 'MED SPEED ',0
753.​ RPM2 : DB '1000 RPM',0
754.​ LVL3: DB 'HIGH SPEED ',0
755.​ RPM3 : DB '1500 RPM',0
756.​ LVL4: DB 'OVERLOADED!!',0
757.​ CLKWISE: DB 'ANTI-CLOCKWISE',0
758.​ ANTICLK: DB 'CLOCKWISE',0
759.​
760.​ ;-------------------------------------------------------------
--
761.​ START1: DB 'SPEED-CONTROLLED',0
762.​ START2: DB 'DC MOTOR',0
763.​ PASS_MSG: DB 'ENTER PASSWORD',0
764.​ ACPT_MSG: DB 'MOTOR ACTIVE',0
765.​ DENY_MSG: DB 'WRONG PASSWORD',0
766.​ TRY_AGN: DB 'TRY AGAIN',0
767.​ PROMPT1: DB 'SPEED AT 1-A',0
768.​ PROMPT2: DB 'STOP-DIR-RES',0
769.​ RESTART: DB 'MOTOR RESTARTING',0
770.​
771.​ END

27
7. Hardware Implementation –
Initial Hardware Setup :

System Implementation :

When we power on the system, a red light will illuminate to indicate that the system is on. The
LCD screen will display the message “SPEED-CONTROLLED DC MOTOR” and prompt for a

28
password. If the password entered is incorrect, it will show “Wrong Password” and request the
correct password.Once we proceed with the correct password “Motor ACTIVATED” message
pops up and the display will show messages indicating the keys used for different functions:
“SPEED AT 1-A” and “STOP-DIR-RES.”And will ask for RPM LEVEL. When we select a key,
the motor will operate accordingly. If an overloaded speed is chosen, the buzzer will sound an
alarm, and the working light will turn off. We can shut down the motor at any time and also
restart it whenever needed using the keypad.

Hardware Demonstration:

Fig : MESSAGE INSTRUCTION TO GIVE PASSWORD Fig : IF PASSWORD TYPED WRONG

Fig: Motor Activated with correct Password Fig: Asked For RPM LEVEL

29
Fig:MOTOR Running At Different RPM

Fig:MOTOR Running With Clockwise & Anti-Clockwise Features

30
Fig:MOTOR OVERLOADED & MOTOR OFF Features

8. Problems Faced During Implementation-


1. The code is very long which introduced various challenges including optimizing labels’
position for SJMP coverage and redirecting using different labels so that a distant label can be
jumped to using LJMP.

2.Initially our LCD was not working. It was turned on after giving power to the microcontroller
board but was not showing blinking cursors or any other output on the screen. After lots of trial
and error(Checking LCD using Arduino to ensure it is working properly) the issue was solved by
setting up the initial two pins of LCD shorted and varying the potentiometer value for proper
contrast.

3.For proper implementation of the code manual debugging(checking with multimeter if getting
proper voltage or not and running a code of seven segment display by repeatedly changing the
port numbers) of each and every ports of AT89c52 was done by us.

4.While implementing the buzzer part our initial approach was to use the Buzzer placed on the
microcontroller board itself. But even after proper declaration of this being turned on for specific
motor level(Overload level) it was continuously getting +5v from the beginning of the code.
Solved this issue by using a external buzzer connected with the specified pins of the
microcontroller.

5. The motor driver circuit (L293D) requires higher value of voltage of 12V which cannot be
supplied by the board, so, we need to use external power adapter.

31
9. Conclusion

In this project, we successfully implemented a step-by-step speed control mechanism for a DC


motor using the 8051 microcontroller, bridging theoretical concepts with practical hardware and
software design. The basic functionalities of our project is comprised of

1.​ Running the motor in 3 different speed(Low,Med, High)


2.​ Changing Direction(Clockwise/Anti-clockwise) of rotation of the motor.
3.​ Overload Protection(If motor is overloaded,it turns off; a buzzer alerts the user and turn the
LED off signifying motor is in unsafe condition).

Additional Functionalities added by us

1.Password protection(Motor can be turned on only by using a definite password).Wrong


password wont allow the user to proceed further

2.Manual Restart and off of the motor.

To enhance security and usability, we integrated password protection and manual control options.
Through this project, we not only validated the operational principles of DC motors and
microcontroller interfacing but also demonstrated strategic thinking in system reliability and user
safety. This work lays a strong foundation for future developments in intelligent motor control
systems.

32

You might also like