PLC's most complete programming algorithm: calculation of analog quantity and calculation of pulse quantity

PLC programming algorithm (1)

1, Switch quantity is also called logic quantity, it means there are only two values, 0 or 1, ON or OFF. It is the most commonly used control. Controlling it is the advantage of PLC and it is also the most basic application of PLC.

The purpose of the switch control is to make the PLC generate the corresponding switch output according to the current input combination of the switch quantity and the history input sequence, so that the system can work in a certain order. Therefore, it is sometimes called sequential control.

The sequence control is divided into manual, semi-automatic or automatic. The control principles used are decentralized, centralized and hybrid control.

2. Analog quantity refers to some continuously changing physical quantities such as voltage, current, pressure, speed, and flow.

PLC was developed after the introduction of microprocessor technology into relay control, and it can be conveniently and reliably used for switching control. Because the analog quantity can be converted into digital quantity, the digital quantity is only the switching quantity of many digits, so after the analog quantity after conversion, PLC can also carry on processing control reliably.

Analogous control is sometimes referred to as process control because continuous production processes often have analog quantities.

Most of the analog quantity is non-electricity, while the PLC can only handle digital quantity and quantity of electricity. All of the conversions between them need to have sensors to convert the analog to digital power. If this power is not standard, but also through the transmitter, the non-standard power into standard electrical signals, such as 4-20mA, 1-5V, 0-10V and so on.

At the same time, there must also be analog input units (A/D) to convert these standard electrical signals into digital signals; analog output units (D/A) to convert PLC-processed digital quantities to analog quantities - standard The electrical signal.

Therefore, the conversion between standard electrical signals and digital quantities requires various operations. This requires a clear understanding of the resolution of the analog unit and the standard electrical signals. E.g:

The resolution of the PLC simulation unit is 1/32767, and the corresponding standard power is 0-10V. The temperature value to be detected is 0-100°C. Then 0-32767 corresponds to 0-100 °C temperature. Then calculate the corresponding digital quantity of 1 °C is 327.67. If you want to make the temperature value accurate to 0.1°C, put 327.67/10.

Analog control includes: feedback control, feedforward control, proportional control, fuzzy control and so on. These are the calculation of the internal digital quantity in the PLC.

3. The pulse quantity is a digital quantity whose value always alternates between 0 (low level) and 1 (high level). The number of alternating pulses per second is called the frequency.

The purpose of controlling the amount of PLC pulse is mainly position control, motion control, trajectory control, and the like. For example: Application of pulse number in angle control. The subdivision of the stepper motor driver is 10,000 per turn, requiring the stepper motor to rotate 90 degrees. Then the pulse number to be acted = 10000/(360/90) = 2500.

PLC Programming Algorithm (II)——Calculation of Analog

1, -10 - 10V. -10V-10V is converted to F448- 0BB8Hex (-3000-3000) at 6000 resolution, and to E890-1770Hex (-6000-6000) at 12,000 resolution.

2, 0-10V. The 0-10V voltage is converted to 0-1770 Hex (0-6000) at 12000 resolution and 0-2EE0Hex (0-12000) at 12000 resolution.

3, 0-20mA. 0 - 20mA current is converted to 0 - 1770 Hex (0 - 6000) at 6000 resolution, and 0 - 2EE0Hex (0 - 12000) at 12,000 resolution.

4, 4-20mA. The 4-20mA current is converted to 0-1770 Hex (0-6000) at 6000 resolution and 0-2EE0Hex (0-12000) at 12,000 resolution.

The above is only a brief introduction, different PLCs have different resolutions, and the physical range you measure is not the same. There may be some differences in the calculation results.

Note: Requirements for the wiring of analog inputs

1. Use shielded twisted pair but no shield. 2. When an input is not used, short the V IN and COM terminals.

3. The analog signal line is isolated from the power line (AC power line, high voltage line, etc.).

4. When there is interference on the power line, install a filter between the input section and the power supply unit.

5. After confirming the correct wiring, first power on the CPU unit and then power the load.

6, cut off the power of the load first, and then cut off the power of the CPU.

PLC Programming Algorithm (3) - Calculation of Pulse Amount

The control of pulse quantity is mostly used for angle control, distance control, and position control of stepping motors and servo motors. The following is a stepper motor as an example to illustrate each control method. (Machinery Industry Press E-vision, ID: cmp_dgdz1)

1. Stepping motor angle control. First, the number of subdivisions of the stepper motor should be clearly defined, and then the total number of pulses required for the stepper motor to make one revolution should be determined. Calculate "Angle percentage = set angle / 360° (ie, one revolution)" "Angle action pulse number = Total number of pulses per revolution * Angle percentage."

The formula is: the number of angular action pulses = the total number of pulses in a circle* (setting angle/360°).

2, stepping motor distance control. First, the total number of pulses required for a stepper motor to make a revolution is determined. Then determine the stepper motor roller diameter, calculate the roller circumference. Calculate the distance traveled for each pulse. Finally, the number of pulses to be run at the set distance is calculated.

The formula is: set distance pulse number = set distance / [(roller diameter * 3.14) / total number of pulses in one circle]

3, stepper motor position control is a combination of angle control and distance control.

The above is only a simple analysis of the control method of the stepper motor, and may differ from the actual ones, and is only for your colleagues' reference.

The operation of the servo motor is the same as that of the stepping motor, but consider the internal electronic gear ratio of the servo motor and the reduction ratio of the servo motor.

Manual Sensor

Multi function remote manual pulse generator for control of all axes.

Manual Sensor,Miniature Optical Kit Encoder,Rotary Encoder With Led Ring,Optical Quadrature Encoder

Yuheng Optics Co., Ltd.(Changchun) , https://www.yhenoptics.com