02-01-2013 01:08 PM - edited 02-01-2013 01:09 PM
Here's an example image that covers your case 5. The array constant covers every possible combination where es_y-pf_y == -1, es_x==pf_x and es_x != 0 in array indices 4-12. One case in the case structure then covers 4..12 meaning every value from 4 through 12. No, I will not upload the VI - you should learn by trying to create it yourself.
This may not be the best way to solve the problem - the array constant will become huge, especially if you ever use a larger grid - but it is one way to do it, and I think it's easier than many levels of nested case structures. Another way to do it would be to nest your case structures based on the values of pf_y, pf_x, etc so you would have only 4 levels deep of case structure. A case structure does not have to select only a true or false value; it can select from a range of numbers.
02-01-2013 01:24 PM
Thanks once again for the help. Concerning the array constant.could you please explain to me how it is done and how it works. In the fucntion palette the array constant is only 1D.
02-01-2013 01:28 PM
The array in my image is a 1D array - it's an array of clusters, where each cluster contains 4 elements. You have all this information already in the VI that I uploaded previously. Turn on context help (control-H) and put the cursor over a wire to see the type of data on that wire.
There is a cluster constant in the palettes, which is an empty container. Drag other constants (for example numeric constants) into the cluster constant to add items.
When you right-click on an array you'll see that there's an "Add Dimension" option if you do need an array with more dimensions (not here, though).
You should go through the available LabVIEW help and tutorials. You'll find a lot of documentation by searching the NI site, in addition to the help provided with LabVIEW.
02-01-2013 02:22 PM
I have been able to understand the array of clusters, how you are searching for the elements in the cluster, and how to insert several cases in the case structure. But i still can't figure out what you are trying to do in the case. I realised that you unbundle the cluster by name, then decremented the es_x then bundle by name... but still don't understand that part. (By the way confirm if the shift register is updating the values of es_x).
02-01-2013 02:33 PM
What's happening inside the case structure is whatever is supposed to happen inside the corresponding if block in your C code. The moves increment or decrement es_x or es_y so that's what I'm showing there, but it's in no way complete.
@rgb8 wrote:
(By the way confirm if the shift register is updating the values of es_x).
Please write some code and test it to confirm this yourself.
02-01-2013 04:29 PM
When I implement your LV code with shift registers, nothing ever changes. What should the initial values be?
Your move VIs would look something like this:
I used a typedef cluster for all the numerics so that it would only require one shift register. Also using Bundle/Unbundle by Name documents what values are used where. All the subVIs use the same connector pane and front panel. The block diagrams differ by Increment/Decrement and which signal is used.
The logic 1 VI block diagram might look like this:
The other True cases are similar to the one shown with the appropriate move VIs wired in.
Lynn
02-02-2013 02:31 PM
Please check the vi attached. I am not getting the expected values - the initial and expected value of the coordinates are on the vi front panel.
02-02-2013 02:57 PM
I realised what was wrong with the vi. In fact, i had forgotten to connect the shift registers. Finally, i got the expected values. Is there a way to reduce the coding?
02-02-2013 11:56 PM
You're making good progress.
A way to make your code more readable is to use a For loop where you check each case until you find one that matches. Also, I recommend that you pass the cluster into each subVI, instead of passing the individual values. That way you can do a comparison on the entire cluster at once, instead of 4 separate comparisons. See image below. You do not need ptemp_x and ptemp_y - the moves should set pf_x and pf_y directly.
02-04-2013 10:27 AM - edited 02-04-2013 10:37 AM
Please could you help me and if possible give an example how to implement part of the C program (which i have attached) in labVIEW. There are two functions and I would like to implement them in two different vi. Could you give me an idea how i can start it?