01-31-2013 12:28 PM
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.
01-31-2013 01:38 PM
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.
01-31-2013 01:51 PM
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)
01-31-2013 01:59 PM
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.
02-01-2013 09:28 AM
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.
02-01-2013 11:22 AM
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
02-01-2013 12:30 PM
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.
02-01-2013 12:31 PM
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?
02-01-2013 12:39 PM
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.
02-01-2013 12:43 PM
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.