Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write a numeric value to a plc register using a radio button

I'm want display a HOA (HAND/OFF/AUTO) on my screen. Lookout is connected to a Allen Bradley PLC. I am trying to write to a "N" register. I want to write a zero to open all (eg) N7:10 bits(OFF), writing a one (1) to N7:10 will close a contact N7:10/0 (AUTO)and writing a two (2) to N7:10 will close N7:10/1 (HAND)etc. How do I do it? Can I use a radio button and if so, how?
0 Kudos
Message 1 of 10
(5,722 Views)

Hi ICI,

Yes, you can use the radio button. Create the radio button and then connect your PLC bit number to the radio button value. The radio button value is left to right 1-3 in your case. 1 = Hand, 2 = Off, 3 = Auto. When the particular selection is made, it will be true (High or 1, all being the same). You can make the radio button transparent and place a graphic HOA Display with multistate on top it.

Good Luck!

Butler

 

0 Kudos
Message 2 of 10
(5,710 Views)
I need to write more than just a 1 or a 0 to the N register using a switch. A pot will not work. By toggling a switch to different positions or separate switches, each writing a different value to the same register. The logic in the PLC looks at what value was put into that register (value is dependant on what switch or switch position was toggled) and then decides what mode the control is in ie: Hand, Off, or Auto. I'm thinking your response writes a 1 or a 0 to different bits not a word.
0 Kudos
Message 3 of 10
(5,702 Views)

I thought you were just needing a single bit. If you need a specific value, you will need to setup a table or several values in an expression. I may not understand the problem but you should be able to use the radio.value, which is just number of the selection made (like 1-3). Make an expression with an IF statement corresponding to the value needed.

A dataTable can also be used but it is a little harder to setup but it is very powerful tool.

Butler

0 Kudos
Message 4 of 10
(5,696 Views)
I’m a little confused – are you writing to N7:10 (16-bit signed integer value ranging from -32,768 to +32,767) or N7:10_0 & N7:10_1 (single bits within a 16-bit signed integer word)?  Either way you could write to N7:10.  It’s a matter of writing 0, 1or 2 if the PLC is looking at a 16 bit integer – or 0, 1 or 2 if the PLC is looking at the first two bits.  Either way a pot object or radio button object would work.  You would ‘edit connections’ to the AB object and select N7:10.  The expression would be something like ‘if(RadioButton1=1,0,if(RadioButton1=2,1,2))’ or ‘if(RadioButton1=2,1,if(RadioButton1=3,2,0))’ depending on what kind of failsafe you desire (or even just ‘RadioButton1-1’).  If you still want to write to individual bits it would require two ‘edit connections’ and look something like N7:10_0 = ‘RadioButton1=2’ & N7:10_1 = ‘RadioButton1=3’.  Does this help you any, or am I way off base?
0 Kudos
Message 5 of 10
(5,694 Views)

Yes, this does help but I'm not quite sure how to read your expression. We do not require a fail safe. Basically I need an expression that says, if radio_button =1 then N7:10 = 2, if radio_button = 2 then N7:10 = 0, if radio_button = 3 then N7:10 = 1. From looking at my Lookout Reference manual, do you use a "NIF" function or just an "IF" function. How does this look (our customer's PLC is over an hour drive away or I would just try different statements until I got it right), 'NIF(Radio_button=1, 2)' or 'NIF(Radio_button= 2, 0)' or 'NIF(Radio_button=3, 2)'.

I don't want to write to individual bits, they are used in the ladder logic. Based on what value is in N7:10 (0,1, or 2), the ladder uses what ever bit of N7:10 is true. Eg, if the radio button writes a value of 2 to N7:10, then the ladder logic uses N7:10_2 to bypass the "Auto" sequence and start the pump in the "Hand" mode.

0 Kudos
Message 6 of 10
(5,679 Views)
Greetings!
       
   Thanks for the post. Please refer to the developers manual of Lookout , Table 7-1 that talks about using nested if statements and how to read them. Also a simple example for what you are looking for is - if(Radio1.value==1,2,if(Radio1.value==2,0,if(Radio1.value==3,1,"None"))) as mentioned in the previous post. A good way to test this is to drag a pot and a radio button, edit connections for the pot to display the specific values depending on what radio button you select. Please let us know if this is what you are looking for.

Thanks much and good luck
Avi Harjani




0 Kudos
Message 7 of 10
(5,668 Views)

As they say, a picture is worth a thousand words (exactly who ‘they’ are I’m not sure).  So here is a source file (LKS) with examples of the HOA expressions for the Allan-Bradley PLC I so poorly tried to explain earlier.  This way you can see a working example and do some testing.  The two examples are:

 

1.  Number the RadioButton object relative to HOA (1=Hand, 2=Off & 3=Auto) and adjust the number the in the expression writing to the PLC.  N7:10= if(Radio1=1,2,if(Radio1=3,1,0))

2.  Number the RadioButton object relative to the PLC (1=Off, 2=Auto, & 3=Hand) and write the value of the RadioButton directly to the PLC (minus one).  N7:10= Radio2-1

 

Strip off the TXT extension (this site would not allow an LKS extension) to load into Lookout.  I used a lot of expressions in the example because words are more descriptive than numbers.  Note that you can click on the Hand, Off & Auto text above the indicator to change the current value as well as clicking the RadioButton directly.  My suggestion is not to use the RadioButton directly, but to use the PushButtons to alter the value of the RadioButton.  Also, you could easily use a Pot or DataTable instead of the RadioButton.  I hope this clears up what I tried to explain previously.

 

FYI - the function NIF (numeric if) is for backward compatibility and is no longer required or needed (unless you’re still using an old version of Lookout).

0 Kudos
Message 8 of 10
(5,660 Views)

ICI, I read thru the replies, and I'm not sure you got the answer you are looking for.

Using a radio button WILL write an interger value to your N register (it does not write to the bit level, well, in a way it does, but it is designed to write an interger. So you could say that only the first 2 bits in your N register would change, they would be 00 for interger value=0, 01 for interger value=1 and 10 for interger value=2, so to check if you are in Radio Button Value=0 check both bits to be a zero state. Then you would have to check the other bits to see which position your Radio Button is in.

Ok, forget all that, and let's make it simple. Your N register will be an interger value of 0, 1, or 2, depending on which radio button is selected (assuming you have a 3 position radio button 'H-O-A')

An easy way around your whole problem is to make some logic in your PLC that says "if this N register is =0 then turn on bit1, next rung if this N register is=1 turn on bit2, next rung, if this N register is =2 turn on bit3. Now you have new 3 bits that turn on depending if you are in Hand, Off, or Auto (basicly just use an equal statement to turn on a bit's 'coil') Use these 3 new bits in your logic to make what you want to happen.

Hope this Helps

Rich Anderson

Green Bay, WI

Message 9 of 10
(5,577 Views)

Thanks Rich,

This what I ended up doing, the other suggestions didn't really work. I couldn't make their expressions work through a client/server setup. I tried using a radio button which was read by an expression, then linked the expression to a pot then linked the pot to the point in the PLC. The radio button always was writing to the PLC point and if another access point to the PLC tried to write to that point, then the radio button would overwrite it, not to mention that I couldn't get feedback from the PLC to display that point being on. So I put the logic in the PLC and used a pushbutton in Lookout to toggle a "move" command to put a value into that N register, just like you suggected. This was more simple and the controls are not relying on Lookout (if something happened to it)

0 Kudos
Message 10 of 10
(5,562 Views)