Author Topic: Way to advance the time/date in the simulator  (Read 5443 times)

TravisB

  • Newbie
  • Posts: 33
  • I am NOT a llama!
    • View Profile
Way to advance the time/date in the simulator
« on: March 23, 2012, 03:43:13 PM »
I have some BASIC code which takes action based on the change of day, and month, and year at midnight each day. I'm wondering if there is a way I can run the simulator and advance the date/time to midnight, to the end of the month, and to the end of the year so I can see if all of my actions are occuring as expected.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Way to advance the time/date in the simulator
« Reply #1 on: March 23, 2012, 05:06:40 PM »
The simulator Time/date variables are normally loaded with the time/date of the PC when the simulation is started.

You can change the simulators time/date variables when you have the if you click on the "VIEW" button in  them simulator.

Click on the "Edit" button to bring up the "View Variables - Integers" dialog.

If you want to set the simulator time to 23:59:00 you will have to type "TIME[1]=23" and press enter to set the hours to 23.

TIME[2] sets the minutes and TIME[3] accesses the seconds.

DATE[1..4] allows you to change the Year, Month, Day and Day of Week values.

Please be aware that the TIME[] and DATE[] registers can change as your is reading them.  If the time is 23:59:59 it is possible for your TBASIC code may read it as 23:59:59 but if you are unlucky you may read the time as 23:59:00.  Newer PLC families have addressed this issue with the STATUS(18) mechanism.

You may want to look at some sample code that I shows how to set/clear RELAYS base on the RTC without getting glitches.


http://www.tri-plc.com/trilogi/RTCAppByGDK.zip

Please note that the sample code did not worry about the date.  You should take the same precautions with the DATE[] values as I did time the TIME[] values.


Gary D
« Last Edit: March 23, 2012, 05:22:56 PM by garysdickinson »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Way to advance the time/date in the simulator
« Reply #2 on: March 23, 2012, 11:54:10 PM »
For a quicker test you can write a test custom function to set the TIME[n] and DATE[n] to a value several seconds just before the target date and time and then you can observe what happen when the time is up.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

TravisB

  • Newbie
  • Posts: 33
  • I am NOT a llama!
    • View Profile
Re:Way to advance the time/date in the simulator
« Reply #3 on: March 26, 2012, 11:29:15 AM »
Thanks Gary, and thanks support!

Works wonderfully.