EXPERIMENT NO DATE
EXPERIMENT NAME
Aim: To interface stepper motor with 8051 microcontroller using Keil version 5 and Peotus
software
Apparatus required:
[Link] version 5
[Link] software
Procedure:
1. Hardware Setup:
1. Select stepper motor: Choose a stepper motor that is compatible with the 8051
microcontroller's power supply and driving current.
2. Assemble the circuit: Connect the stepper motor's coils to the appropriate pins on the
8051 microcontroller. The specific connections will depend on the microcontroller's pin
out and the stepper motor's configuration.
3. Power supply: Ensure that the stepper motor and microcontroller are powered from a
suitable voltage source.
2. Software Development:
1. Create a new project in Keil uVision 5: Start Keil uVision 5 and create a new project
for your 8051 microcontroller.
2. Add necessary files: Include the header files and libraries required for interfacing with
the 8051 microcontroller and the stepper motor.
3. Write the ALP code: Develop the ALP code to control the stepper motor. This code will
involve generating the necessary pulse sequences to drive the coils and control the
motor's rotation.
4. Compile and build the project: Compile and build the project to generate the
executable file.
3. Simulation and Testing:
1. Create a new project in Proteus: Start Proteus and create a new project.
2. Add components: Place the 8051 microcontroller, stepper motor, and other necessary
components on the virtual breadboard.
3. Connect components: Connect the components together using virtual wires, following
the same connections as in the hardware setup.
4. Load the executable file: Load the executable file generated from Keil uVision 5 into
the virtual 8051 microcontroller.
5. Run the simulation: Run the simulation to observe the stepper motor's movement and
verify the functionality of the code.
ALP CODE:
// Full Drive Mode
ORG 00H
MOV TMOD,#01H
MAIN:
MOV P2, #0CH
ACALL DELAY
MOV P2, #06H
ACALL DELAY
MOV P2, #03H
ACALL DELAY
MOV P2, #09H
ACALL DELAY
SJMP MAIN
// To generate a delay of 200 * 1 ms = 200ms
DELAY:MOV R0,#200 //change this value to required delay in ms
BACK: MOV TH0,#0FCH
MOV TL0,#018H
SETB TR0
wait: JNB TF0,wait
CLR TR0
CLR TF0
DJNZ R0,BACK
RET
END
// Half Drive Mode
ORG 00H
MOV TMOD,#01H
MAIN:
MOV P2, #08H
ACALL DELAY
MOV P2, #0CH
ACALL DELAY
MOV P2, #04H
ACALL DELAY
MOV P2, #06H
ACALL DELAY
MOV P2, #02H
ACALL DELAY
MOV P2, #03H
ACALL DELAY
MOV P2, #01H
ACALL DELAY
MOV P2, #09H
ACALL DELAY
SJMP MAIN
// To generate a delay of 200 *1ms
DELAY:MOV R0, #200 //change this value to required delay in ms
BACK: MOV TH0, #0FCH
MOV TL0, #018H
SETB TR0
wait: JNB TF0, wait
CLR TR0
CLR TF0
DJNZ R0, BACK
RET
END
Result: