I wrote this program to rotate a servo motor from 0 to 90 to 180 by using a MCU 8051. The servo motor has minimum control pulse of 0.5 ms and maximum control pulse of 2.5 ms. When this program was simulated using Proteus software it repeated the process '0 to 90 to 180' for three times and stopped at 180. Why did this happen and how to stop it ?
org 000h
mov r2,#50 ;repeating singnal 50 times
stt: clr P1.5 ; duty cycle
mov r3,#1
here1: call delay
djnz r3,here1
setb P1.5
mov r0,#39 ;
here2: call delay
djnz r0,here2
djnz r2,stt
mov r2,#50;repeating singnal 50 times
stt1: clr P1.5 ; duty cycle
mov r3,#3
here11: call delay
djnz r3,here11
setb P1.5
mov r0,#37 ;
here22: call delay
djnz r0,here22
djnz r2,stt1
mov r2,#50 ;repeating singnal 50 times
stt2: clr P1.5 ; duty cycle
mov r3,#5
here111: call delay
djnz r3,here111
setb P1.5
mov r0,#35 ;
here222: call delay
djnz r0,here222
djnz r2,stt2
delay: mov r1,#228 ;generating 500 micro second delay
djnz r1,$
ret
end
Attachments
-
800 bytes Views: 14
Last edited: