radio button logic

ganutenator

Lifetime Supporting Member
Join Date
May 2002
Location
kansas
Posts
1,440
I want to have some radio buttons in a panel view. Does anyone have any code for this?

More detail: only one button can be selected at a time. If you select another selection, it will clear any other previous selection. I am thinking XOR but XOR only compares two bits at a time. I would like to have logic for a variable amount of radio buttons on one screen.

Any ideas to get me started?
 
Wish I had a PV around to play with....seems to me the PV will do that, setup an array of buttons where only one can be on at a time..ie push 1 its on and all others off.

Seems to me when setting properties of the pushbuttons you used Latched which uses a handshake tag to unlatch. If you write the code with the unlatching part first using a one shot then it will unlatch all buttons then latch the one pushed.

I dont get to play with AB much anymore, seems I have done this but my memory isnt what it should be.

Maybe that will get you started or someone else will offer something better.

Please let me know if I am daft and that isnt feasible.
 
Last edited:
I think I have it

I'm not sure if this will work, and I don't have a Panelview to try it out on.

I think you can do the almost the whole thing in the PanelView.

Create a series of Momentary PBs, configured for VALUE. Each Write Tag, while unique, points to the same word in the PLC. Each PB share a common Inbdicator Tag.

The first PB has a value of 0 or 1. The second PB has a value of 0 or 2. The third 0 or 4. And so on, exponentially.

Eliminate all the text and the outline for each state (including the Error state -- very important). If you really want them to look like Radio buttons, you'll want to import two circles, one filled and one hollow. The zero and Error state will use the hollow circle; the "real" number will use the filled.

In the PLC, the only code you'll need is
NEQ Write_Addr 0 MOV Write_Addr Indicator_TAG

When a button is pressed, the Write address will be non-zero, and so will set the proper bit in the Indicator_Tag address. Each PB will display that result. Most will display the Error state (being neither zero nor the correct value). One will have that value match, and will display that value (with the filled circle).

When the button is released, the Write address will go back to zero, which won't affect the Indicator_Tag.

By using powers of two, the PLC now has a bit set for each state. If the PLC ever neeeds to change the state, it can override the Panelview's setting, and the Panelview will still display the new setting.

Let me know if this works
 
Thats multistate? Isnt that meant to be sequential? State 1, state 2, etc up to 16 states.

God I hate being out of the loop.

May want to look at multistate, it allows you to configure up to 16 pushbuttons. I cant remember if its sequential or not.
 
Multistate is sequential. Press it the first time, goes from state 0 to state 1. Press it again, goes to state 2.

That's no good for this application.

I had said to use a Momentary PB. Press it goes to (Value1), release it and it goes to (Value0).

When you use an indicator tag, you get an extra state, the Error state, for when the value of the indicator tag is something that the object doesn't understand (like Value0 or Value1). What I'm suggesting is that that Error state be the primary display state for each PB.
 
Make bunch of momentary push buttons (up to 16) and make
them use write tags
N7:10/0, N7:10/1, N7:10/2, N7:10/3, ... N7:10/15
and indicator tags
N7:11/0, N7:11/1, N7:11/2, N7:11/3, ... N7:11/15

So the first button would have "/0" addresses, next one
would have "/1" etc. Make sure that ON state of the buttons
is different color (green is good).


In the PLC write following rung:

[NEQ N7:10 0]-----------[MOV N7:10 N7:11]

And there you go.
 
NOTE:

Previous code will not work well with regular push buttons
because you would be able to press wo or three buttons at the
same time. It was designed to work with touchscreens only (PV,
PV+, RAC618x,...).
 
I think the easisest solution would be momentary pushbuttons on the panelview and a horrible amount of latch and unlatch bits in the PLC.

When #B3:1.1 is pushed, latch B9:1.1 and unlatch B9:1.2,B9:1.3,B9:1.4

When #B3:1.2 is pushed, latch B9:1.2 and unlatch B9:1.1,B9:1.3,B9:1.4 ect.....

Remember, on a momentary push button, you can write to one bit (B3's) and change display state using another(B9's).
 
I think the easisest solution would be momentary pushbuttons on the panelview and a horrible amount of latch and unlatch bits in the PLC.

Well I don't know about "easiest" but that's exactly what
single rung with only two instructions does in previous example.
Only difference is that it manages all 16-bit at once so you
dont have to write 16 huge rungs. All you have to do is
put up to 16 momentary buttons on the screen and make sure
the write and indicator tags use same bit:

PB0 uses bit0 (writes to N7:10/0, indicates N7:11/0)
PB1 uses bit1 (writes to N7:10/1, indicates N7:11/1)
PB2 uses bit2 (writes to N7:10/2, indicates N7:11/2)
PB3 uses bit3 (writes to N7:10/3, indicates N7:11/3)
PB4 uses bit4 (writes to N7:10/4, indicates N7:11/4)
PB5 uses bit5 (writes to N7:10/5, indicates N7:11/5)

Then put in you PLC following line and you are done...

[NEQ N7:10 0]---------------[mov N7:10 N7:11]
 
Actually, you can have way more tahn 16 buttons (although, you will be limited by the # available on any one screen of the particular PV you are using).

You can use values of 1, 2, 4, 8, 16, 32, etc. if you need 16 or less, this will work great. But, you can use other values as well, like 3, 5, 6, 7, etc. Any number that can be represented by a 16 bit word in fact. Difference is that you have to use multistate indicators on the buttons and program them to look at the word "value" as opposed to a single bit.
 
thanks

Thank you everybody for your help. I have been out on an oil platform and haven't had access to the internet to reply.

Turns out that I didn't need to write the radio button logic after, the application was not needed.

I think that if I need to do this in the future I will just use momentary buttons that I will oneshot in the PLC. Each button would clear all the bits in the word before setting it's individual indicator bit. Seems kind of simple now.
 

Similar Topics

I'm missing something and cant seem to figure it out for the life of me!! I have 3 tanks to choice from and only want one enabled at a time. A...
Replies
9
Views
1,860
I'm trying to do my first application in factory talk view...and having done regular GUI programming in the past, I'm trying to duplicate the...
Replies
3
Views
5,798
I am drawing a complete blank this morning looking for a unicorn. I would like to install a device at a remote site that will gather the data...
Replies
15
Views
2,285
I'm installing a SCADA system that consist of reading data at a Wastewater Treatment Plant, Elevated water tank and 3 lift stations. My master...
Replies
5
Views
2,315
I would like to request everyone's help so i can enjoy the holiday seasons. Our PLC for our Ship Unloader (Allen Bradley) suddenly lost all...
Replies
4
Views
1,680
Back
Top Bottom