With the single-chip microcomputer 8031 as the core, the 8279 chip is used to realize key input and the digital tube is used to display the measured speed. The input voltage analog quantity is converted into digital quantity by ADC0809 (the relevant interface has been connected inside the experimental box) to control the motor speed. Then, the sensor on the motor is connected to the CKMOT interface of DA0832 to connect the pulse signal to INT0 of 8031. The speed is measured by external interrupt. One external interrupt will automatically increase the speed counter by one. The timer is used to generate a one-second timing. The value of the speed counter within one second can be obtained to get the speed of the motor. In addition, the timing counter generates a timer interrupt every 250MS, and the interrupt is used to detect whether there is a new control signal input to achieve the purpose of real-time speed control.
ORG 0000h
ajmp main
ORG 0003h ;External interrupt 0
AJMP ZS
ORG 000BH ;Timer counter 0 interrupt
AJMP JS
ORG 0100H
main: mov sp,#60h
CLR PSW.5 ;Clear flag bit
SETB P1.0 ;Set detection bit
setb et0
SETB IT0 ;External interrupt 0 falling edge valid
SETB EX0 ;Enable T0 interrupt
mov DPTR,#5FFFH ;8279 initialization
MOV A,#0DCH
MOVX @DPTR,A
WAIT: MOVX A,@DPTR
JB ACC.7,WAIT
MOV A,#00H
MOVX @DPTR,A
MOV A,#34H
MOVX @DPTR,A
MOV R0,#30H ; Clear the used value buffer
CL: MOV A,#00H
MOV @R0,A
INC R0
CJNE R0,#36H,CL
MOV 36H,#200
MOV 37H,#20
ACALL DIR
TIME: MOV TMOD,#02H ; One second timer
MOV TH0,#6
MOV TL0,#6
SETB TR0 ; Enable T0 interrupt
SETB EA
LOP2: JNB PSW.5,LOP3
CLR PSW.5
ACALL DIR ;Display the speed in one second
JMP LOP2
LOP3: MOV DPTR,#9FF4H ;Start a/d
MOVX @DPTR,A
;ACALL DELAY1
JB P1.0, $
MOVX A,@DPTR
MOV DPTR,#7FFFH ;Start d/a
MOVX @DPTR,A A
JMP LOP2
JS: PUSH ACC;T0 interrupt subroutine
DJNZ 36H,OUT
DJNZ 37H,next
ajmp next1
next: MOV 36H,#200
ajmp out
next1:SETB PSW.5
MOV 33H,30H
MOV 34H,31H
MOV 35H,32H
MOV 30H,# 0
MOV 31H,#0
MOV 32H,#0
MOV 36H,#200
MOV 37H,#20
OUT: POP ACC
RETI
ZS: PUSH ACC;External interrupt subroutine
CLR EX0
MOV A,30H
ADD A,#1
DA A
MOV 30H,A
CJNE A,#99H,OUT1
MOV 30H,#0
MOV A,31H
ADD A,#1
DA A
MOV 31H,A
CJNE A,#99H,OUT1
MOV 31H,#0
MOV A,32H
ADD A,#1
DA A
MOV 32H,A
OUT1: SETB EX0
POP ACC
RETI
DIR: MOV R0,#33H
MOV DPTR,#5FFFH
MOV A,#92H
MOVX @DPTR,A
MOV R2,#03H
LED: MOV A,@R0
ANL A,#0FH
MOV DPTR,#LEDTAB
MOVC A,@A+DPTR
MOV DPTR,#5EFFH
MOVX @DPTR,A
MOV A,@R0
SWAP A
ANL A,#0FH
MOV DPTR,#LEDTAB
MOVC A,@A+DPTR
MOV DPTR,#5EFFH
MOVX @DPTR,A
INC R0
DJNZ R2,LED
RET
LEDTAB:DB 0c0H,0f9H,0a4H,0b0H,99H,92H,82H,0f8H,80H,90H
DELAY1: MOV R6,#5
DELAY2: MOV R7,#200
DJNZ R7,$
DJNZ R6,DELAY2
RET
END
Previous article:Design and simulation of LED Chinese character display screen based on AT89C51 single chip microcomputer
Next article:Summary of the design and production of electronic temperature alarm based on single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 17:37
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- STC32G Series MCU Technical Reference Manual
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Iprober 520 current probe] Calibration and use in PCB mode
- A brief history of hard disk interface evolution
- Hot plug and unplug
- EEWORLD University ---- STM32CubeMX and STM32Cube HAL basics
- [TI mmWave Radar Evaluation]_3_AWR1843BOOST Corridor Ranging Test Environment
- What is the relationship between the Internet of Things and embedded systems?
- [NXP Rapid IoT Review] + Mobile Synchronizer
- How to use ATA-L series underwater acoustic power amplifier?
- Live broadcast at 10 am today [Infineon Smart Door Lock Solution]
- [GD32E231 DIY Contest] Getting Started