Learn the data types that you must master in Siemens S7-200 series PLC
[Copy link]
In the process of learning PLC, the concept of data type is often mentioned. So what exactly is a data type? What is the function of a data type? What are the data types in Siemens 200 series PLC? These are the contents that you must master when learning Siemens PLC. So what exactly is a data type? What is the function of a data type? Data types are used to describe the length (i.e. the number of binary bits) and properties of data. In PLC, data types play three main roles: First, the choice of instructions. For example, for an addition operation, should the teacher use an integer addition instruction, a double integer addition instruction, or a real number addition instruction? Second, it is the addressing method of the memory. Different data types indicate different data sizes. Therefore, when selecting a memory for data storage, it is necessary to address it in different ways, such as byte addressing, word addressing, or double-word addressing. Third, it determines the display method of the data. For the same 8-bit binary number memory, you can display it in ASCAII or in decimal. Now, for the same 32-bit binary number memory, you can display it in double integer or floating point. The specific display method depends on the data type. There are many types of data. In Siemens PLC, data types are divided into basic data types, complex data types, parameter data types, system data types and hardware data types, etc. However, for S7-200 series PLC, only basic data types are supported. Here I will introduce the basic data types to you. (1) BOOL: Data type Boolean, value range is 0 or 1, indicating whether the switch is disconnected or connected. The addressing method in the program is addressed in the form of byte, such as M0.0. The corresponding instructions are contact or coil instructions. (2) Byte: Data type byte, 8-bit binary number storage, value range is 0~255, the addressing method of the storage is byte, such as VB0. The corresponding instructions used are MOV_B, WAND_B, etc. (3) WORD: data type word, 16-bit binary number storage, value range 0~65535, the addressing mode of the storage is word, such as VW10, and the corresponding instructions are MOV_W, WAND_W, etc. (4) DWORD: data type double word, 32-bit binary number storage, value range 0~4294967295, the corresponding addressing mode is double word addressing mode, such as MD0. The corresponding instructions are MOV_D, WXOR_D, ROL_D, etc. (5) INT: Data type integer, 16-bit binary number storage, value range -32768~32767, the difference from WORD is that WORD stores unsigned numbers, while INT stores signed numbers. The highest bit of the storage indicates the sign bit, 0 indicates an integer, 1 indicates a negative number, and the following 15 bits of binary numbers indicate the size of the data. The addressing method is also word-based, such as: MW0. Supported instructions include ADD_I, SUB_I, etc. (8) ASCII: data type character or ASCAII. An ASCAII requires 8 bits of binary storage, and a Chinese character requires 2 bytes of storage space. The addressing method is byte selection, such as the character 'A'. Stored in VB0, the value stored in VB0 is: (9) string: data type string. A string is composed of multiple characters. Each character takes up one byte of storage space. When storing a string, the first character indicates the number of characters in the string. For example, when storing the string "SMART" in VB10, the storage format is as follows:
|