;***************************************************************************
; Photoelectric automatic track tracking vehicle.dt
;***************************************************************************
PORT5 == 0x05 ; define port 5, 6, 7
PORT6 == 0x06
PORT7 == 0x07
;-----------------------------------------------------------------------
IOCE == 0x0E ; define WDT control register IOCE
;-----------------------------------------------------------------------
STATUS == 3 ; define status register STATUS and zero flag Z_FLAG
Z_FLAG == 2
;---------------------------------------------------------------
DLY1 == 13 ; define delay setting unit DLY1, DLY2, DLY3
DLY2 == 14
DLY3 == 15
TEMP == 16 ; define temporary register unit TEMP to store photoelectric read data
;-----------------------------------------------------------------------
ORG 0x00
INIT: MOV A,@0x0FF ; set P7 port all as input
IOW PORT7
IOW PORT5
MOV A,@0x00 ; set P6 port all as output
IOW PORT6
MOV A,@0X11
IOW IOCE ;Turn off the watchdog function
MOV A,@0x00 ;Stop the motor
MOV PORT6,A
;-----------------------------------------------------------------------
MAIN: MOV A,PORT7 ;Read photoelectric input
AND A,@0B00000111 ;Shield the upper 5 bits
XOR A,@0B00000111
MOV TEMP,A
BC STATUS,Z_FLAG ;Clear the zero flag
CHECK0: MOV A,TEMP
XOR A,@0B00000000 ;Is the photoelectric input 000?
JBS STATUS,Z_FLAG
JMP CHECK1
JMP ACT000
CHECK1: MOV A,TEMP
XOR A,@0B00000001 ; Is the photoelectric input 001?
JBS STATUS,Z_FLAG
JMP CHECK2
JMP ACT001
CHECK2: MOV A,TEMP
XOR A,@0B00000010 ; Is the photoelectric input 010? JBS STATUS,Z_FLAG JMP CHECK3 JMP ACT010 CHECK3: MOV A,TEMP XOR A,@0B00000011 ; Is the photoelectric input 011? JBS STATUS,Z_FLAG
JMP CHECK4 JMP ACT011 CHECK4: MOV A,TEMP XOR A,@0B00000100 ; Is the photoelectric input 100? JBS STATUS,Z_FLAG JMP CHECK5 JMP ACT100 CHECK5: MOV A,TEMP XOR A,@0B00000101 ; Is the photoelectric input 101?
JBS STATUS,Z_FLAG
JMP CHECK6
JMP ACT101
CHECK6: MOV A,TEMP
XOR A,@0B00000110 ;Is the photoelectric input 110?
JBS STATUS,Z_FLAG
JMP CHECK7
JMP ACT110
CHECK7: MOV A,TEMP
XOR A,@0B00000111 ;Is the photoelectric input 111?
JBS STATUS,Z_FLAG
JMP MAIN
JMP ACT111
;-----------------------------------------------------------------------
ACT000: NOP ;Keep the status quo, no action, return to
JMP MAIN
ACT001: MOV A,@0B00000100 ;Slightly to the right, M1 stops, M2 rotates forward
MOV PORT6,A
CALL TURNDELAY
JMP ACT101
ACT010: NOP ;No action, return to
JMP MAIN
ACT011: MOV A,@0B00000100 ;Lean to the right, M1 stops, M2 rotates forward
MOV PORT6,A
CALL TURNDELAY
JMP ACT101
ACT100: MOV A,@0B00000001 ;Slightly to the left, M1 rotates forward, M2 stops
MOV PORT6,A
CALL TURNDELAY
JMP ACT101
ACT101: MOV A,@0B00000101 ;Move along the center of the black tape, M1 rotates forward, M2 rotates forward
MOV PORT6,A
JMP MAIN
ACT110: MOV A,@0B00000001 ;Lean to the left, M1 rotates forward, M2 stops
MOV PORT6,A
CALL TURNDELAY
JMP ACT101
ACT111: MOV A,@0B00001001 ;The black tape is not pressed, M1 rotates forward and M2 rotates reversely
MOV PORT6,A
CALL TURNDELAY
CALL TURNDELAY
JMP ACT101
;-----------------------------------------------------------------------
TURNDELAY:MOV A,@50 ;The turning delay is about 100 milliseconds, which needs to be adjusted
MOV DLY3,A
CALL DELAY
RET
;-----------------------------------------------------------------------
;Delay time = 2mS * DLY3
DELAY: MOV A,@25 ;1*(DLY3)
MOV DLY2,A ;1*(DLY3)
INNER2: MOV A,@133 ;1*(DLY3)*(250)
MOV DLY1,A ;1*(DLY3)*(250)
INNER1: DJZ DLY1 ;1*(DLY3)*(250)*(133)
JMP INNER1 ;2*(DLY3)*(250)*(133)
DJZ DLY2 ;1*(DLY3)*(250)
JMP INNER2 ;2*(DLY3)*(250)
DJZ DLY3 ;1*(DLY3)
JMP DELAY ;2*(DLY3)
RET ;Delay return
to EOP
Previous article:EM78P447 infrared remote control motor
Next article:EM78 series single chip microcomputer programming
- Popular Resources
- Popular amplifiers
- Automatic Parking Path Planning and Tracking Control Research for Intelligent Vehicles
- Automatic Parallel Parking Algorithm for a Carlike Robot using Fuzzy PD+I Control
- An Optimization Design of Adaptive Cruise Control System Based on MPC and ADRC
- Optical Coherence and Quantum Optics [US] L. Mandel 2001 edition
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- 4 discount spots left: STEVAL-SPIN3202 three-phase BLDC motor driver board
- [ART-Pi Evaluation] 4: ATT-Pi builds ModBus simulation environment in RTT Studio environment
- 【ST NUCLEO-G071RB Review】ADC_DAC
- Battery charging and discharging circuit
- Show development board, STM32H747-DK, NUCLEO-L552ZE
- Understanding Battery Charger Functionality and Charging Topologies
- 【RPi PICO】Flashing light
- LED life issues
- How big is the driving capability of the DSP chip?
- Analysis and solution of temperature rise factors of CITIC Hua circuit board