1. System initialization: Generally, the system initialization of a small PLC is mainly to initialize, set up, search for expansion modules, etc.;
2. Scan input: scan IO input signal;
3. Execution logic: execute logic according to user PLC program;
4. Housekeeping: PLC diagnosis, maintenance and other system program execution;
5. Scan output: output the results of logic execution;
6. Communication management unit: communication service program, response programming software and other communication tasks.
PLC operation mode:
From the above we can see that the operation of PLC is a cyclic scanning mode. In fact, PLC also has three scanning modes: timed scanning and interrupt scanning.
Cyclic scanning: PLC executes cyclically according to the above diagram;
Scheduled scanning: PLC scans according to the time set by the user, for example, once every 50ms. When using this scanning method, the user needs to ensure that the user program can complete the scan within the set time. Generally, PLC uses a combination of scheduled interrupts and subroutines to implement this function (in this case, it is no different from the interrupt scanning method). However, there will be some subtle differences in IO scanning, and the function block UpData_IO that refreshes IO immediately may be used.
Interrupt scanning: Interrupt scanning interrupts the operation of the scanning program according to the activation of external or internal interrupts, such as external IO interrupts, high-speed counting interrupts, timing interrupts, etc.
19. PID - temperature control, frequency conversion
PID (Proportional, Integral and Derivative) is the most commonly used algorithm in closed-loop control. It has been widely used in industries including temperature control, water pumps, tension, servo valves, and transportation control. However, since the characteristics of each application object are different, this requires debugging engineers to fully understand the control principle of PID. Only in this way can we apply PID well.
PID principle:
PID is composed of three parts: proportional, differential and integral. In practical applications, only one or two of them are often used, such as P, PI, PD, PID, etc.
From the control principle, when we want the output of a controlled object to reach the value we set, we usually use open-loop or closed-loop control. If the response of the controlled object is very stable and will not be affected by other links, we can choose open-loop control. On the contrary, if the controlled object is affected by the set value, load or source and fluctuates, we should choose closed-loop control. The following figure is a schematic diagram of temperature control:
PID execution cycle (1/10 second) 〔Example〕
Proportional control (P):
Proportional control is one of the most commonly used control methods. It is also the most in line with human perception. For example, if we control a heater to a constant temperature of 100 degrees, when it starts heating, it is far from the target temperature. At this time, we usually increase the heating to make the temperature rise quickly. When the temperature exceeds 100 degrees, we turn off the output. Usually we use such a function
e(t) = SP – y(t);
u(t) = e(t)*P
SP——Set value
e(t)——error value
y(t)——Feedback value
u(t)——output value
P——Proportional coefficient
For control objects with relatively small hysteresis, proportional control can meet the control requirements, but many controlled objects have hysteresis.
For example, for a plastic extruder, if the set temperature is 200 degrees, when proportional control is used, if P is selected to be relatively large, when the temperature reaches 200 degrees and the output is 0, the temperature will still continue to rise, for example, to 230 degrees. When the temperature exceeds 200 degrees too much, it begins to fall again. Although the output begins to heat at this time, the temperature will still fall to a certain temperature before it stops falling and rises again, for example, to 170 degrees. Finally, the entire system will stabilize and oscillate within a certain range.
If the amplitude of this oscillation is allowed, such as the control of household appliances, then proportional control can be used. Many traditional household air conditioners and we often find that household air conditioners are always working intermittently. When the cooling starts, we usually feel colder and colder, and when the air conditioner stops, we feel the temperature is getting higher and higher. It uses proportional control.
Control effect diagram when the proportional value is too small:
If the proportional value is too small, the feedback value will never reach the set value (static error) and a balance will be reached (if it is heating, it means that the heat dissipation and P*e(t) heating have reached a balance)
Control effect diagram when the proportional value is too large:
If the proportional value is too large, the controlled object will oscillate as shown in the figure above. Of course, the oscillation point is not necessarily at the set value, but will oscillate at a certain position depending on the controlled object or the size of the P value. This is not allowed for most control pairs.
Proportional Integral Control (PI):
The existence of integral is an improvement on the characteristic of proportional control that either there is a difference or there is oscillation. It is often controlled together with the proportion, which is PI control.
There are many different formulas, but most of them are not much different. The standard formula is as follows:
u(t) = Kp*e(t) + Ki∑e(t) +u0
u(t)——output
Kp——proportional magnification factor
Ki——Integral amplification factor
e(t)——error
u0——Control quantity reference value (basic deviation)
You can see that the integral term is the accumulated value of historical errors. If only proportional control is used, we know that either the set value cannot be reached or there is oscillation. After using the integral term, the static error problem of not reaching the set value can be solved. For example, after PI control is used in a control, if there is a static error, the output will never reach the set value. At this time, the accumulated error value of the integral term will become larger and larger. After multiplying this accumulated value by Ki, it will account for an increasing proportion of the output, making the output u(t) larger and larger, and ultimately achieving the purpose of eliminating the static error.
When the two PIs are used together, our adjustment method is as follows:
1. First set the I value to 0 and set the P value to a relatively large value. When stable oscillation occurs, we reduce the P value until the P value does not oscillate or oscillates very small (the term is called critical oscillation state). In some cases, we can increase the P value a little bit more.
2. Increase the I value until the output reaches the set value.
3. After the system has cooled down, power it back on to see if the system overshoot is too large or the heating speed is too slow.
Through the above debugging process, we can see that the P value can be mainly used to adjust the response speed of the system, but too large a value will increase the overshoot and stabilization time; and the I value is mainly used to reduce the static error.
The standard PID formula may cause overshoot due to the integral term in slow-response systems such as temperature control. This is because after the heating starts, although the output has been adjusted to the maximum (for example, the PWM output of the solid-state relay is 100% open), the temperature can only rise slowly at this time. At this time, the integral term will increase very quickly. When the temperature reaches the set value, although the proportional term has been output as 0, the integral term will still have a large output due to its high cumulative value, causing temperature overshoot.
In Dewesen's V80, this problem is well solved through measures such as the improved limited weakening integration method, so that the integral term stops integrating when the output is fully open, reducing the impact of integration on such a large time-delay system.
PID control:
Because the existence of I in the PI system will affect the response speed of the entire control system, in order to solve this problem, we added the D differential term in the control. The differential term is mainly used to solve the problem of the system's response speed. The complete formula is as follows:
u(t) = Kp*e(t) + Ki∑e(t) + Kd[e(t) – e(t-1)]+u0
The differential constant in the analog circuit is related to the characteristic frequency, but the differential term in the digital discrete PID actually has some problems, because it only calculates the difference between two errors, and the actual analog PID or the ideal differential formula required by the user should be widened. Only the widened D value can really play a good effect. The differential term plays a role in reducing overshoot and oscillation in the control system, but because the differential term itself is very sensitive to interference, it should be used with caution.
During the debugging process of PID, we should pay attention to the following steps:
1. Turn off I and D, increase P to make it oscillate;
2. Reduce P and find the critical oscillation point;
3. Increase I to reach the target value;
4. Re-power on to see if the overshoot, oscillation and stabilization time meet the requirements;
5. Add some differential terms appropriately for overshoot and oscillation;
6. Note that all debugging should be done under maximum load, so as to ensure that the debugging results are valid within the entire working range;
Position PID and incremental PID:
The PID formulas we mentioned above are all position PID, also known as full PID, which is most commonly used in temperature control, valve control, and water pump control. Another PID formula is called incremental PID and its formula is as follows:
△u(t) = u(t) – u(t-1)
This is most commonly used in motion control, and its output is the difference between two PID operation results. This method can be used for position control of general stepper or servo motors.
21. Motion Control
Motion control has been a hot topic in recent years. Precision positioning, constant speed control, constant torque control, etc. are being used more and more widely in various equipment, which places higher and higher requirements on controllers.
For motion control, the most commonly used ones include stepper motors and servo motors. In addition, servo valves, digital hydraulics, etc. all belong to the same control method. In these motion control systems, we divide them into three categories according to the different control objects: position control, speed control, and torque control. Among them, stepper motors can only be used for position control, while servos can be used for any of the three control methods.
In motion control systems, we can generally use dedicated motion controllers or PLCs to implement motion control functions. Generally speaking, dedicated motion controllers such as CNC systems are more professional and powerful, and have better support for interpolation and G instructions.
For example, a high-end CNC system may support the following functions: after the user draws a drawing with CAD, it is converted into G code and downloaded to the controller. The controller can then execute the corresponding G code to complete the entire control process.
PLC is relatively a more general control platform, and motion control functions are generally implemented through function blocks. The V80 enhanced series (/S) has strong support for two-axis position control and can meet the requirements of most motion control environments. The speed control and torque control of V80 are generally implemented using the E6MAD expansion module. The motion control we mentioned here is the position control function of the CPU module itself.
21.1. Position Control Basics
There are many occasions in equipment control where position control is required, such as various machine tools, winding and arranging cables, paper, cable and pipe cutting to length, packaging, printing, etc. Position control is usually achieved through stepper motors and servo motors. Below we will describe it uniformly using stepper motors.
The stepper motor is an open-loop control element that converts electrical pulse signals into angular displacement or linear displacement. In the case of non-overload, the motor's speed and stop position only depend on the frequency and number of pulses of the pulse signal, and are not affected by load changes, that is, when a pulse signal is added to the motor, the motor rotates a step angle. The existence of this linear relationship, coupled with the characteristics of the stepper motor that only has periodic errors but no cumulative errors, makes it very simple to use stepper motors to control in the fields of speed, position, etc.
PLC uses this characteristic of stepper motor to realize position control function. The interface between PLC and stepper motor is a pulse interface, which we call PTO.
The relationship between pulse and position:
For example, if we need the stepper motor to rotate 90 degrees, and the step angle of the stepper motor is 0.3 degrees, then the number of pulse outputs should be 300. After 300 pulses are output, the motor rotates 90 degrees and stops.
Starting, accelerating and decelerating the stepper motor:
In actual applications, we need to consider that the stepper motor cannot start at high speed when loaded, so the stepper motor needs to use a lower pulse frequency when starting, and then gradually increase the speed, otherwise there will be loss of step and overshoot. At the same time, the general use of stepper motors is open-loop, and once loss of step and overshoot occur, it is an unrecoverable error. (The situation of servo motors is better, but they still cannot start when the load is too large)
In order to prevent step loss and overshoot, we usually start the stepper motor at a low speed and then gradually increase the speed. During the acceleration process, the best is S-type acceleration, which is linear, which is the most consistent with the characteristics of machinery and motors. In actual applications, most of them use linear acceleration and deceleration, which is sufficient for most applications.
Stepper motor forward and reverse rotation:
Forward and reverse rotation is a common method in the operation control system. Since stepper motors do not have feedback devices, they are not suitable for high-speed forward and reverse rotation. Generally speaking, when the stroke is reversed within 100 pulses under no-load conditions, the forward and reverse frequency of stepper motors can only reach less than 10 times/second (most of them are less than 5 times/second), while the forward and reverse frequency of servo motors can reach less than 50 times/second (rigidity should be adjusted higher). Motors from different manufacturers are different, mainly related to the size of inertia.
When rotating forward and reverse, good acceleration and deceleration control support is required, otherwise there will be loss of step and overshoot, and the servo system will start to reverse before it reaches the right position.
In practical applications, we often use proximity switches, photoelectric switches, encoders, and grating rulers to cooperate with stepper motors to complete position control. These methods can be divided into two categories: switch-type positioning and coordinate positioning.
Switch type positioning:
These include proximity switches, photoelectric switches, contact switches, etc. These switches are most commonly placed at the origin to mark zero and eliminate accumulated errors. These systems generally have an origin search process after power-on. Usually, they move in one direction to find the origin, calibrate the origin coordinates, and then start normal operation.
Coordinate positioning:
This type of control uses encoders, grating rulers, electronic rulers (analog voltage interface) and the like, which are divided into absolute encoding and relative encoding. As the name implies, the output signal of absolute encoding is the absolute coordinate, usually a parallel bus, while the output signal of relative encoding is just a serial pulse signal. Because absolute encoders are more expensive, most sites use relative encoding.
Relative encoding signals include AB phase, direction pulse, and up and down pulse.
AB phase is divided into three subdivision modes: *1, *2, and *4. *1 means that the count value of each pulse of AB phase is increased or decreased by 1, *2 means that any rising edge of AB phase is increased or decreased by 1, and *4 means that any rising edge or falling edge of any pulse of AB phase is increased or decreased by 1. The AB phase pulse counting mode of V80 only supports the subdivision mode of *4.
Most encoders use AB phase signals or ABZ signals. Compared with AB phase signals, ABZ signals have an additional Z signal line to indicate the zero point of the encoder. The encoder outputs one pulse per rotation.
Electronic ruler:
Electronic rulers are mostly used in various distance measurement equipment, such as injection molding machine electronic rulers, mold clamping electronic rulers, etc. Electronic rulers can use pulse interfaces or analog interfaces (potentiometers). PLCs need to sample through analog input modules, but the response speed of most PLC analog input modules is too slow to meet the requirements of the site (usually the sampling cycle is about 100mS). V80's high-speed analog expansion module E6MAD can achieve a sampling cycle of mS, so it can be used to implement a high-speed analog electronic ruler interface.
Basically, most motion controls can be composed of the above functions. Having a basic understanding of these concepts is the prerequisite for the correct use of motion control functions.
Previous article:PID calculation and application in DCS and PLC control systems
Next article:NE5539 usage notes
Recommended ReadingLatest update time:2024-11-16 19:39
- Popular Resources
- Popular amplifiers
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- Understanding of TIMERA timing interrupt of MSP430F149
- Live broadcast has ended | ST wide bandgap high-performance silicon carbide and gallium nitride product technology and different application cases
- Huawei P50 series released: the world's first 3D nano-crystal mobile phone
- How to test the continuity of the communication harness?
- 422 to Ethernet
- Thermocouple Calibration Methods
- Please help me with a slightly more detailed analysis of this picture
- FAQ_How to choose TCXO for S2-lp
- [CB5654 Intelligent Voice Development Board Review] First Look at the Intelligent Voice Development Board
- Live broadcast at 3pm today | Keysight Technologies HDMI / DP2.0 online test seminar