Author Topic: Turning on a PLC at a fixed time of the day  (Read 2844 times)

Aviraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Turning on a PLC at a fixed time of the day
« on: November 30, 2015, 02:20:59 PM »
Hi

This might be an extremely straightforward question for a lot of you, but somehow, I cant seem to get around it. I have a few Momentary Buttons on my HMI that are used to turn on/off certain PLCs mnually. What I am looking to do is turn on/off these PLCs at the fixed time of the day automatically!

I have the DateTime control on the Form and I can successfully extract the time out of it. I can also check if it is the correct time to turn on the PLCs or not.

What I am having trouble with is that how do I send that on/off message to the PLC through the momentary button. I initially thought that the Momentary Button would have a 'value' property which I can set to True or False. However, it does not have that property.

Would greatly appreciate any assistance in solving this issue.

Thanks in advance

Aviraj

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #1 on: November 30, 2015, 02:43:52 PM »
How about calling the click event?

Aviraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #2 on: November 30, 2015, 04:03:15 PM »
Hi rbelknap

Could you show me with the help of some sample code please ?

Thanks

Aviraj

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #3 on: November 30, 2015, 04:09:08 PM »
You can try

Code: [Select]

button.performclick ()

or

call button_click(me, eventargs.empty)


just replace button with the name of your button.

Aviraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #4 on: November 30, 2015, 04:38:35 PM »
Hi

So i tried your solution, and unfortunately, that did not work.

Something else maybe ?

Thanks a lot

Aviraj

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Turning on a PLC at a fixed time of the day
« Reply #5 on: December 01, 2015, 07:12:31 AM »
What do you have in PLCAddressClick and OutputType properties of your button?

rbelknap

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #6 on: December 01, 2015, 08:02:56 AM »
I just tried this and can't seem to make it work either.

My guess, after looking at the momentary button code is because the PLC click stuff is being done on mousedown.
When we just call the performClick method or the _click event handler is doesn't fire the mouse events.
I also tried it with the basicbutton since the momentarybutton doesn't have the performClick method

I knew calling the click event seemed a little simple.

Hopefully Archie can come up with a way around this for you.

Aviraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #7 on: December 02, 2015, 09:02:51 AM »
So my PLCAddressClick has the register address in it: 05121 and the OutputType is 'Toggle'


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Turning on a PLC at a fixed time of the day
« Reply #8 on: December 02, 2015, 11:43:19 AM »
Add a DateTime to your form, then add this code:
Code: [Select]
Private Sub DateTime1_TextChanged(sender As Object, e As EventArgs) Handles DateTime1.TextChanged
        Dim CurrentDateTime As Date
        If Date.TryParse(DateTime1.Text, CurrentDateTime) Then
            Dim DifferenceOfTime As TimeSpan = CurrentDateTime.Subtract("12:08")
            If DifferenceOfTime.Minutes = 0 Then
                '* Our time is on the same minute as target, so set the bit
                 ModbusTCPCom1.Write("05121",1)
            End If
        End If
    End Sub

Aviraj

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Turning on a PLC at a fixed time of the day
« Reply #9 on: December 02, 2015, 11:48:06 AM »
Ok great, Thanks Archie

I will try that and get back with the results.

Thanks

Aviraj