Move (output instruction)

FRD: From BCD

Converts binary coded decimal back to an integer.

Also called: BCD to integer, binary coded decimal convert.

FRD(number, a)

Arguments

NameWhat it isAcceptsDefault
destinationWhat the instruction acts ona registerrequired
aSourcea number or a tag0

Arguments are positional and this table is generated from the simulator's own instruction registry, so it always matches what the engine accepts.

What it does

FRD is the inbound half, and the one you need more often. A thumbwheel switch, a legacy weigher or an old serial device hands you a value where each decimal digit sits in its own four bits, and nothing in your program can do arithmetic on that until it has been converted.

The reason this cannot be skipped is that the raw value looks like a perfectly reasonable number. A thumbwheel set to 25 arrives in the register as 37, because the two BCD digits 2 and 5 are the bit pattern 0010 0101, which read as ordinary binary is 37. Nothing faults. The setpoint is simply wrong, by an amount that changes with every digit, and the machine runs a batch of 37 instead of 25.

Convert once, as soon as the value arrives, and give the converted value its own tag. Everything downstream then works in plain integers.

A rung you can run

A thumbwheel setpoint that means what it says

RUNG 1Thumbwheel_ValidFRD Batch_SetpointFRD Thumbwhe…RUNG 2PPart_SensorCTU Batch_CountPRE 4RUNG 3Batch_Count.ACC≥ Batch_SetpointBatch_Done
XIC(Thumbwheel_Valid)FRD(Batch_Setpoint,Thumbwheel_Raw)
ONS(Part_Sensor)CTU(Batch_Count,4)
GEQ(Batch_Count.ACC,Batch_Setpoint)OTE(Batch_Done)

Turn on Thumbwheel_Valid and set Thumbwheel_Raw to 37, which is what a thumbwheel showing 25 actually sends. Batch_Setpoint becomes 25, and the batch finishes after 25 parts rather than 37. Delete the FRD and the same switch quietly runs 12 parts too many.

Run this rung in the simulator

What it is called on other controllers

PlatformEquivalent
Rockwell (Studio 5000)FRD
Siemens (TIA Portal)CONV, from BCD16 to Int
Mitsubishi (GX Works)BIN
CODESYS and IEC 61131-3BCD_TO_INT, from the utility library

Common mistakes

  • Not converting at all. This is the fault above: the value is plausible, nothing errors, and the setpoint is quietly wrong. Any register that comes from a thumbwheel or a legacy display needs an FRD in front of it.
  • Feeding it something that is not valid BCD. A nibble holding a value above 9 has no decimal meaning. Nothing checks, so nonsense in is nonsense out, and a faulty thumbwheel contact can produce a setpoint that looks almost right.

Practise it

Interactive exercises that use FRD. Each one checks your ladder against a real scan.

Related instructions

All ladder logic instructions