About the use of data types in Siemens PLC

1 In PLC programming, variables must be established first, and the data type of variables must be established to establish variables, but before that, understand the difference between lower bits, bytes, words, double words, etc.

Bit: bit, the smallest unit of information stored in a computer, it refers to a binary bit

     Byte: byte, the relationship between it and bits is that 1 byte is equal to 8 bits, and 1 byte = 8 bit

Word: word, 1 word is equal to 2 bytes, that is, 1 word = 2 byte = 16 bit

   So in PLC, you will see these, VB, VW, VD, they refer to 8-bit, 16-bit, and 32-bit respectively.

2 But in PLC programming, when to use words, when to use bytes, and when to use double words?

This depends on the size of the value you store, generally speaking:

1 byte can store 2 to the 8th power, that is, 0~255, one 256

        1 word can store 2 to the 16th power, which is 65536, or -32768-32767

As for double words, 2 to the 32nd power, they are all hundreds of millions.

Therefore, when you calculate the number of pulses, you generally choose double words, 32 bits, and others depend on the situation. You need to store more

Guess you like

Origin blog.csdn.net/yue008/article/details/55222707