ViewOn momentary button writing value to PLC

I am trying to use a button in ViewOn to toggle a value in an Allen Bradley PLC. I want the button to write a (1) while pressing and (0) on depressing the button. The end user will most likely be using a smartphone to toggle the button. I am testing this on a MicroLogix 1100 over Ethernet. I have communication set up properly as I have animation set up on the ViewOn webpage and it works on the incoming tags that are read only. I found the tech note “jog button with viewON”. I wrote the script below for the button and when I “test the animations and actions” from ViewOn, it updates the tag on the test web page. However, when I publish to the Ewon device, my button does not update the actual tag in the Ewon, nor the associated tag in the PLC. I am testing on a PC so that the mouse button works. Would like it to be compatible with mobile. The Ewon tag ‘Wet_recl_run’ is associated with B3:0/13 in the PLC. Wet recl is short for “wet reclaim conveyor”.

MouseDown+button1:
getEwonTagVal(‘Wet_recl_run’);
setEwonTagVal(‘Wet_recl_run’, 1);
commitEwonTagChanges();

MouseUp+button1:
getEwonTagVal(‘Wet_recl_run’);
setEwonTagVal(‘Wet_recl_run’, 0);
commitEwonTagChanges();

Hi @ckaeb1

Just to make sure, are you already able to set the value of the tag on the PLC by changing the value of the tag on the Flexy’s webpage?

@Tim_hms
It does work using an actual mouse. However, I would like to make it compatible with a mobile phone if possible. Because ViewOn is looking for a click or mouse down AND a button input, the mobile does not work with the code I have. Is there an easy way for a mobile device to initiate a momentary change of state?

@Tim_hms
I manually toggled the tag values on the Ewon configuration page and it updated the tag value in the PLC. I then exported the ViewOn project to the Ewon again and it started updating both the Ewon and the PLC. Not sure if just toggling the tag value in the Ewon made everything start working? Thanks for your help!!

Hi @ckaeb1

If you’re doing this through Javascript, I think this may be possible by using touch events such as touchstart and touchend

@Tim_hms
Would this script be on the “Actions” tab of the button in ViewOn, on the “Actions” tab of the “View” in ViewOn, or on the webpage script after publishing it from ViewOn?

Hi @ckaeb1

Here’s an example of one I had done earlier that created a pushbutton print the page.

It goes over grabbing the UID of a button and then shows how to write javascript code to it

@Tim_hms
I contacted our Ewon distributor’s Automation Specialist yesterday as he had sent me a test application he had configured and it works just fine on a mobile phone. He just used the “Send Command” action with a 1 second reset to default. This does not allow the button to stay “on” if you press and hold the button, but for my application today i am not needing a jog button, just a momentary button. After looking at his settings, I realized my problem. The first day I worked on my application I had set up a test user to simulate a customer accessing the Ewon and had set that user up as a “Viewer” and not an “Operator” or “Admin”. This obviously only allows the user to view and not operate any buttons. I changed my test user to an operator and everything works just fine! Thanks for all of your help!!

1 Like