Comprehensive PLC Programming Algorithms for Engineers

PLC Programming Algorithm (1): Digital Signals

In PLC, there are three main types: digital signals, analog signals, and pulse signals. Understanding the relationship between these three will allow you to master PLCs proficiently.

1. Digital Signals are also known as logical signals, referring to two values: 0 or 1, ON or OFF. This is the most commonly used control type, and controlling it is the advantage of PLCs, as well as their most basic application.

The purpose of digital signal control is to generate corresponding digital signal outputs based on the current input combination of digital signals and historical input sequences, allowing the system to operate in a specific order. Therefore, it is sometimes referred to as sequential control.

Sequential control can be manual, semi-automatic, or automatic, and the control principles can be distributed, centralized, or hybrid.

Comprehensive PLC Programming Algorithms for Engineers

2. Analog Signals refer to some continuously changing physical quantities, such as voltage, current, pressure, speed, flow rate, etc.

PLCs were developed from relay control technologies introduced with microprocessor technology, allowing for convenient and reliable control using digital signals. Since analog signals can be converted into digital signals, and digital signals are simply multi-bit digital signals, PLCs can also reliably handle and control the converted analog signals.

As continuous production processes often involve analog signals, analog signal control is sometimes referred to as process control.

If the key points are not standard, they must be converted into standard electrical signals, such as 4-20mA, 1-5V, 0-10V, etc.

There must also be an analog input unit (A/D) to convert these standard electrical signals into digital signals; and an analog output unit (D/A) to convert the processed digital signals back into analog standard electrical signals.

Therefore, the conversion between standard electrical signals and digital signals requires various calculations. It is essential to understand the resolution of the analog signal unit and the standard electrical signals.

For example:

If the resolution of the PLC analog unit is 1/32767, corresponding to a standard electrical signal of 0-10V, and the temperature value to be detected is 0-100℃. Then, 0-32767 corresponds to the temperature value of 0-100℃. Consequently, the digital value corresponding to 1℃ is 327.67. If you want to achieve an accuracy of 0.1℃, you can divide 327.67 by 10.

These are all calculations of internal digital signals in PLCs. Analog signal control includes feedback control, feedforward control, proportional control, fuzzy control, etc.

3. Pulse Signals are digital signals that continuously alternate between 0 (low) and 1 (high peak). The number of times the pulses alternate per second is referred to as frequency.

The primary purpose of PLC pulse signal control is position control, motion control, trajectory control, etc. For example, the application of pulse count in angle control. The separation of stepper motor drivers is 10000 per revolution; if the stepper motor is required to rotate 90 degrees, the pulse count required = 10000 / (360/90) = 2500.

PLC Programming Algorithm (2) – Calculating Analog Signals

1. -10—10V; when the voltage is -10V—10V, at a resolution of 6000, it is converted to F448—0BB8Hex (-3000—3000); at a resolution of 12000, it is converted to E890—1770Hex (-6000—6000).

2. 0—10V; when the voltage is 0—10V, at a resolution of 12000, it is converted to 0—1770Hex (0—6000); at a resolution of 12000, it is converted to 0—2EE0Hex (0—12000).

3. 0—20mA; when the current is 0—20mA, at a resolution of 6000, it is converted to 0—1770Hex (0—6000); at a resolution of 12000, it is converted to 0—2EE0Hex (0—12000).

4. 4—20mA; when the current is 4—20mA, at a resolution of 6000, it is converted to 0—1770Hex (0—6000); at a resolution of 12000, it is converted to 0—2EE0Hex (0—12000).

The above is just a simple introduction; different PLCs have different resolutions, and the sizes of the physical quantities you measure may vary. Calculation results may differ accordingly.

Note: Requirements for Wiring Analog Inputs

1. Use shielded twisted pairs, but do not connect the shield layer.

2. When an input is not in use, short-circuit the V IN and COM terminals.

3. Isolate the analog signal lines from the power lines (AC power lines, high voltage lines, etc.).

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

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

6. When cutting power, first cut the load power, then cut the CPU power.

PLC Programming Algorithm (3) – Calculating Pulse Signals

Pulse signal control is often used for stepper motors and servo motors in angle control, distance control, position control, etc. The following uses a stepper motor as an example to illustrate various control methods.

1. Angle Control of Stepper Motors. First, clarify the subdivision count of the stepper motor, then determine the total pulse count required for the motor to complete one revolution. Calculate “Angle Percentage = Set Angle / 360° (i.e., one revolution)” and “Angle Action Pulse Count = Total Pulse Count per Revolution * Angle Percentage.”

The formula is: Angle Action Pulse Count = Total Pulse Count per Revolution * (Set Angle / 360°).

Comprehensive PLC Programming Algorithms for Engineers

2. Distance Control of Stepper Motors. First, extend the total pulse count required for the stepper motor to complete one revolution. Then determine the diameter of the stepper motor wheel to calculate the wheel’s circumference. Calculate the distance traveled per pulse. Finally, calculate the pulse count required for the set distance.

The formula is: Set Distance Pulse Count = Set Distance / [(Wheel Diameter * 3.14) / Total Pulse Count per Revolution].

3. Position Control of Stepper Motors combines angle control and distance control.

The above is just a simple analysis of stepper motor control methods, which may differ from actual practices and serve as a reference for colleagues.

The operation of servo motors is similar to that of stepper motors, but consideration must be given to the internal electronic gear ratio and the reduction ratio of the servo motor.

(Source: Jicheng Training)

『This article is copyrighted by the original author. If there is any infringement, please contact for deletion.』

Editor: Hu Ying
Proofreader: Duan Shaomin
Reviewer: Li Guoqing

Comprehensive PLC Programming Algorithms for Engineers

Comprehensive PLC Programming Algorithms for Engineers

Comprehensive PLC Programming Algorithms for Engineers

Leave a Comment