02-28-2023 01:52 PM
@GRCK5000 wrote:
This is a setup for two similar NI modules. The configuration is the same for both. The attached code is how I set up the code. It's fine to me, but I was thinking maybe it needs improvement. What would be your suggestion or how would you set it up? If you think my code looks good, let me know.
I'm trying to learn from others.
Thank you.
P.S.: The output of Daqmx read is a 1D array of both modules
Arrays are zero indexed. That means your attempt to split both modules starting at index 1 is actually swapping the second module into the shift register previously holding the first on the first while loop iteration and after the second iteration you have lost both. By the third iteration, both executions of the DAQ read should be generating errors, but you are not handling or displaying errors so there will be nothing to alert you to this aside from your results all being 0.
You are also continuously merging errors onto themselves.
You don't need to pass these individual elements into the loop at all. Build the array and merge the errors prior to the loop. You should only need one shift register each for the DAQ tasks and error cluster.
03-02-2023 09:39 AM
@altenbach wrote:
@Yamaeda wrote:
As already mentioned, after the measurement you only index out 1 element (the other will be empty) so after the 1st loop you'll only measure the 2nd task each time.Well, after one more iteration, all tasks are lost forever.
Right! I somehow missed that at a quick glance!