01
BIT_TO_BYTE
可以汇总夹具到位信号与检测开关等信号
FUNCTION BIT_TO_BYTE :BYTE // FC 679
TITLE = 'Version 3.0.00'
VERSION : '3.0'
AUTHOR : VASS_V05
NAME : BTOBY
FAMILY : BTOBY
// Bausteinparameter
VAR_INPUT
BIT_0 : BOOL ;
BIT_1 : BOOL ;
BIT_2 : BOOL ;
BIT_3 : BOOL ;
BIT_4 : BOOL ;
BIT_5 : BOOL ;
BIT_6 : BOOL ;
BIT_7 : BOOL ;
END_VAR
VAR_TEMP
BYTE1 : BYTE ;
TMP_BYTE1 AT BYTE1: ARRAY[0..7] OF BOOL;
END_VAR
TMP_BYTE1[0]:= BIT_0;
TMP_BYTE1[1]:= BIT_1;
TMP_BYTE1[2]:= BIT_2;
TMP_BYTE1[3]:= BIT_3;
TMP_BYTE1[4]:= BIT_4;
TMP_BYTE1[5]:= BIT_5;
TMP_BYTE1[6]:= BIT_6;
TMP_BYTE1[7]:= BIT_7;
BIT_TO_BYTE := BYTE1 ;
END_FUNCTION
02
BIT_TO_WORD
BIT转WORD时一定要注意高低字节的转换
FUNCTION BIT_TO_WORD :WORD // FC 680
TITLE = 'Version 3.0.00'
VERSION : '3.0'
AUTHOR : VASS_V05
NAME : BTOW
FAMILY : BTOW
// Bausteinparameter
VAR_INPUT
BIT_0 : BOOL ;
BIT_1 : BOOL ;
BIT_2 : BOOL ;
BIT_3 : BOOL ;
BIT_4 : BOOL ;
BIT_5 : BOOL ;
BIT_6 : BOOL ;
BIT_7 : BOOL ;
BIT_8 : BOOL ;
BIT_9 : BOOL ;
BIT_10 : BOOL ;
BIT_11 : BOOL ;
BIT_12 : BOOL ;
BIT_13 : BOOL ;
BIT_14 : BOOL ;
BIT_15 : BOOL ;
END_VAR
VAR_TEMP
WORD1 : WORD ;
TMP_WORD1 AT WORD1: ARRAY[0..15] OF BOOL;
END_VAR
TMP_WORD1[0]:= BIT_8;
TMP_WORD1[1]:= BIT_9;
TMP_WORD1[2]:= BIT_10;
TMP_WORD1[3]:= BIT_11;
TMP_WORD1[4]:= BIT_12;
TMP_WORD1[5]:= BIT_13;
TMP_WORD1[6]:= BIT_14;
TMP_WORD1[7]:= BIT_15;
TMP_WORD1[8]:= BIT_0;
TMP_WORD1[9]:= BIT_1;
TMP_WORD1[10]:= BIT_2;
TMP_WORD1[11]:= BIT_3;
TMP_WORD1[12]:= BIT_4;
TMP_WORD1[13]:= BIT_5;
TMP_WORD1[14]:= BIT_6;
TMP_WORD1[15]:= BIT_7;
BIT_TO_WORD := WORD1 ;
END_FUNCTION
03
BIT_TO_DWORD
注意高低字节的转换
代码如下:
FUNCTION BIT_TO_DWORD :DWORD // FC 681
TITLE = 'Version 3.0.00'
VERSION : '3.0'
AUTHOR : VASS_V05
NAME : BTODW
FAMILY : BTODW
// Bausteinparameter
VAR_INPUT
BIT_0 : BOOL ;
BIT_1 : BOOL ;
BIT_2 : BOOL ;
BIT_3 : BOOL ;
BIT_4 : BOOL ;
BIT_5 : BOOL ;
BIT_6 : BOOL ;
BIT_7 : BOOL ;
BIT_8 : BOOL ;
BIT_9 : BOOL ;
BIT_10 : BOOL ;
BIT_11 : BOOL ;
BIT_12 : BOOL ;
BIT_13 : BOOL ;
BIT_14 : BOOL ;
BIT_15 : BOOL ;
BIT_16 : BOOL ;
BIT_17 : BOOL ;
BIT_18 : BOOL ;
BIT_19 : BOOL ;
BIT_20 : BOOL ;
BIT_21 : BOOL ;
BIT_22 : BOOL ;
BIT_23 : BOOL ;
BIT_24 : BOOL ;
BIT_25 : BOOL ;
BIT_26 : BOOL ;
BIT_27 : BOOL ;
BIT_28 : BOOL ;
BIT_29 : BOOL ;
BIT_30 : BOOL ;
BIT_31 : BOOL ;
END_VAR
VAR_TEMP
DWORD1 : DWORD ;
TMP_DWORD1 AT DWORD1: ARRAY[0..31] OF BOOL;
END_VAR
TMP_DWORD1[0]:= BIT_24;
TMP_DWORD1[1]:= BIT_25;
TMP_DWORD1[2]:= BIT_26;
TMP_DWORD1[3]:= BIT_27;
TMP_DWORD1[4]:= BIT_28;
TMP_DWORD1[5]:= BIT_29;
TMP_DWORD1[6]:= BIT_30;
TMP_DWORD1[7]:= BIT_31;
TMP_DWORD1[8]:= BIT_16;
TMP_DWORD1[9]:= BIT_17;
TMP_DWORD1[10]:= BIT_18;
TMP_DWORD1[11]:= BIT_19;
TMP_DWORD1[12]:= BIT_20;
TMP_DWORD1[13]:= BIT_21;
TMP_DWORD1[14]:= BIT_22;
TMP_DWORD1[15]:= BIT_23;
TMP_DWORD1[16]:= BIT_8;
TMP_DWORD1[17]:= BIT_9;
TMP_DWORD1[18]:= BIT_10;
TMP_DWORD1[19]:= BIT_11;
TMP_DWORD1[20]:= BIT_12;
TMP_DWORD1[21]:= BIT_13;
TMP_DWORD1[22]:= BIT_14;
TMP_DWORD1[23]:= BIT_15;
TMP_DWORD1[24]:= BIT_0;
TMP_DWORD1[25]:= BIT_1;
TMP_DWORD1[26]:= BIT_2;
TMP_DWORD1[27]:= BIT_3;
TMP_DWORD1[28]:= BIT_4;
TMP_DWORD1[29]:= BIT_5;
TMP_DWORD1[30]:= BIT_6;
TMP_DWORD1[31]:= BIT_7;
BIT_TO_DWORD := DWORD1 ;
END_FUNCTION
04
Byte_To_Bit
代码:
05
Word_To_Bit
代码:
06
博途BIT_TO_BYTE
在1500PLC里就简单很多
代码:
07
博途BIT_TO_BYTE
联系客服