02-28-2023 10:02 AM
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
02-28-2023 10:09 AM
You seem to be doing the same measurement on the same channels with the same device twice.....
Are you sure that's correct?
02-28-2023 10:12 AM
You failed to downconvert, so I cannot look at the VI, just a picture.
Does it work??? Does it do what you expect it to do?
What is it supposed to do?
For the picture, there seem to be glaring errors.
02-28-2023 10:24 AM
@GRCK5000 wrote:
You duplicate all code at the start, you only need to split the resulting string. This is however also unnecessary since it creates identical tasks, so you can just do it twice with one instead. This is ofc just silly, measure once. 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.
Also, using the Dev-list and index out a device seems slightly random should anything change about the setup. I'd prefer 2 DAQ-controls on the front panels, or constants.
Assuming you simply forgot to change the indexing in the start, you still only need one DaqDevices and one Indexarray, as it can be expanded to show 2 outputs.
Don't forget to clase Daq-task after loop.
Apart from that it's a good start. 🙂
02-28-2023 10:28 AM
Hi Mr. Altenbach,
I downconverted it.
02-28-2023 10:34 AM
Thanks Yamaeda for the input. I also downconverted my code.
02-28-2023 10:56 AM
@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.
Let's talk about the code before the loop. Why do you need to get the same list twice and process each identically. So much redundancy and duplication. Why exactly are you creating two identical tasks (same device, same channels, same features). Don't these interfere?
Branching an error wire into two and then merging the two identical branches is just plain silly.
You still have not told us what happens when you run it! Does it do what you expect it to do? Do you get errors?
02-28-2023 11:25 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.
Let's talk about the code before the loop. Why do you need to get the same list twice and process each identically. So much redundancy and duplication. Why exactly are you creating two identical tasks (same device, same channels, same features). Don't these interfere?
Branching an error wire into two and then merging the two identical branches is just plain silly.
You still have not told us what happens when you run it! Does it do what you expect it to do? Do you get errors?
Maybe it's just a code review. 😄
02-28-2023 11:40 AM
02-28-2023 12:06 PM
😂 Wow Mr. Altenbach. You are not very patient with me. HAHAHA. I will test it and give you guys update.