Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a program to spin the stepper motor. activate bits 1, 2, 4, and 8 in seque

ID: 3552488 • Letter: W

Question

write a program to spin the stepper motor. activate bits 1, 2, 4, and 8 in sequence to energize the electromagnets in turn. The motor can be half stepped by turning on pairs of magnets followed by a single magnet followed by a pair and so on. Please use the file below:


; ================================


; ===== 99Step.asm ===============


; ===== Stepper Motor ============


mov al,1 out 05


mov al,2 out 05


mov al,4 out 05


mov al,8 out 05


mov al,9 out 05


mov al,1 out 05


mov al,3 out 05


mov al,2 out 05


mov al,6 out 05


mov al,4 out 05


mov al,c out 05


mov al,8 out 05


mov al,9 out 05


mov al,1 out 05



end


; ================================


Explanation / Answer

In c languaged am writin g tis :




I m using following c program:

#include<reg51.h>
void main()
{
while(1)
{ void delay (int);
P1=0xCC;
delay(1);
P1=0x66;
delay(1);
P1=0x33;
delay(1);
P1=0x99;
delay(1);
}
}
void delay(int a)
{
unsigned int x,y;
for(x=0;x<10;x++)
for(y=0;y<a;a++);
}

If it steps 2 degree and you want 80 degree then 2 * 40 = 80. Use a counter and count from 1 to 40 and stop the execution of motor code if count is > 40. i.e., put you motor code inside if(cnt <= 40) and before that initialize cnt to 1.