Exp 15:
Aim: To
develop skills to interface stepper motor to 89c51 and rotate in clockwise and
anticlockwise direction.
Flowchart:
Algorithm:
- Initialize port P2 as output.
- Send hex value 0x33 to port 2 and add delay
- Send hex value 0x66 to port 2 and add delay.
- Send hex value 0xCC to port 2 and add delay.
- Send hex value 0x99 to port 2 and add delay.
- Repeat from step2.
Diagram:
OR
Program:
Step 3: ‘C’
Language Program #include<reg51.h> void delay_ms(unsigned int); void main (void) { P2=0x00; while(1) { P2=0x33;
delay_ms(100); P2=0x66;
delay_ms(100); P2=0xCC; delay_ms(100); P2=0x99; delay_ms(100); } } void delay_ms(unsigned int k) { unsigned int
i,j;
for(i=0;i<k;i++) {
for(j=0;j<1275;j++); } } |
Comments /* Special function register declarations */ /* For the intended 8051 derivative */ //Function prototype declaration //Make port as output //Infinite loop //Delay function |
Conclusion:
In
this experiment, we learnt to develop interface of stepper motor in clockwise
and anticlockwise direction.