Determining a buttons up or down state in VBA

awhite

Member
Join Date
Apr 2013
Location
NH
Posts
17
Yes, this is similar to the other posts but different yet.

In VBA is there a way to tell if the button is in the Up Appearance State or the Down Appearance State? There are several buttons on the HMI that use the Toggle Tag Value action setting. This causes the button to hold in the up and down state. I need either which state is was in or is going to be in when the button is pushed. Is this possible?
 
Yes. It is easy to predict because there are only two possibilities. Figure out one, and then you know the next one coming up. Connect a button to something, press button. If the "something" goes ON, then the next state will be OFF, and the following state will be ON, then repeating forever.
 
I'm sure it's possible, it may even be one for you if there is an OnChange event, the real question is, what HMI, what software? We need details to be able to help you.
 
We're using RSView SE 6.1. The button only shows a Released Event. Either way, I would still need to know the previous state or the new state.
 
Oh, if you are using RSView, then there are plenty of options to show the button status. I use colors. In this picture, can you tell which of the Auto-Start and Auto-Stop buttons has been pressed (using the RSView "View, Test Run" mode)?

A more important question: Which do you really care about the most: how many times the button was pressed, OR what is the state of the tag that the button controls? If you tie the button animation color to the state of the tag that the button turns ON or OFF, then you will know something more important than just that the button was pressed. For me, the important thing is: was the button successful in doing its job?

RSView Toggle Button Press.jpg
 
Last edited:
Here is that same AUTO-START button, showing the button animation color. The button color is tied to the status of tag "SYSTEM_RUN". Red= SYSTEM_RUN OFF, Green = SYSTEM_RUN ON.

RSView Toggle Button-Animation Color Tag OFF State.jpg
 
Last edited:
Similar to my other thread, I'm interested in what the state of the tag that the button controls. I need to execute script A when they press the button and script B when they release the button.

I can't place the tag in the VB as it is generic across several hundred buttons. I would need to get the information of the object model. The object model diagram I got from the Rockwell site is incomplete. There's more avaiable and is listed (atleast in RSView SE 6.1).
 
I can't place the tag in the VB as it is generic across several hundred buttons.
Do you mean that you have several hundred buttons that do the same thing? If so, why can't you use the same tag in each one? For every STOP button that I use in a project (usuallly a STOP on nearly every screen), I do use the exact same tags? Why not? It works, is simple, and makes logical sense. You will not run out if you use more than one version of the same tag!

Do you mean you need the logic expression to use in a button for the Press and Release Actions of the button itself (not the tag value that the button controls)? Here is one version for a Stop-Reset button for a Burner Management System gas burner relay. The button is Normally Closed, so pressing the button sets the button tag "BMS_STOP" to 0, and releasing the button sets the tag value back to 1.

RSView Button- Press & Release Actions.jpg
 
Last edited:
Each button controls something different, thus the tag is different for each button.

The buttons you describe I would call jog-style (on while pressed, off when released). The buttons I am working with are push on-push off toggle-style buttons. Thus there are two button presses for each button. I need to execute script A when the button is pressed to turn it on; and script B when the same button is pressed again to turn it off. I cannot see how that could be done within the button properties. Secondly, the items to execute are only available in VB.
 
I need to execute script A when the button is pressed to turn it on; and script B when the same button is pressed again to turn it off.
Ah-hah! You are doing the old alternator, toggle, or flip-flop function in VB script! Now I know the problem! It should not be too hard to take alternator logic that has been done here hundreds of times and convert it to VB script. I bet someone here on this site already has it. Anyone?

Here is one "toggle" or "alternator" in RSLogix. I:1.0/0 is the button. Now all you have to do is convert it to VB. It does use a temporary memory storage location B3:0/1, which may not be possible in VB script.

BST XIC I:1.0/0 NXB XIC B3:0/1 BND BST BST XIO I:1.0/0 NXB XIO O:2.0/0 BND OTE B3:0/1 NXB BST XIO I:1.0/0 NXB XIC O:2.0/0 BND OTE O:2.0/0 BND

I think just about all alternator methods will require at least ONE temporary storage location. If you can set that up in your VB script, then you should be able to do it. However, for most of us, it is easier to set up the alterantor in the PLC program.

Alternator Method 1.jpg
 
Last edited:
Not quite. You have used touch animation whereas they have used button. There is a Toggle Value action for a button which has been used for the toggling. The button properties does the flip-flop but I need to execute a VB script. The script is based on the screen name, button name, and button state. I'm able to get the first two, but the last is the jist of my question.
 
Check out this thread for the deep dark past:
http://www.plctalk.net/qanda/showthread.php?p=2177#post2177

Peter, will you convert your old program to Visual Basic for "awhite"?

Load ixPushButton
r_trig (* rising edge on shot *)
xor oxLamp
Store oxLamp

Not quite. You have used touch animation whereas they have used button.
Who the heck is this "they" you are talking about? I used animation to control a button just as I desired and wanted. Everyone else can do what they want!

I just read your old post. If TConnolly says you can't do it without tags, then you can't. It seems reasonable to me that RSView SE is set up to operate on Tags. If you have no Tags for your buttons, you are up the proverbial creek without a paddle. It seems to me that you could at least use internal Derived Tags for this job. Stop beating your head against the wall and find another method. o_O
http://www.plctalk.net/qanda/showthread.php?t=78726
 
Last edited:
When I started the threads I did not know their paths would cross. 'They' is the customer. I don't always have the opportunity to be the first person in the door. Sometimes I have to deal with what exists or I am handed. Since you were interested in the thread, I was hopeful you might know something I or anyone else did not. I thank you for your time and your repsonses.
 
For the past couple of hours, I tried to write an expression that would be accepted by RSView to toggle a button output (not using the built-in button "toggle" function). I have not found any logic that it understands. Even if I did, I suspect that it would have to use a Tag of some type, maybe a Derived Tag.
 
Based on what all has been said, I would expect that. If the object model does not pass any information about the state or tag information into VB, then I don't think it would be possible as there is no way to know the current or previous toggle state.
 

Similar Topics

We are in the process of installing a new DC drive to replace a 1373 series Speedpak drive. There are 8 leads coming out of the motor -- Two for...
Replies
5
Views
844
Good morning! I am looking for a clever method to determine the number of occurrences in a series using ladder logic. What I need to determine is...
Replies
6
Views
1,256
I have my PLC and HMI connected to my local network over DHCP just like my laptop. I can upload and download including VNC to the HMI over wifi...
Replies
2
Views
1,137
We have a DC Drive (ABB DCS800) which is running a load (initially) at a fixed speed. For testing purposes, we want to simulate a different...
Replies
20
Views
6,229
ive been tasked, due to a restructure of our inventory, to find out how big our SLC programs are. specifically, we have several dozen 5/05s at...
Replies
4
Views
1,654
Back
Top Bottom