Liquid flow control is usually achieved by solenoid valves. In recent years, the structure and control mode of solenoid valves have
changed . With the entry of computers into the control field and the continuous emergence of new power electronic power components, the pulse width modulation (PWM) control mode using fully controlled switching power components has been widely used. This control mode is easy to implement in a single-chip microcomputer, thus providing an opportunity for the digitalization of solenoid valve control.
The proportion, integral, and differential of the deviation are linearly combined to form a control quantity, and this control quantity is used to control the controlled object. Such a controller is called a PID controller. The PID controller first appeared in analog control systems. The traditional analog PID controller realizes its function through hardware (electronic components, pneumatic and hydraulic components). With the emergence of computers, it was transplanted into computer control systems, and the original hardware-implemented functions were replaced by software, so it was called a digital PID controller, and the entire set of algorithms formed was called a digital PID algorithm. Compared with analog PID controllers, digital PID controllers have very strong flexibility and can adjust parameters online according to experiments and experience, so better control performance can be obtained.
2. Liquid flow control system composition
This system uses the AVR series atmega32 microcontroller as the core. By setting the PWM control register of atmega32 to generate a PWM wave with adjustable pulse width, the input voltage of the proportional solenoid valve is modulated to achieve variable control of the liquid flow. The microcontroller collects the actual flow signal through the turbine flowmeter, and uses the digital PID algorithm inside it to modify the value of the PWM control register according to the signal, so as to achieve precise variable control. In order to prevent external interference signals from entering the control system, optical coupling isolation is used between the microcontroller and the turbine to improve the reliability of the system. Temperature sensors and pressure sensors are used to monitor the pressure and temperature in the spray rod. Human-computer dialogue is achieved through a 4*4 keyboard and a 128*64 LCD module, which is convenient for user operation. The system schematic diagram is shown in Figure 2-1:
3 Hardware Part
3.1 PWM Drive Circuit
The PWM pulse signal output by the single-chip microcomputer is input to the G poles of Q1 and Q2 through 7406 and 7407 respectively. In the high-level interval of each PWM cycle, Q1 is turned on, Q2 is turned off, and the solenoid valve is turned on. In the low-level interval of each PWM cycle, Q1 is turned off to cut off the power supply, and the induced electromotive force of the solenoid valve forms a loop through the internal freewheeling diode of Q2. At this time, the G pole of Q2 is at a high level, but the switching diode is turned off due to the clamping effect of the diode. Therefore, by adjusting the PWM wave of the single-chip microcomputer, the duty cycle of the solenoid valve input voltage can be adjusted, thereby achieving flow regulation.
3.2 Proportional solenoid valve
Proportional solenoid valve has been used in the late 1960s and was originally used in hydraulic control systems. With the development of single-chip microcomputers and integrated circuits, it has gradually been applied to the flow control of various liquids. The working principle of the proportional electromagnet is as follows: After the coil is energized, magnetic flux is generated inside the yoke and the armature, and electromagnetic attraction is generated, which attracts the armature to the yoke. At the same time, the spring on the armature is compressed. When the electromagnetic force and spring force on the armature are balanced, the armature stops moving. The suction force of the proportional electromagnet has a linear relationship with the current or voltage of the coil within the effective stroke range. Therefore, by adjusting the input current or voltage, the size of its opening can be controlled, thereby achieving the purpose of variable control. The characteristic curve of the proportional solenoid valve used in this system is shown in Figure 3-1: (Kvs represents the flow rate when the proportional solenoid valve is at its maximum opening, and Kv represents the flow rate value corresponding to a certain voltage or current value).
4. Software
4.1 PWM wave generation
The design uses the single-chip microcomputer atmega32 to generate PWM signals. The PWM mode of the atmega32 timer/counter can be divided into two categories: fast PWM and frequency (phase) adjustment PWM. This design uses the fast PWM mode. Fast PWM can get a relatively high frequency PWM output, and the response is relatively fast, so it has high real-time performance. At this time, the counter only works in a one-way forward counting mode. The upper limit value of the counter determines the frequency of PWM, and the value of the comparison match register determines the size of the duty cycle. The control register settings of fast PWM mode are as follows:
//Output port initialization
PORTD=0x44;
DDRD=0x20;
//T/C1 initialization
TCCR1A=0xC3;/*OC1A outputs high level when compare match, clears ICP falling edge capture when at top value,
clock 1/8 division (tentative), that is, working in inverted pwm mode*/
TCCR1B=0x0A;//10-bit fast pwm mode
TCNT1H=0x00;//start at 0
TCNT1L=0x00;[page]
4.2 PID Algorithm
The basic principle of the conventional PID algorithm is shown in Figure 4-1 below. The control law of the analog PID controller is:
——Proportional coefficient; ——Integral constant; ——Differential constant; ——Control constant.
Since the single-chip control is a sampling control, it can only calculate the control quantity according to the deviation value at the sampling time, and cannot continuously output the control quantity and perform continuous control like analog control. In addition, the amount of data processed by the single-chip is limited. Considering comprehensively, the system adopts incremental PID control, and its algorithm is as shown in formula 4-3:
Where is the sampling error of this time; is the sampling error of the previous time; is the sampling error of the previous time. The flow chart of its control program is shown in Figure 4-2
The program implemented in C is as follows:
void PID()
{float u; //voltage difference
sint z; //this output increment
sint temp1; //temporary record value
float t;
t=itime*T;
Speed_change(); //Convert flow rate into digital quantityif
(Ek==(0-Sheding_liusu)) //When Ek is greater than a certain value, directly add the maximum value
{temp1=0x0000;
SetOutputOCR1A(temp1); }//Set the output compare register valueelse
{
Ek=Sheding_liusu-Celiang_liusu;
u=A*((Ek-Ek_1)+(t/B)*Ek+(C/t)*(Ek-2*Ek_1+Ek_2)); //Incremental PID algorithmz
=u/U1*0x03FF;
temp1=GetOutputOCR1A(); //Read the output compare register valuetemp1
=temp1+z;
SetOutputOCR1A(temp1);
Ek_2=Ek_1;
Ek_1=Ek;}
TCNT1=0x00;}
5. Simulation under Matlab
Matlab is an analysis and simulation software for control systems. It can be used to simulate the control system conveniently and accurately. In order to verify the reliability of the digital PID algorithm, the simulink component under Matlab6.5 is used to simulate the incremental digital PID algorithm. The simulation program is shown in Figure 5-1, and the simulation results are shown in Figure 5-2.
As shown in Figure 5-2, Kp=0.5, Ki=0.001, Kd=0.001,
the simulation results show that the use of PID to adjust the PWM square wave has good dynamics and stability, thus proving the feasibility of the liquid flow control system.
6. Conclusion
This paper introduces the solution of using digital PID algorithm combined with the PWM function of AVR microcontroller to realize liquid flow control, and uses Matlab software for simulation to prove the feasibility of the system. Compared with the hardware PID controller, the digital PID algorithm is easy to operate to adjust the control parameters, and the system setting is flexible. This control system can be applied to liquid flow control in industries such as industry and agriculture, and can also be used for solenoid valve control in hydraulic systems. The
author's innovation in this paper:
Traditional liquid flow control mostly uses high-speed switching solenoid valves. The frequent switching of solenoid valves will produce a large hysteresis, which is not conducive to the real-time performance of the control system. The system uses PWM signals to control the size of the proportional solenoid valve opening, realizes continuous control of the flow, reduces hysteresis, and uses incremental digital PID algorithm to adjust the closed-loop control, making the system adjustment more accurate and stable.
References:
[1] Liu Jinkun, Advanced PID Control Matlab Simulation (2nd Edition), Electronic Industry Press, 2004.
[2] Wang Xiaoming, Single Chip Microcomputer Control of Electric Motor, Beijing: Beijing University of Aeronautics and Astronautics Press, 2002.
[3] Wang Zhenglin et al. Process Control and Simulink Application, Electronic Industry Press, 2006.
[4] Nie Huiping, Solid Coriolis Flowmeter Measurement and Control System Based on ARM and uCOS-II, Microcomputer Information, 2005, Vol. 21, No. 7-2.
Previous article:Atmega32 MCU serial port driver
Next article:ATMEGA32 microcontroller controls stepper motor program
Recommended ReadingLatest update time:2024-11-16 00:48
- Popular Resources
- Popular amplifiers
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
- 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
- Share 2018 Electronics Competition Paper - [B- Fire Extinguishing Aircraft] Fujian Province Ti Cup Special Prize / Xiamen University / Changmen University Team
- About the difference between CC1312R LAUNCHPAD versions
- About the signal input mode of the power amplifier
- My Journey of MCU Development (Part 1)
- How to understand the accuracy parameter (1.5% + 3) of the Fluke F17B+ multimeter?
- Another bottleneck.
- Easy-to-use and cheap microcontroller is here
- Inverting proportional operational amplifier circuit
- Upper computer displays waveform acquisition
- Evaluation Weekly Report 20211129: There are 4 days left for Anxinke NB-IoT and domestic FPGA applications, and the wireless charging mouse pad is waiting to be disassembled (Extra)