Over 90,000 friends have followed this industrial control WeChat platform:Technical sharing,Learning exchange,Industrial control videos
PLC Programming Algorithms (1)
In PLC, there are three main types: digital signals, analog signals, and pulse signals. Once you understand the relationship between the three, you can master PLC programming.
1. Digital signals, also known as logic signals, refer to two values: 0 or 1, ON or OFF. This is the most common type of control, and managing it is the advantage of PLCs, as well as their most basic application.
The purpose of digital signal control is to produce 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, with control principles categorized into decentralized, centralized, and mixed control.
2. Analog signals refer to continuously varying physical quantities such as voltage, current, pressure, speed, and flow rate.
PLCs developed from relay control with the introduction of microprocessor technology, making them convenient and reliable for digital signal control. Since analog signals can be converted into digital signals, and digital signals are simply multi-bit digital signals, PLCs can reliably handle processed analog signals after conversion.
As continuous production processes often involve analog signals, analog signal control is sometimes referred to as process control.
Most analog signals are non-electrical quantities, while PLCs can only handle digital quantities and electrical quantities. Therefore, to implement conversions between them, sensors must be used to convert analog signals into digital electrical quantities. If this electrical quantity is not standard, it must go through a transmitter to convert non-standard electrical quantities into standard electrical signals, 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, converting 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, where the temperature range being measured is 0–100℃. Therefore, 0–32767 corresponds to the temperature values of 0–100℃. The digital quantity corresponding to 1℃ is 327.67. If you want to achieve a temperature precision of 0.1℃, divide 327.67 by 10.
Analog signal 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 continuously alternate between 0 (low level) and 1 (high level). The frequency is the number of times the pulse alternates per second.
The main purpose of PLC pulse signal control is for position control, motion control, trajectory control, etc. For example, the application of pulse counts in angle control. If the stepper motor driver has a subdivision of 10,000, and it requires the stepper motor to rotate 90 degrees, then the number of pulses needed = 10000/(360/90) = 2500.
PLC Programming Algorithms (2) — Calculating Analog Signals
1. -10—10V. The voltage of -10V—10V 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. The voltage of 0—10V 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. The current of 0—20mA 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. The current of 4—20mA 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 ranges of the physical quantities may vary. The calculation results may have certain discrepancies.
Note: Requirements for wiring of analog inputs
1. Use shielded twisted pair cables, but do not connect the shield layer. 2. When an input is not used, short-circuit 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, power on the CPU unit first, then power on the load.
6. When shutting down, first cut off the load power, then cut off 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 the stepper motor. First, clarify the subdivision count 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° (one full rotation)” and “Angle Action Pulse Count = Total Pulse Count for One Rotation * Angle Percentage.”
The formula is:
Angle Action Pulse Count = Total Pulse Count for One Rotation * (Set Angle/360°).
2. Distance control of the stepper motor. First, clarify the total pulse count required for one full rotation of the stepper motor. Then determine the wheel diameter of the stepper motor and calculate the wheel circumference. Calculate the distance traveled per pulse. Finally, calculate the number of pulses required for the set distance.
The formula is:
Set Distance Pulse Count = Set Distance/[(Wheel Diameter * 3.14)/Total Pulse Count for One Rotation].
3. Position control of the stepper motor combines angle control and distance control.
The above is a simple analysis of the control methods for stepper motors, which may differ from reality and are for reference only.
The actions of servo motors are similar to those of stepper motors, but the internal electronic gear ratio and reduction ratio of the servo motor must be considered. Source: Provided by