LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does this program group and cluster these button values into an array?

Solved!
Go to solution
In the attached program, there are 6 buttons in a cluster and 1 individual button. These buttons control a bunch of different relays to control power to different components of a single device. Right now the program works in that I can control the 6 buttons, the LED turns on in the board and the power is being transmitted. What I do not understand is how it is doing this.  I ran the program with the highlight execution on and at the start of the read from array component, if say I pressed button 6 and hit ok, it reads #6, where did these get defined and labled? and if i wanted to add another button/relay how do i do this? If someone could explain step by step how this is grouping the relays on the board into an array and then controling them I would really appreciate it. Thanks.
0 Kudos
Message 1 of 30
(4,407 Views)
So the "cluster to array" always reads a #6 regardless of which button I press. This is really confusing me.
0 Kudos
Message 2 of 30
(4,382 Views)

Hi,

So it is easy. The while loop runs :

1rst step, there is an exclusive Or, which make that 2 boolean controls cannot be ON at the same time.

The second step is to write a port.  The port is the collection of channels. 8 (depends of your device) channels make a port.

 You can write on a port using several methods : writing an array 1D of booleans (the easiest to understand), or you can write a value to the port. The value is exactly the same that writing a 1D array, because the value is the translation of the array in a word. for exemple, if you write (True,True,False, False) on your port, you can write 12d, or 0C, the result will be the same...

Any other question ?

V-F
0 Kudos
Message 3 of 30
(4,379 Views)
Yes one more, and not be rude or unappreciative but....huh? So let's say I added in another button, the board has spots for up to 16 relays, how do I assign it a value in the array and figure out which final value is corresponding to the board? If i press button 4, it calculates a 247 and the button turns on, how do I know where to assign these numbers when I want to add in newe buttons? 
0 Kudos
Message 4 of 30
(4,374 Views)

When you press 4, it calculates 247d, so it is 11100011.

I think that when you measure the voltage on the ports,  you will recognize these values. Isn't it ?

 

V-F
0 Kudos
Message 5 of 30
(4,361 Views)
What do you mean measure the voltage? How am I supposed to do this? short of stripping  a wire or two on the board for a probe I dont see how I can do this.....
0 Kudos
Message 6 of 30
(4,357 Views)
What is your device ?
V-F
0 Kudos
Message 7 of 30
(4,353 Views)

This is the device:

http://parts.digikey.com/1/parts/760645-mounting-brd-16-pos-w-50-conn-70rck16-hl.html

 

Ok I can attach a probe somewhere if I take it out of the housing it is in, but what will that tell me? 

0 Kudos
Message 8 of 30
(4,346 Views)

It is a TTL signal : if the line is on, you should measure a 5V signal, and if the line is off, you should measure a 0V signal.

Betweek the GND and each line, you should recognize the 11110111, which is the translation of your 247d. I think that it reverse the lines of the port, so you should measure only one port at ON, which is the 4th or the 5th, depending on how you're reading.

 

V-F
0 Kudos
Message 9 of 30
(4,341 Views)

The #6 your seeing is the number of elements in the array not a value for the array. 

 

Now for some deeper explainations.   From the code it appears that exactly 1 of 6 valves may be used and an additional valve may be in one of two possible states.

 

When the program is run the cluster of buttons is initiallized to all False.  and we enter the outer while loop where a sequence structure starts.  In the first frame of the sequence we initiallize a shift register to hold the current value of "Buttons." and this loop runs unthrottled (Add a wait for next ms multiple to this loop to prevent using 100% of the CPU!) 

 

For each iteration the buttons are read and if a change has occured to any value buttons that were previously True are reset to False to prevent opening more than one valve.

 

When the user presses OK or stop- the current "Buttons" value is passed to the next frame.  This frame convertsthe 7 boolean values to a integer where each valve is controlled by a seperate bit of the integer (Isolation is bit 6 and bits 0-5 each control a mixing valve)

 

Now I'd strongly recommend reworking the DAQmx calls- it is pointless to initiallize the task each time you want to use it- Create the task in the initialzation case and wait until the user exits to destroy the task.  And well a sequence structures are frowned on- (there are better ways to do this)

 

As far as adding a relay- right now the relays are associated to the hardware by their index position in the cluster (element 1 = bit 0 etc....) to add a new valve you would need to decide what bit you would use to drive it and code in that bits' value to write a 0 in that bit.  (hint the 40 constant is realy 0x40 right-click>visable items>show radix )111.PNG

 

 

Let me know if you need further elaboration

 

 


"Should be" isn't "Is" -Jay
Message 10 of 30
(4,338 Views)