Analog Monitors ¶ HYSTERESIS (FunctionBlock) LIMITALARM (FunctionBlock)
BCD Conversions ¶ A BYTE in the BCD format contains integers between 0 and 99. Four BITs are used for each decimal place. The ten decimal place is stored in the BITs 4-7. Thus the BCD format is similar to the hexadecimal presentation, with the simple difference that only values between 0 and 99 can be stored in a BCD BYTE, whereas a hexadecimal BYTE reaches from 0 to FF. Example: The integer 51 should be converted to BCD format: 5 in binary code is 0101, 1 in binary code is 0001, which makes the BYTE 01010001 in BCD code, which corresponds to the value $51=81. BCD_TO_BYTE (Function) BCD_TO_DWORD (Function) BCD_TO_INT (Function) BCD_TO_WORD (Function) BYTE_TO_BCD (Function) DWORD_TO_BCD (Function) INT_TO_BCD (Function) WORD_TO_BCD (Function)
LIMITALARM (FB) ¶ FUNCTION_BLOCK LIMITALARM Monitors if an input value is between a lower and a upper limit InOut: Scope Name Type Comment Input IN INT Input value HIGH INT Upper limit LOW INT Lower limit Output O BOOL TRUE : IN > HIGH FALSE : Else U BOOL TRUE : IN < LOW FALSE : Else IL BOOL TRUE : Neither O nor U are TRUE
BCD_TO_BYTE (FUN) ¶ FUNCTION BCD_TO_BYTE : BYTE Converts one byte in BCD code into one byte in binary code Use BYTE_TO_BCD for the reverse conversion. InOut: Scope Name Type Comment Return BCD_TO_BYTE BYTE Value in binary code for the input B Input B BYTE Value in BCD code
BCD_TO_DWORD (FUN) ¶ FUNCTION BCD_TO_DWORD : DWORD Converts one DWORD in BCD code into one DWORD in binary code Use DWORD_TO_BCD for the reverse conversion. InOut: Scope Name Type Comment Return BCD_TO_DWORD DWORD Value in binary code for the input X Input X DWORD Value in BCD code
BCD_TO_INT (FUN) ¶ FUNCTION BCD_TO_INT : INT Converts one byte in BCD format into an INT value Example in ST: i := BCD_TO_INT ( 73 ); (* Result is 49 *) k := BCD_TO_INT ( 151 ); (* Result is 97 *) l := BCD_TO_INT ( 15 ); (* Output -1, because it is not in BCD format *) InOut: Scope Name Type Comment Return BCD_TO_INT INT Value as INT for the input B Input B BYTE Value in BCD code. If the value is not in the BCD format, then the output is -1.
BCD_TO_WORD (FUN) ¶ FUNCTION BCD_TO_WORD : WORD Converts one WORD in BCD code into one WORD in binary code Use WORD_TO_BCD for the reverse conversion. InOut: Scope Name Type Comment Return BCD_TO_WORD WORD Value in binary code for the input W Input W WORD Value in BCD code
BYTE_TO_BCD (FUN) ¶ FUNCTION BYTE_TO_BCD : BYTE Converts one byte in binary code in the range of 0..99 into one byte in BCD code Use BCD_TO_BYTE for the reverse conversion. InOut: Scope Name Type Comment Return BYTE_TO_BCD BYTE Value in BCD code for the input B Input B BYTE Value in binary code
DWORD_TO_BCD (FUN) ¶ FUNCTION DWORD_TO_BCD : DWORD Converts one DWORD in binary code into one DWORD in BCD code Use BCD_TO_DWORD for the reverse conversion. InOut: Scope Name Type Comment Return DWORD_TO_BCD DWORD Value in BCD code for the input X Input X DWORD Value in binary code. Valid range: 0..99999999
INT_TO_BCD (FUN) ¶ FUNCTION INT_TO_BCD : BYTE Converts an INT value into a byte in BCD code Example in ST: i := INT_TO_BCD ( 49 ); (* Result is 73 *) k := BCD_TO_INT ( 97 ); (* Result is 151 *) l := BCD_TO_INT ( 100 ); (* Error! Output: 255 *) InOut: Scope Name Type Comment Return INT_TO_BCD BYTE Value in BCD code for the input I Input I INT Value as INT. A wrong value (<0 or >99) causes a return of 255.