LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What do you think about my simple code?

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

GRCK5000_0-1677599960020.png

 

 

0 Kudos
Message 1 of 12
(1,157 Views)

You seem to be doing the same measurement on the same channels with the same device twice.....

 

Are you sure that's correct?

0 Kudos
Message 2 of 12
(1,150 Views)

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.

  • You have an array of two elements, but later you are indexing out element 1 and 2 (you have just lost element 0 forever and 2 did not exist!)
  • Wouldn't it be more reasonable to form the array before the loop and keep the array in the shift register?
  • Why is the stop wire hidden under the while loop boundary?
  • I am not a DAQ expert, but I don't understand the voodoo code before the loop.
0 Kudos
Message 3 of 12
(1,146 Views)

@GRCK5000 wrote:

GRCK5000_0-1677599960020.png

 

 


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. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 12
(1,140 Views)

Hi Mr. Altenbach,

I downconverted it.

0 Kudos
Message 5 of 12
(1,133 Views)

Thanks Yamaeda for the input. I also downconverted my code.

0 Kudos
Message 6 of 12
(1,128 Views)

@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?

0 Kudos
Message 7 of 12
(1,114 Views)

@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.  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 12
(1,095 Views)

"The proof is in the running" 😄

 

0 Kudos
Message 9 of 12
(1,089 Views)

😂 Wow Mr. Altenbach. You are not very patient with me. HAHAHA. I will test it and give you guys update.

0 Kudos
Message 10 of 12
(1,078 Views)