The motor analog control circuits currently used are relatively complex, and the measurement range and accuracy cannot be taken into account at the same time. In addition, the sampling time is long, and it is difficult to measure the instantaneous speed. The motor control system introduced in this article uses the PWM control principle and combines the Hall sensor to collect the motor speed. After the single-chip microcomputer detects it, the speed value is displayed on the display. The single-chip microcomputer analyzes the process quantity of the speed according to the pulse signal output by the sensor, and automatically alarms when it exceeds the limit. This system is also equipped with a key operation instrument, which can be used to adjust the speed of the motor.
1 System solution formulation
The DC motor control system is mainly a control system composed of C8051 single-chip microcomputer as the core. The motor speed in this system is proportional to the voltage at both ends of the motor, and the voltage at both ends of the motor is proportional to the duty cycle of the control waveform. Therefore, the programmable counter array inside the MCU outputs a PWM wave to adjust the voltage at both ends of the motor and the duty cycle of the control waveform, thereby realizing speed regulation. This system uses a Hall sensor to achieve real-time monitoring of the DC motor speed. The design tasks of the system include hardware and software. Hardware design includes scheme selection, circuit schematic design, PCB drawing, and line debugging. Software design includes memory space allocation, design of DC motor control application program module, program debugging, software simulation, etc.
2 Hardware Design
C8051 is a fully integrated mixed signal system-level MCU chip with 64 digital I/O pins. It contains VDD monitor, watchdog timer and clock oscillator. It is a truly independent system-on-chip and can quickly and accurately complete signal acquisition and adjustment. It is also convenient for software programming, interference prevention, and structural optimization of the forward channel.
This single-chip control system can receive external signals in real time through external connection to control external devices. This closed-loop system can more accurately realize the design requirements, thereby formulating a reasonable plan. Figure 1 shows the block diagram of the motor measurement and control system.
In this system, the single-chip microcomputer first sends a control signal to the drive motor, and at the same time, the motor speed signal is detected by the sensor and transmitted to the single-chip microcomputer. The single-chip microcomputer then compares the speed measurement signal with the given speed through software to determine the motor speed, and at the same time sends the current motor speed value to the LED display. In addition, the motor speed can also be set by setting the keyboard. The speed detection device in the system is composed of a Hall sensor, and the speed is converted into a voltage signal through A/D conversion, and then transmitted to the single-chip microcomputer in the form of a pulse. This design method has the characteristics of high frequency response (response frequency of more than 20 kHz), constant output amplitude, and strong anti-electromagnetic interference ability. Among them, the Hall sensor input is a pulse signal, which is very easy to connect to the microprocessor and is also convenient for signal analysis and processing. The TO port of the single-chip microcomputer can count the pulse signal. [page]
The pulse width modulation (Pulse Width Modulation) principle of this system is: the pulse width modulation wave is composed of a series of rectangular pulses with different duty cycles, and its duty cycle is proportional to the instantaneous sampling value of the signal. The system consists of a comparator and a sawtooth wave generator with a period of Ts. If the pulse signal is greater than the sawtooth wave signal, the comparator outputs a positive constant A, otherwise it outputs 0. Figure 3 shows the modulation principle and waveform of the pulse width modulation system.
[page]
The LED display adopts dynamic scanning mode, and uses the microcontroller I/O interface to expand the output, and then the transistor drives the bit selection end of each display and amplifies the current. The independent key adopts the query mode, and the key input is low-effective. The pull-up resistor can be used to ensure that the I/O port is high when the key is disconnected. The five keys extended by the I/O (P0.1~0.5) pin of the microcontroller are defined as: set, start, shift, start, +1 function. After the hardware circuit is determined, the main function of motor speed control will rely on software to achieve.
[page]
Assume that the sample τk is a uniform pulse signal, and its kth rectangular pulse can be expressed as:
where x{t} is a discretized signal; Ts is the sampling period, τ0 is the unmodulated width, and m is the modulation index. Now assume that the pulse amplitude is A, the center is at t=kTs, and τK changes slowly between adjacent pulses, then its Xp(t) can be expressed as:
where,
, ωs is the motor angular velocity, combined with formula (2), it can be seen that the pulse width signal can be composed of the signal x(t) plus a DC component and a phase modulation wave. When τ0<
3 Software Design
The design of the software program of this system can be divided into five steps: comprehensive analysis and determination of the algorithm; design of the program flow chart; reasonable selection and allocation of memory units and working registers; program writing; debugging and running the program on the computer.
The design of application software can adopt modular structure design, which has the advantages that the program structure of each module is relatively simple, and the task is clear, easy to write, debug and modify; secondly, the program has good readability, the program can be modified locally, and the other parts can remain unchanged, which is convenient for function expansion and version upgrade; in addition, for frequently used subroutines, a subroutine library can be established to facilitate multiple module calls; finally, it is convenient for division of labor and cooperation, and multiple programmers can write and debug programs at the same time, so the progress of software development can be accelerated.
This program is implemented by C language programming of 8051 single-chip microcomputer. In the system program design, modular programming can be used. The whole software consists of main program module, speed measurement module, clock module, data communication module, dynamic display module, etc. Each module is designed with structured programming ideas, so it has strong versatility; and the use of modular program structure can make the software easy to debug, maintain and transplant.
The system software can be designed according to the function of the hardware circuit and the connection status of each pin of AT89C51. In order to clarify the functions to be completed by each pin, it is convenient to carry out program design and memory address allocation, and finally complete the modular design of the program.
This system is a DC motor measurement and control system. According to the system performance requirements, in addition to the reset circuit, some function keys should be set: including start key, set key, confirm key, shift key, plus 1 key, etc. Since the microcontroller in this system still has idle I/O port lines, and the number of keys required by the system is not large, an independent key structure can be used.
According to the structure of the DC motor control system, the motor speed control system is a simple application system, and a sequential design method can be used. This design consists of a main program and several interrupt service programs. The entire motor speed measurement and control system can be divided into six modules, and each module completes a certain function. Figure 4 shows the program design module diagram determined according to the circuit diagram.
As for the design of the timer T1 (1s) subroutine, in fact, in the single-chip microcomputer, the timing function can be realized by hardware (timer/counter) or by software timing program. The software
delay program takes up the CPU time, thus reducing the CPU utilization rate. The hardware timing is timed by the timer in the single-chip microcomputer, and after the timer is started, it can work in parallel with the CPU
, so it does not take up the CPU time, thus making the CPU have a higher working efficiency.
This system uses hardware timing and software timing at the same time, that is, the T1 overflow interrupt function is used to realize 10ms timing, and the software delay program is used to realize 1ms timing.
The function of the T1 timer interrupt service program is mainly to realize the reading, detection and cache processing of the speed value.
For the calculation of the initial count value of the timer T1, since the system uses a clock frequency of 6 MHz, the time of one machine cycle is 2μs. In this way, according to the 500 μs timing generated by the T1 timer, the initial count value can be calculated.
The working mode register TMOD=00010000B of the speed measurement and control system designed in this paper, and the T1 timer completes the timing in working mode 2.
4 Program debugging
Program debugging can be compiled on the Weifu simulation software, which supports offline operation. The pure software environment can simulate single step, tracking, full speed, breakpoints; source file simulation, assembly, etc., and can support multi-file mixed programming. The target program after simulation debugging can be solidified into EPROM, and then the 89C51 microcontroller is programmed with a special program burner.
5 Conclusion
This design uses C51 for programming. The program occupies less memory units, has a fast execution speed, and can accurately grasp the execution time and achieve fine control. At the same time, because 89C51 is used as CP-U, and PWM control technology with strong noise resistance is used, the serial port expands the display interface and the I/O port expands the keyboard. Therefore, the off-chip RAM can be omitted, and it is small in size, full in function, compact and flexible, easy to operate, and can be installed at the work site to work alone. Therefore, it has great practical value and good application prospects.
Previous article:Automatic measurement and control of LED energy-saving lighting system based on 51 single-chip microcomputer
Next article:Design of a fast charger for electric bicycle based on AT89C51
Recommended ReadingLatest update time:2024-11-16 15:20
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Intelligent Control Technology of Permanent Magnet Synchronous Motor (Written by Wang Jun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
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
- Theoretical speed calculation of WiFi protocols
- BQ76930: Design help needed for BQ76930 based BMS
- Application of the concepts of virtual short and virtual disconnect in operational amplifiers in actual product circuits
- What is the application of PWM
- Guess the questions in the electronic competition and win prizes!
- MSP430f5529
- What is Full SRT?
- Introduction to MSP430 development tools (JTAG SBW BS)
- The experiment got me all greasy:lol
- EEWORLD University Hall----Live Replay: Supporting 'Dual Carbon' - ADI Smart Factory Solution