Author Topic: How to compare time with DM value  (Read 11649 times)

jurg1505

  • Newbie
  • *
  • Posts: 10
  • I'm a llama!
    • View Profile
How to compare time with DM value
« on: March 17, 2014, 01:00:35 AM »
How can i compare the time with a DM value ?

SETLCD 1,11,"| "+STR$(TIME[1])+":"+STR$(TIME[2],2)+":"+STR$(TIME[3],2)+""

if DM[1] >= 0 AND DM[1] < 2400 AND DM[1] <> load_eep16(100) AND then                
save_EEP16 DM[1],100
else DM[1] = load_eep16(100)
ENDIF

if TIME >= load_eep16(100) then

DM[1] is always  4 digits

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:How to compare time with DM value
« Reply #1 on: March 18, 2014, 01:45:46 PM »
Do you mean you want the hour and minute only? You could assemble the number into four digit using TIME[1] and TIME[2]


E.g.  T  = TIME[1] * 100 + TIME[2]

So TIME[1] will be from 0000 to 2359


Alternatively you can also use STATUS(18) to read the clock as a 6 digit value and you can divide it by 100 to remove the seconds so that you get a 4 digit value.

E.g. T = STATUS(18)/100

You can then use T to compare against your DM values.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Philippe Parmentier

  • Newbie
  • Posts: 29
  • new in plc
    • View Profile
Re:How to compare time with DM value
« Reply #2 on: March 18, 2014, 04:13:07 PM »
The other solution is to use a DM32 variable that can easily handle the 6 digits of the full time from 000000 to 235959