PLC Programming Algorithms (1)
In PLC, there are three main types of signals: digital signals, analog signals, and pulse signals. Once you understand the relationship between these three, you can master PLC programming.
1. Digital signals, also known as logical signals, refer to signals that have only two values: 0 or 1, ON or OFF. This is the most commonly used control method, 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 combinations 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. The control principles can be decentralized, centralized, or mixed.
2. Analog signals refer to continuously varying physical quantities, such as voltage, current, pressure, speed, flow rate, etc.
PLCs have developed from relay control to microprocessor technology, making them convenient and reliable for digital signal control. Since analog signals can be converted into digital signals, and digital signals are merely multi-bit digital signals, PLCs can reliably process and control the converted analog signals.
As continuous production processes often involve analog signals, analog signal control is sometimes referred to as process control.
Analog signals are mostly non-electrical quantities, while PLCs can only handle digital quantities and electrical quantities. Therefore, to achieve conversion between them, sensors are required 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 calculations. It is essential to understand the resolution of the analog signal unit and the standard electrical signals. For example:
The resolution of the PLC analog unit is 1/32767, corresponding to a standard electrical quantity of 0–10V, with the temperature range to be detected being 0–100℃. Therefore, 0–32767 corresponds to the temperature values of 0–100℃. The digital quantity corresponding to 1℃ is calculated as 327.67. If you want to achieve a temperature precision of 0.1℃, you divide 327.67 by 10.
Analog signal control includes: feedback control, feedforward control, proportional control, fuzzy control, etc. These are all calculations of digital quantities within the PLC.
3. Pulse signals are digital quantities that continuously alternate between 0 (low level) and 1 (high level). The number of times the pulse alternates per second is called frequency.
The main purpose of PLC pulse signal 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 per revolution and needs to rotate 90 degrees, the required pulse count = 10000/(360/90) = 2500.
PLC Programming Algorithms (2)
Calculating Analog Signals
1. -10—10V. When the voltage is -10V—10V, it is converted to F448—0BB8Hex (-3000—3000) at a resolution of 6000; at a resolution of 12000, it is converted to E890—1770Hex (-6000—6000).
2. 0—10V. When the voltage is 0—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 is 0—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 is 4—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 measurement range of the physical quantities you are measuring may vary. The calculation results may have some discrepancies.
Note: Requirements for Wiring Analog Inputs
1. Use shielded twisted pair cables, but do not connect the shield layer.
2. When an input is not used, short the V IN and COM terminals.
3. Isolate the analog signal lines from 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 the correct wiring, first power on the CPU unit, then power on the load.
6. When cutting power, first disconnect the load power, then cut the CPU power.
PLC Programming Algorithms (3)
Calculating Pulse Signals
Pulse signal 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, clarify the number of subdivisions of the stepper motor, then determine the total pulse count required for one full rotation of the stepper motor. Calculate “Angle Percentage = Set Angle / 360° (i.e., one full rotation)” 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°).
2. Distance control of stepper motors. First, clarify the total pulse count required for one full rotation of the stepper motor. Then determine the diameter of the stepper motor wheel and calculate the circumference of the wheel. 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 is a combination of angle control and distance control.
The above is 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.
Reposted from the internet; please correct any errors.
Submission email: [email protected]. Accepted submissions will receive a fee!
—————–End—————-
Long press the QR code to follow the forum.
