LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spreadsheet Table Search Help w/ state machine

Hi,

 

Having a bit of difficulty with labview when I use state machine to search a table.

 

 

I have 4 stages(I do not use all 4 stages for the state machine in the example provided)

 

4 stages are:

 

Find "Phase"

"What Phase"

"Next Phase"

"Stop"

 

 

Fine Phase:

 

 

In this stage the program simply looks at every cell in the table for a keyword "phase" It does this by incrementing the rows by 1. When it locates this keyword "Phase" it increments the column value by 1 and changes from "Find Phase" to "what phase"

 

 

What Phase:

 

Simply takes the rows and columns values from the previous state and retrieves the value. At which point it determines if the given value is between a Max and a Min range provided by the user. If it is within this range it will output the phase # increment row value decrement the column value so that it can begin search for the next phase. At this point the program switches back to find phase.

 

 

Next Phase:

 

Not implemented

 

 

 

Stop:

 

Not implemented

 

 

 

 

The problem I am having is that I feel as if this is much easier than it looks. I feel that my current approach to this type of searching is very flawed. My goal is to have labview search for a "phase" once located it will begin reading values which it can output to an analyzer to set it up for me. And then labview would prompt the user asking if he/she would like to begin the next phase.  The reason to this approach is so that instead of updating the code for labiview incase I need to change values I can simply update the spreadsheet file which contains all the values. This would allow for a very flexible program which will run anything as long as the necessary values are present.

 

 

 

 

 

Download All
0 Kudos
Message 1 of 7
(3,783 Views)

Yes, you are making it far for complicated than it needs to be. Instead of incrementing the rows, first use the Index Array function to get column 1. You can then use the Search 1D Array function to search for "phase". Wire the Start Index to a shift register initialized to 0. This will return an index value. Write this to the shift register. In the what phase state, index the 2D array to get column 2. Use the shift register value to get the number. Proceed from there. When you go back to the Find Phase, you would increment the index number and the search would begin from after the first found. When the search returns a -1, go to the stop state. The Find Phase state would look something like the code below.

 

First State.PNG

0 Kudos
Message 2 of 7
(3,771 Views)

Are you reporting any specific problems?

 

I think you have a serious dataflow problem.  It is very likely your while loop at the right will start executing with the data from the local variable of the table (which would be empty the first time the VI is run) before your Read spec sheet.VI has had a chance to run and read the data from the spreadsheet to write it to the indicator.

 

Some of your tunnels on the right are set to use "default if wired".  I am wondering if you will lose your place in your counters if you execute a case statement where you actually want to continue passing the data through on the wire.

0 Kudos
Message 3 of 7
(3,770 Views)

Ravens Fan wrote:

Are you reporting any specific problems?

 

I think you have a serious dataflow problem.  It is very likely your while loop at the right will start executing with the data from the local variable of the table (which would be empty the first time the VI is run) before your Read spec sheet.VI has had a chance to run and read the data from the spreadsheet to write it to the indicator.

 

Some of your tunnels on the right are set to use "default if wired".  I am wondering if you will lose your place in your counters if you execute a case statement where you actually want to continue passing the data through on the wire.


No. I am able to increment from one phase to the other without a problem. The issue is that as dennis pointed out I am making it harder than it really needs to be. As for the default when unwired I put it in true false statements so there won't be a value unless I need a value to be sent to it. So far I haven't lost my place but the reason I posted here because it became VERY diffcult to keep track of my current position in the table.

 

 

 


Dennis Knutson wrote:

Yes, you are making it far for complicated than it needs to be. Instead of incrementing the rows, first use the Index Array function to get column 1. You can then use the Search 1D Array function to search for "phase". Wire the Start Index to a shift register initialized to 0. This will return an index value. Write this to the shift register. In the what phase state, index the 2D array to get column 2. Use the shift register value to get the number. Proceed from there. When you go back to the Find Phase, you would increment the index number and the search would begin from after the first found. When the search returns a -1, go to the stop state. The Find Phase state would look something like the code below.

 

First State.PNG


I will give this a shot and post any problems or diffculties I may encounter here.

  

 

0 Kudos
Message 4 of 7
(3,761 Views)
I seem to be having trouble getting it to increment correctly with the suggesstion you provided.
0 Kudos
Message 5 of 7
(3,753 Views)

In the Find Phase state, you are indexing row 0 and not column 0. Look at my example again. In the What Phase, you are discarding the index value because you have nothing wired to the shift register. I don't see the purpose of the second shift register at all. As far as I can tell, you need 1 for the index and 1 for the state.

 

What Phase State.PNG

0 Kudos
Message 6 of 7
(3,747 Views)

Dennis Knutson wrote:

In the Find Phase state, you are indexing row 0 and not column 0. Look at my example again. In the What Phase, you are discarding the index value because you have nothing wired to the shift register. I don't see the purpose of the second shift register at all. As far as I can tell, you need 1 for the index and 1 for the state.

 

What Phase State.PNG


I managed to have it increment as you said. I had to make sure it would from find phase --> what phase ---> Next phase ---> what phase  (in a loop). A question that you might be able to help me with: Because of the way it is looped it seems like this will be stuck in a loop (simply because the comparitor being use is equal to or less than) it feels like I am still searching for it incorrectly. I was under the assumption that it would search for phase  (at which point it would hop to the next state increment columns to grab the value) then return to the previous column exactly where it left at and continue searching for the next "phase" at which point it would simply repeat the same cycle of increment columns grab value return to previous spot and search.

0 Kudos
Message 7 of 7
(3,742 Views)