09-26-2021 12:58 PM
I have a for loop that reads a USB device. I want to combine all of the reads of the output "data". I cannot figure out how to do that. All I get is the last read in the loop. I know this has been answered in other places, but I cannot find it. Any help, please.
09-26-2021 02:50 PM
Two suggestions:
Bob Schor
09-27-2021 12:17 AM
Dear Bob,
Thank you. I know it might be able to do it another way, but the current code works excepts it gets data only from the last pass. If the data would combine my whole code with work.
To simplify, the problem I extracted the code. The real code does compile. If someone can tell me how to arrange the output so all loops are contained. Then my program would be finished.
It is just that I do not understand the several techniques to deal with loops.
Howard
09-27-2021 07:14 AM - edited 09-27-2021 07:17 AM
What he said about not using express VIs. Lets fix that first, right click on the express VI and choose convert to DAQmx code. Now you have code you can see what is going on and modify as you need. Since I do not use that type of express VI I am guessing that the output that says data is a cluster with a deltaT, To and a data array either that or a 2D array with time as the first column and data as the second. Let's assume the former.
Here is the way that I would do it. I would use the shift register. Initialize it with a blank 1D array then inside the loop use build array putting the output of the shift register on top. do a cluster unbundle by name to select the data array and wire it to the bottom of build array. Then right click on the build array and select concatenate inputs so that the output is also a 1D array. Wire that array to the input of the shift register where you currently have the data going.
On exit of the loop if you really want the data to be a cluster you can do a bundle by name and stick the built up data array into the cluster.
09-27-2021 06:01 PM
I fixed the problem by converting the data to an array before the "For Loop" was finished. I then used the "Concatenate". This solution is inelegant but it works.