Author Topic: How to enter Time of Day  (Read 1677 times)

Mvlawn

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
How to enter Time of Day
« on: February 29, 2016, 12:06:25 PM »
I would like to write the time of day, I want something to happen. What should I use for this?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: How to enter Time of Day
« Reply #1 on: February 29, 2016, 12:47:53 PM »
Write time of day on a form? or in the PLC?

Mvlawn

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: How to enter Time of Day
« Reply #2 on: February 29, 2016, 01:26:35 PM »
Sorry for the lack of clarity. I am looking to move the time from the HMI/Form, to the PLC. I am currently using the keypad from a DigitalPanel meter and writing that to floating register. I then dived by 100 so the minutes and hours are separated by a decimal, then copy that to an integer, and use a little more math. this separates the hours and minutes for me into different registers. I assume an easier way exist.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: How to enter Time of Day
« Reply #3 on: February 29, 2016, 01:37:08 PM »
This is how I would do it:

- Add a button to the form
- Double click the button to get back to the code
- Enter this code:
Code: [Select]
ModbusTCPCom1.Write("40001",Now.Hour)
ModbusTCPCom1.Write("40002",Now.Minute)

Just change according to the driver you are using and the registers that you need to write to.

Mvlawn

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: How to enter Time of Day
« Reply #4 on: February 29, 2016, 04:43:58 PM »
Thanks Archie

StefanA

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: How to enter Time of Day
« Reply #5 on: March 09, 2016, 12:15:01 PM »
Hi,
Can this code you provided above:

ModbusTCPCom1.Write("40001",Now.Hour)
ModbusTCPCom1.Write("40002",Now.Minute)

be used as a substitute for a rtc. Instead of a button press the time would be written automatically every time Advanced Hmi updates.
I don't need any great accuracy just minute and hour.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: How to enter Time of Day
« Reply #6 on: March 09, 2016, 06:05:36 PM »
Hi,
Can this code you provided above:

ModbusTCPCom1.Write("40001",Now.Hour)
ModbusTCPCom1.Write("40002",Now.Minute)

be used as a substitute for a rtc. Instead of a button press the time would be written automatically every time Advanced Hmi updates.
I don't need any great accuracy just minute and hour.
- Add a Timer from the All Windows Forms group in the Toolbox
- Set Interval to 60000
- Set Enabled to True
- Double click the timer to get back to the code
- Enter the above code