In the previous discussion about dc motor driver with L298 explained that, dc motor can be set by the L298 motor driver. To adjust the movement of the motor automatically needed circuit that combines the IC Microcontroller and L298.
Many types of IC microcontrollers that can be used to perform this work. Here are discussed using AT89S51 as the IC control. This IC can store data for 4Kbyte. Data entered into the microcontroller is made with a program which is then converted to a file. Hex, this file will be flashed into the IC control.
The following is a simple motor control circuit.
To flash the program from the PC (Personal Computer) to the IC control needed downloader that is connected to the MISO, MOSI, SCK, RESET, VCC and GND of the IC control.
This is a list of programs to control the dc motor automatically using assembly programming :
Start:
motor_right: ; dc motor rotates to the right
mov p1,#00000001b ; p1.0 = 1 and p1.1 = 0
call delay ; call times
mov p1,#0ffh ; stop
call delay ; call times
motor_left: ; dc motor rotates to the left
mov p1,#00000010b ; p1.0 = 0 and p1.1 = 1
call delay
mov p1,#0ffh ; stop
call delay
sjmp start ; jump to start
delay : ;times
mov r1, #255
dly:
mov r2,#100
djnz r2, $
djnz r1,dly
ret
end
0 comments:
Post a Comment