First page Back Continue Last page Overview Graphics
Laboratory 4.3 : Stepper Motor
Write an assembly language program to turn the stepper motor. (Start a new project.)
Set bits 2 to 5 of PORTDLC to 1 (output direction).
Output the following sequence to turn the motor clockwise:
Bit # 5 4 3 2 = value
0 1 0 1 = 0x14
1 0 0 1 = 0x24
1 0 1 0 = 0x28
0 1 1 0 = 0x18
This sequence will cause the motor to step four times. Sending the data out in reverse order (or flipping the cable around) will cause the motor to turn in the reverse direction.
Program the port DLC data direction register as outputs by writing ones to bits 2-5 in the address $ff.
Put the step data into an array and use an index register (X or Y) to step through the data.
The data sequence should be sent to PORTDLC (address $fe). Note the bits used. When the end of the array is reached the pointer will need to be reset to the beginning of the array.
Delay 30 milliseconds between each step using a loop delay. Make the delay loop a subroutine.
Save the program, later direction and speed control will be added. The program should run in a continuous loop.
1. Be sure the cable to the stepper motor is connected before performing this exercise.
2 To control the stepper motor the jumper on J2 (lower board) must be moved to the left side position.
3. Other bits of PORTDLC are “don’t care” (either 0 or 1).