PLC Programming Design Methods

Q

What is thought?

It is the result or the system of viewpoints and concepts formed by the reflection of objective existence in human consciousness through cognitive activities.

There are good and bad thoughts; correct thoughts can quickly achieve goals.

PLC Programming Design Methods

PLC Programming Design Methods

In short: Program = Data + Algorithm

A good program structure makes PLC programs readable, standardized, and extensible. A good algorithm can improve the efficiency of program execution.

PLC programming design methods follow these principles:

• General principle: Top-down, gradually refine.

• Top-down: First write out the overall structure of the program, gradually making the problem more specific.

• Gradual refinement: Break complex problems into many simple modules, which can be decomposed multiple times.

• Object-oriented thinking: Treat functions and devices as specific objects and write corresponding encapsulated functional blocks.

PLC Programming Design Methods

The Essence of Data

All data is binary and consists of bytes. Therefore, in the DB block, the offset address is counted in bytes.

Examples are as follows:

  • Time: Essentially a 32-bit unsigned integer, measured in milliseconds.

  • Real: 32 bits, essentially 0 and 1, but it follows the IEEE 754 format definition.

  • Char: 1 byte, stored in ASCII format.

  • Word: 16 bits, commonly referred to as “registers” in field devices.

PLC Programming Design Methods

Memory Addressing

In Siemens 1200/1500 PLCs, there are only four memory areas: I, Q, M, and DB.

Absolute addressing, taking the I area memory address as an example:

·I0.0: Represents the first bit of byte 0 of the input.

·IB0: Represents byte 0 of the input.

·IW0: Represents word 0 of the input.

·IDW0: Represents double word 0 of the input.

Taking the M area as an example, explaining data storage:

PLC Programming Design Methods

In Siemens 1200 PLC, there is a high-byte low-storage, meaning the high byte stores the low-order content.

Therefore, when transmission instructions appear garbled or erroneous, the fundamental reason is byte disorder, a big-endian and little-endian sorting issue, which needs to be adjusted through PLC programming.

Leave a Comment