PLC programming algorithm (1): switch value
There are nothing more than three large quantities in PLC: switching quantity, analog quantity, and pulse quantity. Once you understand the relationship between the three, you will be able to master PLC proficiently.
1. Switching quantity is also called logical quantity, which refers to two values, 0 or 1, ON or OFF. It is the most commonly used control , and controlling it is the advantage of PLC and the most basic application of PLC.The purpose of switch control is to make the PLC generate corresponding switch outputs based on the current input combination of switches and the historical input sequence, so that the system can work in a certain sequence. Therefore, it is sometimes called sequential control.
Sequential control is divided into manual, semi-automatic or automatic. The control principles adopted include decentralized, centralized and hybrid control methods.
2. Analog quantities refer to some continuously changing physical quantities, such as voltage , current , pressure , speed, flow , etc.
PLC was developed after the introduction of microprocessing technology from relay control. It can conveniently and reliably utilize switching control. Since the analog quantity can be converted into a digital quantity, and the digital quantity is only a multi-bit switching quantity, the converted analog quantity can also be processed and controlled reliably by the PLC.
Since continuous production processes often contain analog quantities, analog quantity control is sometimes also called process control.
If the point is not standard, it must be processed to turn the non-standard volume into a standard electrical signal, such as 4-20mA, 1-5V, 0-10V, etc.
At the same time, there must be an analog input unit (A/D) to convert these standard electrical signals into digital signals; an analog output unit (D/A) to convert the digital quantities processed by the PLC into analog quantities – standard electric signal.
At the same time, there must be an analog input unit (A/D) to convert these standard electrical signals into digital signals; an analog output unit (D/A) to convert the digital quantities processed by the PLC into analog quantities – standard electric signal.
Therefore, the conversion between standard electrical signals and digital quantities requires various operations. This requires understanding the resolution of the analog unit and the standard electrical signals.
For example:
The resolution of the PLC simulation unit is 1/32767, the corresponding standard power is 0-10V, and what is to be detected is the temperature value 0-100°C. Then 0-32767 corresponds to the temperature value of 0-100℃. Then it is calculated that the digital quantity corresponding to 1℃ is 327.67. If you want the temperature value to be accurate to 0.1°C, just change 327.67/10.
These are the calculation processes of digital quantities inside the PLC. Analog control includes: feedback control, feedforward control, proportional control, fuzzy control, etc.
3. The pulse quantity is a digital quantity whose value always alternates between 0 (continuous) and 1 (high peak value). The number of pulse alternations per second is called frequency.
The control purpose of PLC pulse volume is mainly position control, motion control, trajectory control, etc. For example: the application of pulse number in angle control. The separation of the stepper motor driver is 10,000 per revolution, requiring the stepper motor to rotate 90 degrees. Then the pulse value to be acted upon = 10000 / (360/90) = 2500.
PLC programming algorithm (2)-calculation of analog quantities
1. -10-10V; -10V-10V voltage is converted to F448-0BB8Hex (-3000-3000) at 6000 resolution; it is converted to E890-1770Hex (-6000-6000) at 12000 resolution.
2. 0-10V; 0-10V voltage is converted to 0-1770Hex (0-6000) at 12000 resolution; 0-2EE0Hex (0-12000) is converted at 12000 resolution.
3. 0-20mA; 0-20mA current is converted to 0-1770Hex (0-6000) at 6000 resolution; 0-2EE0Hex (0-12000) at 12000 resolution.
4. 4-20mA; 4-20mA current is converted to 0-1770Hex (0-6000) at 6000 resolution; 0-2EE0Hex (0-12000) at 12000 resolution.
The above is only a brief introduction. Different PLCs have different resolutions, and the dimensions of the physical quantities you measure are different. Calculation results may vary.
Note: Analog input wiring requirements
1. Use shielded twisted pair cable, but do not connect the shielding layer.
2. When an input is not in use, short-circuit the V IN and COM terminals .
3. Isolate analog signal lines from power lines (AC power lines, high-voltage lines , etc.).
4. When there is interference on the power line, install a wave filter between the input part and the power supply unit.
5. After confirming the correct wiring, first power on the CPU unit, and then power on the load .
6. When powering off, first cut off the power supply to the load, and then cut off the power supply to the CPU.
PLC programming algorithm (3)-calculation of pulse volume
Pulse control is mostly used for angle control, distance control, position control, etc. of stepper motors and servo motors. The following uses a stepper motor as an example to illustrate each control method.
1. Angle control of stepper motor. First, we need to clarify the subdivision number of the stepper motor, and then determine the total number of pulses required for the stepper motor to make one revolution. Calculate “Angle percentage = set angle / 360° (i.e. one circle)” “Angle action pulse number = total number of pulses in one circle * angle percentage.”
The formula is: number of angle action pulses = total number of pulses in one circle * (set angle/360°).
2. Step by step motor distance control. First extend the total number of pulses required for the stepper motor to make one revolution. Then determine the diameter of the stepper motor roller and calculate the circumference of the roller. Calculate the distance traveled by each pulse. Finally, calculate the number of pulses to run for the set distance.
The formula is: set distance pulse number = set distance / [(roller diameter * 3.14) / total number of pulses in one circle]
3. The position control of the stepper motor is a combination of angle control and distance control.
The above is just a simple analysis of the control method of stepper motors, which may be different from the actual situation and should be used as a reference for colleagues.
The action of the servo motor is the same as that of the stepper motor, but the internal electronic gear ratio of the servo motor and the reduction ratio of the servo motor must be considered.