LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting from case structure to arrays

I am working on a set up that write out 8 digit binary to a connector block. I had it set up with a case structure but there are over 40 different writes and it is becoming way too convoluted. I know it would be much easier to do this with arrays but I have no idea how to use them, please help.

Here is my current program:
0 Kudos
Message 1 of 9
(3,557 Views)

You are correct, it is getting out of control.  Have you considered a 2D array with current state, next state, and the settings for each state.  You could control your progam using an Excel spreadsheet that would simplify things greatly.  Let me know what you thing of the idea.

I would also write a few subVIs.  One for controlling the exhaust that looks like it is always the same bit flipper.  A second VI for the valve control.  Looks like it is just a waking bit across multiple ports.  I would find a way to do this with code and not hard code each value.  in the end you need to reduce the number of case structures to make it maintainable.

 

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 2 of 9
(3,551 Views)
how would i control it with excel? and how are sub
VIs used?
0 Kudos
Message 3 of 9
(3,545 Views)

Excel was just one of many solutions to your problem.  Export the Excel file to a text format, read it from disk,  and use it as an input to your program.

Attached is a simple solution for controlling the ports done in LV 8.0.  You need to finish it!

 

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 4 of 9
(3,538 Views)
I see that the data going to the port is counting from 0-7 and that it has one case for every port. But, what is the significance of the Numeric I32? I have a previous version of my program that was made for only 6 or  7 valves, this might explain better what im trying to do. This is my first time using LabVIEW as you might have noticed so sorry if I don;t pick up on the strategies right away, thanks for the help.
0 Kudos
Message 5 of 9
(3,530 Views)
I32 was just lazy on my part.  For you application of less than 255 use a U8.  Your application can reduce the number of case structures substantially by using the technique shown for one case for every 8 ports.  I thought that answered the original question of how to make it more simple.
 
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 6 of 9
(3,526 Views)
Here is a quick attempt to do everything with arrays. See if it makes sense to you. As you can see, the code is much simpler. (LabVIEW 8.0).
 
You should be able to adapt some of the ideas. Many additional simplifications are possible, for example you could calculate the port 0 values directly from the outputs of the upper Q&R function. Try it!
Message 7 of 9
(3,503 Views)
what is the significance of the five false values that are connected to the array vi?
0 Kudos
Message 8 of 9
(3,490 Views)

It's an array of SIX FALSE values, one for each LED indicator. The LEDs form an array on the front panel, so we need to update all six values. At each iteration, we start with a template of six OFF  values, then one of them is turned on whenever needed to display the appropriate state, using "replace array subset" before the final array reached the indicator terminal.

 

0 Kudos
Message 9 of 9
(3,482 Views)