Comprehensive PLC Programming Algorithms for Reference

Comprehensive PLC Programming Algorithms for Reference

Comprehensive PLC Programming Algorithms

Comprehensive PLC Programming Algorithms for Reference

PLC Programming Algorithm (1):

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

1. Digital signals, also known as logic signals, refer to values that can only be 0 or 1, ON or OFF. This is the most common control method, and controlling it is an advantage of PLCs, representing the most basic application of PLCs.

The purpose of digital signal control is to produce corresponding digital signal outputs based on the current input combinations and historical input sequences, enabling the system to work in a specific sequence. Therefore, it is sometimes referred to as sequential control.

Sequential control can be manual, semi-automatic, or automatic, and the control principles can be decentralized, centralized, or mixed.

2. Analog signals refer to continuously changing physical quantities, such as voltage, current, pressure, speed, and flow.

PLCs developed from relay control with the introduction of microprocessing technology, allowing for convenient and reliable digital signal control. Since analog signals can be converted into digital signals, and digital signals are simply multi-bit digital signals, PLCs can reliably process and control converted analog signals.

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

Analog signals are mostly non-electrical quantities, while PLCs can only handle digital signals and electrical quantities. Therefore, to achieve conversion between them, sensors are needed to convert analog signals into digital electrical quantities. If the electrical quantity is not standard, it must go through a transmitter to convert the non-standard electrical quantity into a standard electrical signal, such as 4–20mA, 1–5V, 0–10V, etc.

Additionally, there must 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 quantities back into analog signals—standard electrical signals.

Thus, the conversion between standard electrical signals and digital quantities requires various operations. This necessitates an understanding of the resolution of the analog unit and the standards for electrical signals.

For example:

If the resolution of the PLC analog unit is 1/32767 and the corresponding standard electrical quantity is 0–10V, the temperature range to be detected is 0–100℃. Then, 0–32767 corresponds to the temperature values of 0–100℃. Consequently, the digital quantity corresponding to 1℃ is 327.67. If you want to achieve a temperature accuracy of 0.1℃, simply divide 327.67 by 10.

Analog control includes feedback control, feedforward control, proportional control, fuzzy control, etc. These are all computational processes of digital quantities within the PLC.

3. Pulse signals are digital quantities that constantly alternate between 0 (low level) and 1 (high level). The number of times pulses alternate per second is called frequency.

The primary purpose of PLC pulse control is position control, motion control, trajectory control, etc. For example, the application of pulse counts in angle control. If a stepper motor driver has a subdivision of 10000, and it is required to rotate the stepper motor 90 degrees, then the required pulse count = 10000/(360/90) = 2500.

PLC Programming Algorithm (2) — Calculating Analog Signals

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

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

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

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

The above is a simple introduction; different PLCs have different resolutions, and the measured physical quantities may have different ranges. Therefore, the calculation results may vary.

Note: Requirements for Analog Input Wiring

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

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

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

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

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

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

PLC Programming Algorithm (3) — Calculating Pulse Signals

Pulse control is often used for angle control, distance control, and position control of stepper motors and servo motors. The following explains each control method using stepper motors as an example.

1. Angle control of stepper motors. First, determine the subdivision of the stepper motor, then determine the total pulse count needed for the stepper motor to make one full rotation. Calculate the “angle percentage = set angle / 360° (one full rotation)” and “angle action pulse count = total pulse count per rotation * angle percentage.”

The formula is:Angle action pulse count = total pulse count per rotation * (set angle / 360°).

2. Distance control of stepper motors. First, determine the total pulse count needed for the stepper motor to make one full rotation. Then determine the diameter of the stepper motor’s wheel and calculate the circumference of the wheel. Calculate the distance traveled per pulse. Finally, calculate the pulse count needed to travel the set distance.

The formula is:Set distance pulse count = set distance / [(wheel diameter * 3.14) / total pulse count per rotation].

3. Position control of stepper motors is a combination of angle control and distance control.

The above is just a simple analysis of the control methods for stepper motors, which may differ from actual practice and is for reference only.

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

Source: Internet, copyright belongs to the original author

Previous Recommendations

1. Latest Complete Electrical Engineering Question Bank (National Version) 2020

2. Electrical Experts’ Private Tool Kit (Electrical Simulation Software + 16 Sets of Electrical Industry PPTs)

3. Master Says: If You Don’t Know CAD, Don’t Expect to Be an Electrical Engineer (Includes CAD Software Package)

Comprehensive PLC Programming Algorithms for Reference

Comprehensive PLC Programming Algorithms for ReferenceLike it? Click hereComprehensive PLC Programming Algorithms for ReferenceLearn PLC and Electrical Courses for Free, click to read the original text

Leave a Comment