I prefer IEC timers for a number of reasons. One of them is that it is easier to use the values from a HMI driectly.
The format of the setpoint for an S5 timer is:
· W#16#wxyz
· Where w = the time base (that is, the time interval or resolution)
· Where xyz = the time value in binary coded decimal format
Time Base Binary Code for the Time Base
10 ms 00
100 ms 01
1 s 10
10 s 11
The milliseconds timer setpoint should allready be in BCD format. If not, you must convert it from INT to BCD with the ITB instruction.
As the smallest resolution for an S5 timer is 10 ms, so should the value from the HMI also be in 10 ms resolution ("12" = 120 ms).
It could look like this:
if 10 msec timebase is used:
L "HMI_SP"
ITB //remove this line if HMI_SP is allready BCD
L W#16#0FFF //first 4 bits set to zero = 10 ms timebase.
AW //combine HMI_SP and 0FFF to make BCD setpoint.
T "S5Timer_SP"
10 msec timebase it a little different from the other timebases.
Example if 1 sec timebase is used:
L "HMI_SP"
ITB //remove this line if HMI_SP is allready BCD
L W#16#0FFF
AW //strip the last 4 bits from HMI_SP
L W#16#2000 //first 4 bits set to 0010 = 1 sec timebase.
0W //combine HMI_SP and 2000 to make BCD setpoint.
T "S5Timer_SP"