Arithmetic instructions
350
Part III FP Instructions
F40_BADD
4-digit BCD addition
15 . . 12 10 . . 8 7 . . 4 3 . . 0
d
0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 1
2 1 1 1
0 0 1 1
2 1 2 2
16# (BCD)
15 . . 12 10 . . 8 7 . . 4 3 . . 0
s
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
16# (BCD)
15 . . 12 10 . . 8 7 . . 4 3 . . 0
d
0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 0
16# (BCD)
Example value 16#0011 (BCD)
Bit
Result value 16#2122 (BCD) if trigger is ON
Bit
Bit
Example value 16#2111 (BCD)
This instruction also exists as a P instruction (for FP2/2SH, FP3/5, FP10/10SH PLC types), which
is only executed at the rising edge of the EN trigger. Select [Insert P instruction] from the
"Instructions" pane if you require a P instruction. To facilitate reuse, the instruction then appears
under "Recently used" in the pop-up menu. Press <Ctrl>+<Shift>+<v> within the programming
area to open the list of recently used elements.
When this instruction is used, the area for the augend d is overwritten by the
added result. If you want to avoid the overwrite, we recommend using the
instruction F41_DBADD (see page 351).
PLC types
Availability of F40_BADD (see page 1325)
Variable Data type Function
s WORD addend, 16-bit area for 4-digit BCD data or equivalent
constant
d WORD augend and result, 16-bit area for 4-digit BCD data
Description
The 4-digit BCD equivalent constant or 16-bit area for 4-digit BCD data specified by s and the
16-bit area for 4-digit BCD data specified by d are added together if the trigger EN is in the
ON-state. The result is stored in d.
Data types