Design of DC Motor Speed ​​Measurement and Control System Based on 51 Single Chip Microcomputer

Publisher:温暖心情Latest update time:2011-11-09 Keywords:PWM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
0 Introduction
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.

a.JPG


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]

During the design, the keyboard input can be completed through the five interfaces P0.1~P0.5 of the microcontroller, the P1.6 port can complete the beeping and alarm, P2.0 is connected to the motor, P2.1~P2.4 are connected to the display bit selection, and the P0 port is the display segment selection code. The hardware connection circuit is shown in Figure 2.

b.JPG


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.

c.JPG


Assume that the sample τk is a uniform pulse signal, and its kth rectangular pulse can be expressed as:
d1.jpg
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:
d2.jpg
where, d.JPG , ω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<

[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.

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.

e.JPG

[page]

The main program module mainly sets the starting address of the main program, the starting address of the interrupt service program, the initialization of the relevant memory units and related components, and some subroutine calls, etc. The main program flow chart is shown in Figure 5.

f.JPG


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.

Keywords:PWM Reference address:Design of DC Motor Speed ​​Measurement and Control System Based on 51 Single Chip Microcomputer

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

53.PWM DAC Experiment
1. Principle of PWM DAC N= ARR-1 T = the time of one counting cycle of the timer, which is the inverse of its frequency. n = value of the CCR counter Any continuous signal can be transformed into a representation consisting of a DC component + first harmonic + second harmonic + ... nth harmonic (n = infinity)
[Microcontroller]
53.PWM DAC Experiment
PWM square wave generation 51 program
 PWMH DATA 30H ;Number of high level pulses PWM DATA 31H    ;PWM周期 COUNTER DATA 32H pwmhmin DATA 33H  ORG 0000H  AJMP MAIN  ;ORG 0003H  ;AJMP INT_X0  ;ORG 0013H  ;AJMP INT_X1  ORG 000BH  AJMP INT_T0  ORG 0100H MAIN:   MOV SP,#60H ;Assign initial value to stack pointer        movie,#87h                 
[Microcontroller]
STM8S IO port level output after PWM output stops
STM8S has many timers that support PWM output, but after stopping the timer, what is the IO port level? Either high or low. Therefore, in order to determine the corresponding value after the PWM stops outputting the level, we need to set the CCMR1 register when stopping the PWM output. For example, TIM2_Cmd(DIS
[Microcontroller]
PWM current controller based on AD8205 high-end current sensor
1 Introduction High-performance current sensing and control are required in many industrial applications, such as battery management systems, electromagnetic systems, hydraulic systems, motor control systems, and automotive electrical controls. In most of these application systems, it is necessary to detect small dif
[Power Management]
Summary of problems in PWM wave generation of STM32
Using STM32F103RC Question: The calculation result of PWM duty cycle is correct, but the output is wrong. The motor of Xinxida cannot be unlocked because the function of register is not understood. #include "tim2_pwm.h" #include "stm32f10x_tim.h" void Init_GPIO(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB
[Microcontroller]
Engineers recommend LED dimming and color adjustment method based on two-channel PWM
introduction In 2002, David Berson and others from Brown University in the United States discovered a third type of photoreceptor cell on the retina of mammals, which mainly plays a role in regulating human endocrine, controlling physiological rhythms and other non-visual biological effects. Lighting design has also
[Power Management]
Engineers recommend LED dimming and color adjustment method based on two-channel PWM
How to use 51 single chip microcomputer to generate PWM wave
The 89C51 chip does not have its own PWM generator. If you want to use 51 to generate PWM waves, you must use software programming to simulate. The methods can be roughly divided into two methods: software delay and timer generation. The following will introduce them one by one. 1 Software Delay Method Use software
[Microcontroller]
How to use 51 single chip microcomputer to generate PWM wave
Summary of pwm learning of stm32
Since the chip of the computer mouse we participated in this time was the STM32 series, and time was tight, we basically learned while making the module. We encountered many difficulties, but I still feel that I have learned a lot and want to share it with you. Okay, let's stop talking nonsense and get to the point. P
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号