Explanation of three algorithms for PLC programming

Publisher:BlissfulDreamsLatest update time:2024-08-21 Source: elecfansKeywords:PLC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

PLC programming algorithm (1)

There are only three quantities in PLC: switch quantity, analog quantity and pulse quantity. As long as you understand the relationship between the three, you can master PLC skillfully.


1. Switch quantity is also called logic quantity, which means that there are only two values, 0 or 1, ON or OFF (switch quantity has only two states 0/1. It includes input quantity and output quantity, which reflects the state). It is the most commonly used control. Controlling it is the advantage of PLC and also the most basic application of PLC.


pYYBAGSb-FyAMGSFAAZWJzJqkGY976.png

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

Sequential control is divided into manual, semi-automatic or automatic. The control principles adopted are decentralized, centralized and mixed control.

2. Analog quantity refers to some continuously changing physical quantities (digital quantity is discontinuous. It reflects the measurement value of electrical quantity), such as voltage, current, pressure, speed, flow, etc.


poYBAGSb-FyAOW7KAAU-gvNpq0k978.png

PLC is developed from the introduction of microprocessing technology into relay control, and can be used conveniently and reliably for switch quantity control. Since analog quantity can be converted into digital quantity, and digital quantity is just a multi-bit switch quantity, PLC can also reliably process and control the converted analog quantity.

Since continuous production processes often involve analog quantities, analog quantity control is sometimes also called process control.

Analog quantities are mostly non-electrical quantities, while PLC can only process digital quantities and electrical quantities. To achieve the conversion between them, sensors are required to convert analog quantities into digital quantities.

If the amount of electricity is not standard, it must pass through a transmitter to convert the non-standard amount of electricity into a standard electrical signal, such as 4-20mA, 1-5V, 0-10V, etc.

At the same time, there must be an analog input unit (A/D) to convert these standard electrical signals into digital signals. An analog output unit (D/A) is used to convert the digital quantity processed by the PLC into analog quantity - a standard electrical signal.

Therefore, the conversion between standard electrical signals and digital quantities requires various operations, which requires understanding the resolution of the analog unit and the standard electrical signal.

For example:

The resolution of the PLC simulation unit is 1/32767. The corresponding standard power is 0-10V, and the temperature to be detected is 0-100℃. Then 0-32767 corresponds to the temperature value of 0-100℃. Then the digital value corresponding to 1℃ is calculated to be 327.67. If you want to get the temperature value accurate to 0.1℃, just divide 327.67/10.

Analog control includes: feedback control, feedforward control, proportional control, fuzzy control, etc. These are all calculation processes of digital quantities inside PLC.

3. Pulse quantity is a digital quantity whose value is always alternating between 0 (low level) and 1 (high level) (a signal quantity in which voltage or current jumps from one value to another in an instant). The number of pulse alternations per second is called frequency.


poYBAGSb-GGABvyIAADm7gknP5s309.png

The purpose of PLC pulse quantity control is mainly position control, motion control, trajectory control, etc. For example: the application of pulse number in angle control. The subdivision of stepper motor driver is 10000 per circle. The stepper motor is required to rotate 90 degrees.

Then the pulse value required for the action = 10000/(360/90) = 2500

PLC programming algorithm (2) - calculation of analog quantity

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

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

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

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

The above is just a brief introduction. Different PLCs have different resolutions, and the ranges of the physical quantities you measure are different. The calculation results may be somewhat different.

Note: Analog input wiring requirements

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

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

3. The analog signal lines are isolated 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 part and the power unit.

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

6. When powering off, first cut off the power to the load, and then cut off the power to the CPU.

PLC programming algorithm (3) - calculation of pulse quantity

The control of pulse quantity is mostly used for angle control, distance control, position control, etc. of stepper motors and servo motors. The following is an example of stepper motors to illustrate various control methods.

1. Angle control of stepper motor. First, we need to determine the number of subdivisions of the stepper motor, and then determine the total number of pulses required for the stepper motor to make one revolution.

Calculate "angle percentage = set angle / 360° (i.e. one circle)"

"Number of pulses for angle action = total number of pulses in one circle * angle percentage"

The formula is:

Angle action pulse number = total pulse number in one circle * (set angle/360°)

2. Distance control of stepper motor. First, determine the total number of pulses required for the stepper motor to rotate one circle. Then determine the diameter of the stepper motor roller and calculate the circumference of the roller. Calculate the running distance of each pulse. Finally, calculate the number of pulses required to run the set distance.

The formula is:

Set distance pulse number = set distance / [(roller diameter * 3.14) / total pulse number in one circle]

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

The above is just a simple analysis of the control method of the stepper motor, which may differ from the actual situation and is only for reference by colleagues.

The action of a servo motor is the same as that of a stepper motor, but the internal electronic gear ratio of the servo motor and the reduction ratio of the servo motor must be considered.


Keywords:PLC Reference address:Explanation of three algorithms for PLC programming

Previous article:Learn PWM in a blink
Next article:Simulation of permanent magnet synchronous motor speed control system based on Simulink

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号