5.1 Basic Data Type
5.1.1 Bit
Bool--BOOL
- Bit: "Bit" is the basis of computer operations
| Format | Value range | Input value example |
|---|---|---|
| Boolean | FALSE or TRUE BOOL#0 or BOOL#1 BOOL#FALSE or BOOL#TRUE | TRUE BOOL#1 BOOL#TRUE |
| Unsigned integer (decimal) | 0 or 1 | 1 |
| Binary | 2#0 or 2#1 | 2#0 |
| Hexadecimal | 16#0 or 16#1 | 16#1 |
warning
- The length of our BOOL type variable is 8bit or 1byte;
- Logically BOOL length is 1bit, while in software storage BOOL length is 1byte;
- Values include TRUE and FALSE, and the default value of BOOL type variables is FALSE
5.1.2 Bit string
Byte--BYTE
- Byte: "Byte" is the unit of transmitting information through the network (or storing information on the hard disk or memory)
| Format | Value range | Input value example |
|---|---|---|
| Integer | Signed integer: -128 to +127 Unsigned integer: 0 to 255 | 15 BYTE#15 |
| Binary | 2#0 to 2#1111_1111 | 2#0000_1111 BYTE#2#0000_1111 |
| Hexadecimal | 16#0 to 16#FF | 16#0F BYTE#16#0F |
warning
- The length is 8 bits. Byte type variables cannot exceed the value range, otherwise it will cause overflow.
Word--WORD
| Format | Value range | Input value example |
|---|---|---|
| Integer | 0 to 65535 | 666 WORD#666 |
| Binary | 2#0 to 2#1111_1111_1111_1111 | 2#1111_0000_1111_0000 WORD#2#1111_0000_1111_0000 |
| Hexadecimal | 16#0 to 16#FFFF | 16#F0F0 WORD#16#F0F0 |
Double word--DWORD
| Format | Value range | Input value example |
|---|---|---|
| Integer | 0 to 4294967295 | 156 DWORD#156 |
| Binary | 2#0 to 2#1111_1111_1111_1111_1111_1111_1111_1111 | 2#0000_1111_0000_11 11_0000_1111_0000_1111 DWORD#2#0000_0000_1111_0000_1111_1111_0000_1111 |
| Hexadecimal | 16#0000_0000 to 16#FFFF_FFFF | 16#00F0_FF0F DWORD#16#00F0_FF0F |
Long word--LWORD
| Format | Value range | Input value example |
|---|---|---|
| Integer | Signed integer: -9_223_372_036_854_775_808 to +9_223_372_036_854_775_807 Unsigned integer: 0 to 18_446_744_073_709_551_615 | 26_123_590_360_715 LWORD#+26_123_590_360_715 |
| Binary | 2#0 to 2#1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 | 2#0000_0000_0000_0000_0000_1011_1110_0001_0010_1111_0101_0010_1101_1110_1000_1011 LWORD#2#0000_0000_0000_0000_0000_1011_1110_0001_0010_1111_0101_0010_1101_1110_1000_1011 |
| Hexadecimal | 16#0000_0000 to 16#FFFF_FFFF_FFFF_FFFF | 16#0000_0000_5F52_DE8B LWORD#16#0000_0000_5F52_DE8B |
5.1.3 Integer
Short integer type--SINT
| Format | Value range | Input value example |
|---|---|---|
| Signed integer | -128 to 127 | 66 SINT#44 |
| Binary | 2#0 to 2#0111_1111 | 2#0010_1100 SINT#2#0010_1100 |
| Hexadecimal | 16#0 to 16#7F | 16#2C SINT#16#2C |
Unsigned short integer type--USINT
| Format | Value range | Input value example |
|---|---|---|
| Unsigned integer | 0 to 255 | 77 |
| Binary | 2#0 to 2#1111_1111 | 2#0100_1110 |
| Hexadecimal | 16#0 to 16#FF | 16#4E USINT#16#4E |
Integer type--INT
| Format | Value range | Input value example |
|---|---|---|
| Signed integer | -32768 to 32767 | 333 INT#333 |
| Binary | 2#0 to 2#0111_1111_1111_1111 | 2#0000_1110_1100_1001 INT#2#0000_1110_1100_1001 |
| Hexadecimal | 16#0 to 16#7FFF | • 16#0EC9 INT#16#0EC9 |
Unsigned integer type--UINT
| Format | Value range | Input value example |
|---|---|---|
| Unsigned integer | 0 to 65535 | 295 UINT#295 |
| Binary | 2#0 to 2#1111_1111_1111_1111 | 2#1111_1111_0000_1111 UINT#2#1111_1111_0000_1111 |
| Hexadecimal | 16#0 to 16#FFFF | 16#FF0F UINT#16#FF0F |
Double integer type--DINT
| Format | Value range | Input value example |
|---|---|---|
| Signed integer | -2_147_483_648 to +2_147_483_647 | 125790 DINT#125 |
| Binary | 2#0 to 2#0111_1111_1111_1111_1111_1111_1111_1111 | 2#0000_0000_0000_0001_1110_1011_0101_1110 DINT#2#0000_0000_0000_0001_1110_1011_0101_1110 |
| Hexadecimal | 16#0 to 16#7FFF_FFFF | 16#0001_EB5E DINT#16#0001_EB5E |
Unsigned double integer type--UDINT
| Format | Value range | Input value example |
|---|---|---|
| Unsigned integer | 0 to 4_294_967_295 | 4_042_322_160 UDINT#4_042_322_160 |
| Binary | 2#0 To 2#1111_1111_1111_1111_1111_1111_1111_1111 | 2#1111_0000_1111_0000_1 111_0000_1111_0000 UDINT#2#1111_0000_1111_0000_1111_0000_1111_0000 |
| Hexadecimal | 16#0 to 16#FFFF_FFFF | 16#F0F0_F0F0 UDINT#16#F0F0_F0F0 |
Long integer type--LINT
| Format | Value range | Input value example |
|---|---|---|
| signed integer | -9_223_372_036_854_775_808 to +9_223_372_036_854_775_807 | 154 LINT#+154_325_790_816_159 |
| Binary | 2#0 to 2#0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111 | 2#0000_0000_0000_0000_1000_1100_0101_1011_1100_0101_1111_0000_1111_0111_1001_1111 LINT#2#0000_0000_0000_0000_1000_1100_0101_1011_1100_0101_1111_0000_1111_0111_1001_1111 |
| Hexadecimal | 16#0 to 16#7FFF_FFFF_FFFF_FFFF | 16#0000_8C5B_C5F0_F79F LINT#16#0000_8C5B_C5F0_F79F |
Unsigned long integer type--ULINT
| Format | Value range | Input value example |
|---|---|---|
| Unsigned integer | 0 to 18_446_744_073_709_551_615 | 154 ULINT#154_325_790_816_159 |
| Binary | 2#0 To 2#1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_11 11_1111_1111_1111_1111 | 2#0000_0000_0000_0000_1000_1100_0101_1011_1 100_0101_1111_0000_1111_0111_1001_1111 ULINT#2#0000_0000_0000 _0000_1000_1100_0101_1011_1100_0101_1111_0000_1111_0111_1001_1111 |
| Hexadecimal | 16#0 to 16#FFFF_FFFF_FFFF_FFFF | 16#0000_8C5B_C5F0_F79F ULINT#16#0000_8C5B_C5F0_F79F |
5.1.4 Real number
Real number--REAL
| Format | Value range | Input value example |
|---|---|---|
| Comply with IEEE754 standard | ±0.0 ±1.175495e-38 to ±3.402823e+38 | 1.0e-5;REAL#1.0e-5 1.0;REAL#1.0 |
Long real number--LREAL
| Format | Value range | Input value example |
|---|---|---|
| Comply with IEEE754 standard | -1.7976931348623157e+308 to -2.2250738585072014e-308 ±0.0 +2.2250738585072014e-308 to +1.7976931348623157e+308 | 1.0e-5; LREAL#1.0e-5 1.0; LREAL#1.0 |
warning
- Single precision (REAL): 32 bits in total, of which S occupies 1 bit, E occupies 8 bits, and M occupies 23 bits
- Double precision (LREAL): 64 bits in total, of which S occupies 1 bit, E occupies 11 bits, and M occupies 52 bits
- Special values:
- When the binary digits of E are all 1, and if the binary digits of M are all 0, then N represents infinity, if S is 1, it is negative infinity, and if S is 0, it is positive infinity;
- When the binary digits of E are all 1 and the binary digits of M are not all 0, it means NAN (Not a Number), which means that this is not a legal real number or infinity, or the number has not been initialized.
5.1.5 String
Single-byte character--CHAR
| Format | Value range | Input value example |
|---|---|---|
| ASCII characters | ASCII character set | 'A' CHAR#'A' |
String--STRING or STRING[N]
warning
- The STRING type of Baosky PLC is in the memory, and is actually an array with CHAR elements.
- Baosky PLC allows subscripted access to CHAR elements of STRING type variables. The access starting point of string elements is 1
| Format | Value range | Input value example |
|---|---|---|
| ASCII string, including special characters | The actual storage space occupied in the system=[N+2]BYTE;N is a constant, up to 254; the default value is N=80 | 'Name' STRING#'NAME'< br/> STRING#'' (The string is empty.) |
5.1.6 Time data
Duration--TIME
| Format | Value range | Input value example |
|---|---|---|
| Signed duration | T#-24d_20h_31m_23s_648ms to T#+24d_20h_31m_23s_647ms Precision in milliseconds | T#5MS TIME#5MS |
Date--DATE
| Format | Value range | Input value example |
|---|---|---|
| Date (year-month-day) | D#1970-1-1 ~ D#2106-02-06 The accuracy is days | D#1970-1-1 |
Time--TIME_OF_DAY
| Format | Value range | Input value example |
|---|---|---|
| Time (hour:minute:second.millisecond) | TOD#0:0:0.000 ~ TOD#23:59:59.999 The precision is milliseconds | TOD#0:0:0.000 |
Date and time--TIME_AND_DAY
| Format | Value range | Input value example |
|---|---|---|
| Date and time (year-month-day-hour:minute:second) | DT#1970-1-1-0:0:0 ~ DT#2106-02-06-06:28:15 Accuracy in seconds | DT#1970-1-1-0:0:0 |
Long duration--LTIME
| Format | Value range | Input value example |
|---|---|---|
| Signed duration | Signed long stored ns value LT#-2^63~ (2^63-1) Precision in nanoseconds | LTIME#0ns |
warning
- Bool: If the lowest bit in memory is set, the BOOL type variable is "true". If the lowest bit in memory is not set, the BOOL variable is FALSE.
- Real number: Support for data type LREAL depends on the target device. Are 64-bit type LREALs converted to REALs at compile time (with possible information loss), or remain unchanged