Date and time instructions
870
Part III FP Instructions
F158_SUB_DTBCD
_TIMEBCD
Time subtraction
Example:
You cannot specify special data registers DT9054 to DT9056 (DT90054 to DT90056
for FP2/2SH and FP10/10S/10SH) for the operand d_DTBCD. These registers are
factory built-in calendar timer values. To change the built-in calendar timer value,
first store the subtraction result in other memory areas and transfer them to the
special data registers using SET_RTC_DTBCD (see page 874) instruction.
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.
Example 1: clock/calendar data in
DTBCD format
DUT
Member
Result
MinSec 16#2331 (minutes/seconds)
DayHour 16#0114 (day/hour)
August 1, 1992, Time: 14:23:31
(hour:minutes:seconds)
YearMon 16#9208 (year/month)
Example 2: time data in TIMEBCD
format
32 hours; 50 minutes; and 45 seconds
16#00325045 hex
(hours/minutes/seconds)
PLC types
Availability of F158_SUB_DTBCD_TIMEBCD (see page 1321)
Variable Data type Function
s1_DTBCD DTBCD minuend, time and date, values in BCD format
s2_TIMEBCD DWORD subtrahend, 32-bit area for storing time data in BCD format
d_DTBCD DTBCD result in BCD format
Description
Subtracts time data (2 words) specified by s2_TIMEBCD from the date/clock data (3 words)
specified by s1_DTBCD if the trigger EN is in the ON-state. The result is stored in the area (3
words, same format than s1_DTBCD) specified by d_DTBCD. All the data used in this instruction
are handled in form of BCD.
Data types