DEC_TO_BCD
The "DEC_TO_BCD" function block allows decimal numbers to be converted to BCD format. The number to be converted is checked for admissibility of the values.
VAR_INPUT
VAR_INPUT
START : BOOL;
DIN : BYTE;
END_VAR
START: the function block is enabled via a positive edge at this input.
DIN: the decimal number to be converted.
VAR_OUTPUT
VAR_OUTPUT
BUSY : BOOL;
ERR : BOOL;
ERRID : UDINT;
BOUT : BYTE;
END_VAR
BUSY: this input is set at the start of the conversion procedure, and remains set until the conversion has been completed. Once the BUSY output has been reset, the BCD value is available at the BOUT output.
ERR: this variable is set to TRUE if an error occurs.
ERRID: error code.
BOUT: the converted variable in BCD format is available at this output if the process is successful.
Error Codes:
Error code | Error description |
---|---|
0 | No error |
0x00FF | The decimal value of the variable to be converted is not reliable |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | TcPlcUtilities.Lib; Standard.Lib; PLCSystem.Lib; TcPLCAds.Lib; PLCHelper.Lib; |
TwinCAT v2.8.0 | PC or CX (x86) | TcUtilities.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) |