Discussion on PID Calculation and Motion Control of PLC

Publisher:legend8Latest update time:2012-03-09 Keywords:PLC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
PLC Workflow

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.

Keywords:PLC Reference address:Discussion on PID Calculation and Motion Control of PLC

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

Application of PLC in Mine Hoist Control System
0 Introduction The successful use of devices with programmable controller (PLC) as the core in mine hoists not only reflects the basic functions of PLC and can replace complex relay control, but also realizes functions that are difficult to complete in the original electronic circuit with rich program instruct
[Industrial Control]
Application of PLC in Mine Hoist Control System
Design of PLC backplane bus protocol interface chip based on single chip microcomputer and CPLD (Part 2)
3.2 Hardware Programming Based on Verilog HDL Language   This design uses Verilog HDL language to program the protocol chip. Verilog HDL language is a hardware description language. When designing digital chips, it can be described in layers and can perform timing modeling. This design uses a mixed design mode. The
[Analog Electronics]
Design of PLC backplane bus protocol interface chip based on single chip microcomputer and CPLD (Part 2)
Common causes and solutions for PLC failures during operation
PART1: Failure of peripheral circuit components This type of failure often occurs after the PLC has been working for a certain period of time. If a component failure occurs in the PLC control loop, the PLC control system will automatically stop working immediately. The input circuit is the port throu
[Embedded]
Common causes and solutions for PLC failures during operation
About the Standard Writing of Siemens PLC Program
1. Unified program structure OB1: main program; OB100: Initialization program (no need to call the main program); OB35: 100ms (modifiable) interrupt (no need to call the main program), can call the PID module; OB80, OB82, OB85, OB86, OB87, OB121, OB122: fault diagnosis module (no need to call the
[Embedded]
Modbus to Profinet gateway connects the inverter to the PLC
Project case operation: This case is about connecting the data of Danfoss inverter to Siemens 1200PLC through Netess' Modbus to Profinet gateway device. The devices used are a Siemens 1200PLC, a Modbus to Profinet gateway, and a Danfoss inverter. Modbus to Profinet gateway configuration method:
[Embedded]
Modbus to Profinet gateway connects the inverter to the PLC
PID calculation and application in DCS and PLC control systems
Now some well-known domestic and foreign brand manufacturers almost dominate the entire industrial automation control field, such as: foreign brands include Emerson and Siemens; domestic brands include: Zhejiang University Central Control, Hollysys, etc., so how is the most common PID control in these cont
[Analog Electronics]
PLC definition/classification/function/application field/basic structure/working principle
Definition of PLC A programmable controller is a digital computing electronic system designed for use in industrial environments. It uses a programmable memory to store instructions for executing logical operations, sequential control, timing, counting and arithmetic operations, and controls various types of ma
[Embedded]
PLC definition/classification/function/application field/basic structure/working principle
Briefly describe the issues that should be paid attention to in the application and use of PLC
1. Brief Introduction Over the years, the programmable controller (hereinafter referred to as PLC) has made a leap from wiring logic to storage logic since its creation; its functions have evolved from weak to strong, from logic control to digital control; its application areas have grown from small to large, f
[Industrial Control]
Latest Analog Electronics Articles
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号