PLC Programming Recommendations from an Expert

Programming Recommendations

1. When a PLC and a host computer (or touch screen) form a monitoring system, it is often necessary to have control modes such as “Manual” and “Automatic” on the screen (generally, only one can be active at a time). In the program, you can use the “MOV” instruction. For example: when “Manual” is selected, move the constant 1 into a register VB10, and when “Automatic” is selected, move 2 into the same register VB10. By checking the value in the register, you can determine the control mode of the system. The advantage of this approach is that it is easy to understand and does not require complicated interlocking programs.

2. When the program involves analog control, if the read analog value has minimal error, a time filtering method can be used to delay for a period. If the read data has significant errors, other filtering methods should be employed, such as averaging. Relevant materials can be consulted.

3. During program debugging (especially when modifying equipment, and your program is added to the original equipment’s program), if a condition is met in the program statement but the output coil does not activate, check whether your program is between such statements, like JUMP or go to statements. Another possibility is that after an interrupt, the condition is met but the output does not activate; this is generally because this part of the program is not being scanned.

4. In sequential control programs, where one action is completed before moving to the next, I find it convenient to use a +10+10 control mode. The idea is to preset a register, initialized to 0. When the system starts, add 10 to it, making the register 10; when the register equals 10, the first action can be performed. After completing the first action, add another 10, making the register 20, allowing the second action to be performed. After the second action, add another 10, making the register 30. By checking the value in the register, you can determine which action to complete. When a jump action is needed, you can add +20, +30, etc., depending on the actual requirements.

Why add 10 instead of 1? Because after adding 10, if an insertion is needed, you can choose any position within those 10 available spaces.

5. When designing the program, if a process fault occurs (not controlled by the control system), it is best to maintain the fault phenomenon and have visual and audible alarms until the operator resets it, so they are aware of the system fault. Otherwise, if the machine stops, others may think there is a problem with your program. This is generally something to consider when designing a new system.

6. For frequently called subroutines, they can be made into sub-modules for frequent invocation.

7. Since the various steps of machinery in a working cycle require a certain amount of time to execute, and these times have certain limits, these times can be used as a reference. At the start of the step action to be monitored, start a timer, setting the timer’s value to be 20% to 30% longer than the normal duration of that action. The timer’s output signal can be used for alarms or automatic shutdown devices. If the time taken for a step action exceeds the specified time and has not transitioned to the next step action, the timer will issue a fault signal, stopping the normal working cycle program and starting the alarm or shutdown program. This is what we commonly refer to as over-cycle protection.

PLC Programming Recommendations from an Expert

8. Some safety detection switches (such as emergency stop buttons, safety light curtains, limit switches, etc.) typically use normally closed (NC) inputs.

9. For safety and energy-saving considerations, try to design outputs to activate only when needed, stopping output once in position, rather than designing them to output continuously and only stopping when required.

10. The principle of action for executing elements should be to prefer not to move rather than to move erratically!

11. For single device control: a single device must have a soft manual/automatic switch and the ability to start/stop during manual operation. When switching from automatic to manual, the device must not stop; when switching from manual to automatic, the device’s start/stop depends on the automatic program.

12. A single device (pump, fan, and other large equipment) must rotate after running for 24 hours, and there must be a cumulative running time, except when the start/stop sequence is set by the host computer, in which case the operator can set it themselves.

Leave a Comment