LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

4by4 puzzle type parking system

Can you please give some explanations on the vi as i am having trouble in understanding the logic that has been used in the block diagram.  The search 1D array how does it work in this example.

0 Kudos
Message 21 of 41
(1,714 Views)

The VI contains an array constant. Each element is a cluster of es_x, es_y, etc. I don't actually have any idea what those variables represent - I didn't work through your C code thoroughly enough to figure it out. Search 1D Array provides a way to find the starting configuration by searching for an element of the array that matches the es_x, es_y, etc values that are entered when the program starts. This is a lot easier than doing separate comparisons for each value.

 

I should have used integer numeric types instead of floating point, though.

0 Kudos
Message 22 of 41
(1,705 Views)

es_y and es_x represent the coodinates of the empty space (es_y : row and es_x : column) similarly for pf_y and pf_x which represent the coordinates of the pallet which needs to be brought to coordinates (3,0)

0 Kudos
Message 23 of 41
(1,698 Views)

Got it. Again, I didn't look through the C code thoroughly. So in this version of the puzzle, you have one empty space and the game ends when you've moved one specific car to the exit position. In that case, I would again simplify the algorithm (in the C code, and the same applies to LabVIEW). Right now it appears you have a separate set of directions for every possible case - that's inefficient. Instead, constantly work back to the same goal. Each case needs to make only one move and update the positions, then repeat with the new positions.

0 Kudos
Message 24 of 41
(1,692 Views)

i have use global variables in the vi attached.  initially, i initialised my global variables.  However for  certain values, when i run the vi,  the program loops continously since the global variables are not updated (for it to meet the condition to stop).  Only when i stop the program and run it again, then i observed that the global variables are updated.  can you tell me how can i update the variables while the program is looping.

0 Kudos
Message 25 of 41
(1,673 Views)

We need the move... subVIs also.  You can zip them so that you do not need to attach numerous files.

 

I recommend that you learn about shift registers and get rid of global and local variables.

 

Lynn

0 Kudos
Message 26 of 41
(1,679 Views)

Do not use global variables. Your code will be much simpler if you do it the way I suggested - store the values in a cluster in a shift register, and use Search 1D Array to find the correct case. For the cases where you're subtracting two values and checking if it's 0 or -1, just add multiple array elements since you're only dealing with possible values of 0 through 3. A single case in a case structure can handle multiple values - separate them with ',' - so you can handle all the combinations of values that give -1 in the same case.

0 Kudos
Message 27 of 41
(1,676 Views)

There is a second logic vi in the attachment.  I tried putting the global variables inside the while loop and i think it worked out. I have been trying to write part of the c program attached (only the first 8 ifs statements) in labVIEW. Could you help me in simplifying it?

0 Kudos
Message 28 of 41
(1,676 Views)

You are doing it all wrong. Start over with NO global or local variables. Store values in shift registers only. Your subVIs need inputs and outputs to dictate the execution order - right now you don't know what order they'll execute, and worse, they might execute simultaneously, which means you don't really know what value is being written to the global variables.

 

Again, a much better algorithm would be to make only a single move in each case. This will move the free space to a new location. Then repeat with those new coordinates, and make another move, until finally you're at the endpoint.

0 Kudos
Message 29 of 41
(1,668 Views)

Indeed it will be much easier the way you suggested but being a beginner in labVIEW i am having some trouble in understanding the concept of clustering, and what do you mean by adding multiple array elements, and how do i separate multiple values in a single case in a case structure - could you give an example.

0 Kudos
Message 30 of 41
(1,667 Views)