I. Introduction
DC motors have been widely used due to their good linear speed regulation characteristics, high efficiency, simple control, good speed regulation performance and small size. In conventional motor speed control methods, the motor works unstably and has large losses, especially at low voltage and light load. In addition, the working frequency is limited by the power supply frequency, which makes it difficult to meet the high-precision speed regulation requirements and is not conducive to widespread promotion [1]. The
purpose of our research is to make the circuit have low cost, high control accuracy, convenient debugging and parameter modification, and convenient and flexible application in high-power and high-reliability DC motor control systems.
References [2] and [3] use advanced algorithms and use LTM18200 and L298 as motor control circuits, which have the advantages of high control accuracy, good stability and fast response speed, but their driving ability is low and the cost is high.
II. Principle of DC Motor PWM Speed Regulation The
DC motor speed expression is:
Where: U—armature terminal voltage; I—armature current; R—armature circuit total resistance; —per-pole magnetic flux; K—motor structural parameters.
The speed control methods for DC motors can be divided into the excitation control method that controls the excitation flux and the armature control method that controls the armature voltage. At present, most DC motors use a switch drive method, which makes the semiconductor power device work in a switch state and controls the motor armature voltage through pulse width modulation (PWM) to achieve speed regulation.
PWM (Pulse Width Modulation) - Pulse width modulation technology modulates the width of a series of digital pulses. Under the action of the pulses, when the motor is powered on, the speed increases, and when the power is off, the speed gradually slows down. As long as the power-on and power-off time are changed according to a certain rule, the motor speed can be controlled to realize the digitalization of DC motor speed regulation [4], as shown in Figure 1.
3. Control system hardware design
This speed control system is mainly composed of ATmega8 microcontroller, drive circuit, speed detection circuit and communication interface circuit, as shown in Figure 2.
1. Introduction to ATmega8 microcontroller[5]
ATmega8 is an enhanced AVR RISC CMOS microcontroller with the advantages of high speed, low power consumption, rich on-chip resources, and strong power supply anti-interference ability. ATmega8 has 32 general working registers and a rich instruction set, with a hardware multiplier, 8K FLASH and 1K SRAM, 8-way 10-bit ADC and three-channel PWM output, supports ISP function, and can easily program and modify the device online.
2. ATmega8 implements PWM control
ATmega8's 16-bit T/C can achieve precise program timing, waveform generation and signal measurement. ATmega8 waveform generator uses double buffered output compare register OCR1A/B to compare with T/C value to generate PWM signal, and outputs interference-free pulse, phase-correct, variable frequency PWM signal through output compare pin OC1A/B.
PWM converts pulses with different duty cycles (ratio of motor armature voltage on time to power cycle) into different voltages to drive DC motor to rotate. By changing the duty cycle, different speeds are obtained to realize motor start, stop, and reverse functions.
The microcontroller compares the deviation between the preset speed and the measured speed, obtains the control quantity through PID algorithm, changes the output pulse width of PWM signal according to the control quantity, realizes the control of motor speed after the drive circuit power amplification, and then enters the next control cycle.
3. Driving circuit principle
DC motors are often required to work in forward and reverse situations, so a reversible PWM system is needed. The reversible PWM system can be divided into a bipolar drive reversible PWM system and a unipolar drive reversible PWM system. The bipolar reversible system runs smoothly at low speed, but the current fluctuation is large and the power loss is large. In particular, the dead zone must be increased to avoid the danger of the switch tube being directly connected, which limits the increase in the switching frequency; the unipolar drive method can avoid the switch tube being directly connected, which can greatly improve the reliability of the system. Although there will be a current cut-off under light load, it can be overcome by increasing the switching frequency or improving the circuit design.
The system adopts limited multiplication unipolar reversible PWM drive control, as shown in Figure 3. It can change the control method of the switch tube to make the two ends of the DC motor armature obtain a voltage wave that is 1 times higher than the PWM control signal frequency, which can make up for the current cut-off problem caused by the limited unipolar drive. It has the advantages of strong driving ability, simple control, high reliability and low cost.
PWM is connected to the PWM signal output of the OCR1A pin of ATmega8, and IN1 and IN2 are connected to the forward and reverse control signals of the motor; the specific logic functions of PWM, IN1 and IN2 are shown in Table 1:
4. Control system program design
The control program adopts C language modular structure. It mainly includes main program, PID control program, interrupt service program and motor forward and reverse control program.
1. Main program flow chart
The main program mainly completes the functions of related interrupt initialization, calling display, judging interrupt type and executing corresponding interrupt service program. Its structure is shown in Figure 4:
2. Digital PID controller[1]
In the control system, the PID controller, which uses the proportional P, integral I, and differential D of the deviation between the output and the given quantity to form the control quantity through linear combination, has been widely used. It is easy to set parameters and flexible to change the structure.
PID expression:
Where: u(t) - control quantity; KP - proportional gain factor; TI - integral time; TD - differential time.
This system uses a rotor position sensor, and uses the pulse signal output by the sensor to reflect the motor speed. The signal output by the sensor is sent to the microcontroller after passing through the sampling and conditioning circuit. This pin is used as the input port of the external interrupt source. As the motor rotates, the microcontroller will continuously receive pulse signals. When a rising edge is received, timer T0 will be started to start timing until the next adjacent rising edge is received. The timing result of timer T0 is the time required for the motor to rotate one circle, and the motor speed can be calculated based on this.
Using the PID algorithm, the real-time collected motor speed value is compared with the set value to obtain the deviation, and the speed regulation is achieved using software programming.
This system adopts position digital PID algorithm, and the simplified schematic diagram of its control algorithm is shown in Figure 5:
Using the full-quantity algorithm, the expression can be simplified by substituting difference for differentiation:
Where: ; ;
u(k)——the control quantity at the Kth sampling moment; KP——the proportional amplification factor; kI——the integral amplification factor; kD——the differential amplification system; TS——the sampling period; u0——the base value of the control quantity, that is, the control when k=0.
The PID algorithm flow chart is shown in Figure 6:
[page]
3. Control procedures
The following is part of the program for ATmega8 microcontroller to implement motor control:
Initialization of PWM controller:
void timer1_init(void)
{ OCR1A = 0; //Initialize to 0, motor stop
OCR1B = 0; //Initialize to 0, motor stop
TCCR1A = (1< TCCR1B = (1< TCNT1 = 1;
CLR_IN1;
SET_IN2;
CLR_IN3;
SET_IN4;
}
Timer 0 interrupt service function, used to control the time of PWM1A:
SIGNAL(SIG_OVERFLOW0)
{ if(Timer0_Tick < PWM1A_counter)
{ Timer0_Tick++;}
else{printf("ACK:");
SET_IN3;
SET_IN4;
OCR1A = 0;
TIMSK &= ~_BV(TOIE0);
}
}
Motor forward rotation, speed is the speed (adjustable from 0 to 255), choose is the motor channel selection (R is right, L is left):
void for_ward(uchar speed,char choose)
{ if(ch =='R')
{ OCR1B = speed; // PWM1B_EN;
SET_IN1;
CLR_IN2; }
Else
{ OCR1A = speed; // PWM1A_EN;
SET_IN3;
CLR_IN4; }
}
V. Conclusion
Using the PWM signal generated by the ATmega8 microcontroller, the digital PID algorithm is added to control the motor speed, which improves the control accuracy of the system and ensures the stability of the motor speed; the start, stop, left and right turn and speed of the motor are defined by the program. During debugging, only the duty cycle of the PWM signal needs to be modified to achieve speed control, and the output port level can be changed to achieve the forward and reverse rotation of the motor. Various controls can be achieved without changing the system hardware circuit, which can effectively shorten the development cycle and improve efficiency; combined with the limited multiplication unipolar reversible PWM motor drive circuit, the system's driving ability is enhanced, and the system's reliability and cost performance are improved. The circuit design is simple, the motor control is convenient, and it is conducive to wide promotion.
Previous article:ATmega48 sensor button design based on Atmel QTouch
Next article:Design of LED rotating screen based on ATmega16L chip
Recommended ReadingLatest update time:2024-11-18 13:39
- 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)
- 2.1 uboot transplantation in linux
- uboot relocation code analysis
- ECS operating system: hardware platform porting and driver programming
- "Writing Embedded Operating Systems Step by Step" Reading Notes 1—Skyeye Introduction, Installation and HelloWorld
- The relationship between BootLoader and kernel image
- How to use UBOOT's own loadb command to load the application program into SDRAM for execution
- 6410 bare metal program stuck
- Tiny6410--Modulation software settings
- Data block copying in ARM integrated environment
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- iSoftStone and Renesas enter into a partnership to advance automotive underlying technology innovation
- iSoftStone and Renesas enter into a partnership to advance automotive underlying technology innovation
- NXP FXLS8971CF and FXLS8961AF accelerometers improve your precision inclinometer application performance
- NXP FXLS8971CF and FXLS8961AF accelerometers improve your precision inclinometer application performance
- Industry Summit 2024 to stimulate innovation and promote the development of smart energy technologies
- Industry Summit 2024 to stimulate innovation and promote the development of smart energy technologies
- 2.1 uboot transplantation in linux
- uboot relocation code analysis
- ECS operating system: hardware platform porting and driver programming
- "Writing Embedded Operating Systems Step by Step" Reading Notes 1—Skyeye Introduction, Installation and HelloWorld
- Ask for help
- Disable AD auto-start JLink
- Problems with creating sheet symbols for multi-page schematics
- Zigbee Z-Stack 3.0.1 Modify channels using broadcasting
- 【McQueen Trial】Use IPAD to program McQueen's car
- The STM32 FFT library calculates the amplitude normally, but the phase is different each time. Has anyone encountered this problem?
- Optoelectronic Isolator Application Examples
- RFID tags using FRAM mass storage
- EEWORLD University----UCD3138 Analog Front End (AFE) Module
- Infineon Technologies Launches Monolithic Low-Power Tuner Integrated Circuit TUA6039