Byte to Hex Text
medium
Writes a byte as two hex digits, 244 as 'F4' and 10 as '0A'.
What it teaches
A byte holds 0 to 255, and hex writes it as two digits worth 0 to 15 each: the first counts sixteens and the second counts ones, so 244 is 15 sixteens and 4 ones, 15 × 16 + 4. The digits are '0' to '9', then 'A' to 'F' for 10 to 15, so 244 is written 'F4'. As characters they are codes 48 to 57 and 65 to 70. DTOS writes decimal only and gives '244'. Below 16 the first digit is 0 and is still written, 10 as '0A', as the serial number kept its zeros in Serial Number Text.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Value | Input | DINT | 244 | A byte value, 0 to 255 |
| Ref_HexByte | InOut | STRING | — | In_Value as two hex digits |
Required behavior
- Devices often take numbers as hex text, two digits per byte. Every scan, Ref_HexByte is In_Value written as exactly two upper-case hex digits: 244 is 'F4' and 10 is '0A'.
- In_Value is always 0 to 255.
- With the default In_Value of 244, Ref_HexByte is 'F4'.