Serial Number Text
medium
Builds a laser marker's serial number, 'SN-0042', from a counter.
What it teaches
DTOS writes a number with only the digits it needs, so 42 becomes '42', and 'SN-0042' needs its two zeros added. CONCAT joins two STRING tags and does not take text in quotes, so fixed text such as 'SN-' has to be in a STRING tag first. RTOS is no way round this: it prints 7 as '7.00000000'.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_Count | Input | DINT | 42 | The part counter, 0 to 9999 |
| Ref_Serial | InOut | STRING | — | The text the laser marker prints |
Required behavior
- Every scan, Ref_Serial is 'SN-' followed by In_Count as exactly four digits, with leading zeros: 42 is 'SN-0042'.
- In_Count is always 0 to 9999.
- DTOS writes as many digits as the number needs and no leading zeros, so the zeros have to be added.
- CONCAT joins two STRING tags and does not take text in quotes, so put 'SN-' into a STRING tag first.
- With the default In_Count of 42, Ref_Serial is 'SN-0042'.