Author Topic: Writing a MomentarySet from code  (Read 675 times)

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Writing a MomentarySet from code
« on: March 08, 2017, 11:36:02 AM »
What I need to do is write an integer value to 40009, then do a MomentarySet to 00011, sort of an automatic enter key. I can use either a BasicButton or windows form button to write to 40009. Then I made a BasicButton to do a MomentarySet to 00011 but I can't get the button to fire after I hit the integer buttons. I tried btnMoveManual.PerformClick(); which indeed does fire the event handler but it does not write to the PLC.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5283
    • View Profile
    • AdvancedHMI
Re: Writing a MomentarySet from code
« Reply #1 on: March 08, 2017, 11:47:53 AM »
I tried btnMoveManual.PerformClick(); which indeed does fire the event handler but it does not write to the PLC.
This is because the writing occurs on MouseDown and MouseUp, not on the Click event. You will need to use a Button and 3 write commands.
1) Write value
2) Set bit
3) Clear bit

EE_Kraig

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Writing a MomentarySet from code
« Reply #2 on: March 08, 2017, 12:27:32 PM »
Thanks Archie. Writing them back to back was so fast I couldn't see it in debug mode on the PLC, maybe it would be fine but I wanted a little delay. So what I did is write the value and set the bit on the mousedown event, then clear the bit in the mouseup event.