LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling data from 8 AI channels starting at user defined times

Hello all,

 

I have created a small program to read an analog voltage signal until the value drops low enough for 3 seconds, at which point the test ends and the time it ran is displayed. The test begins when the user clicks a start button, and it all works well so far. 

 

However, what I am struggling with is scaling this functionality up to multiple(eventually 😎 start buttons, each initiating measurement and timing from a different channel on the DAQ. I have run into the "resource reserved" error trying to separate the controls, which makes me think the data acquisition needs to be on the same task. If somebody could point me in the right direction on how to approach this I'd be very appreciative. 

 

I've attached the single channel version of the code below, if I need to fundamentally re-imagine this I'm willing - I'm still new to LabView and certainly default to structures that I'm comfortable with. Thanks very much for any assistance! 

0 Kudos
Message 1 of 6
(169 Views)

Don't have the latest version of LabVIEW on this computer, so I cannot look at your VI, but:

  1. A DAQ device can only support 1 AI task at a time. You can NOT have multiple tasks with different channels simultaneously. That is the source of your error.
  2. You can use a single task and once it is completed, set a new task for a different channel.
  3. Or you can collect multiple channels at once and analyze them in parallel to decide what you want to do with the data.

Based on your message, it looks like you have decided on #3.

0 Kudos
Message 2 of 6
(138 Views)

Hi Mcduff, thanks for letting me know about the version issue. I tried the "save for previous version" option and attached below - please let me know if I should use a different method.

 

I agree that your option #3 is the direction I would like to work, I guess I'm just looking for guidance on how to approach adjusting my code to get there. 

0 Kudos
Message 3 of 6
(130 Views)

There are some definite issues with the current code, attached is a quick fix for multiple channels, can still be greatly improved, but maybe it will give you some ideas about how to proceed.

0 Kudos
Message 4 of 6
(114 Views)

I cannot look at mcduff's code (only LabVIEW 2020 here), but lots of your constructs are just silly. There is a lot of code smell independent of and DAQ.

 

 

altenbach_0-1728755652763.png

 

  • Have you ever wondered what would be different if you would just remove that select and the two constants? (we've seen that before, so read the entire thread!)
  • A timeout event with a timeout of -1 will never execute, so why is it there?
  • Your outer loop cannot be stopped. Forcing aborting of a running VI can have consequences.
  • Your inner while loop may never stop if the readings remain in a certain range.
  • Why take the absolute value twice in parallel? Once is enough!
  • A vertical array indicator that spans many screens is not user friendly. Make it smaller and show the scrollbar (or just graph the data!)
  • You could use a chart and "mean ptbypt" (both with a history of 60), eliminating your array shift register entirely.
  • Doing fancy math to get hours minutes and seconds is not needed if you use a relative time format (and why would you need two 60 constants???). altenbach_0-1728757756205.png

     

  • etc etc.

 

0 Kudos
Message 5 of 6
(56 Views)

@altenbach wrote:

I cannot look at mcduff's code (only LabVIEW 2020 here), but lots of your constructs are just silly. There is a lot of code smell independent of and DAQ.

 

 

altenbach_0-1728755652763.png

 

  • Have you ever wondered what would be different if you would just remove that select and the two constants? (we've seen that before, so read the entire thread!)
  • A timeout event with a timeout of -1 will never execute, so why is it there?
  • Your outer loop cannot be stopped. Forcing aborting of a running VI can have consequences.
  • Your inner while loop may never stop if the readings remain in a certain range.
  • A vertical array indicator that spans many screens is not user friendly. Make it smaller and show the scrollbar (or just graph the data!)
  • You could use a chart and "mean ptbypt" (both with a history of 60), eliminating your array shift register entirely.
  • etc etc.

I don't have LabVIEW on this computer, so can't down convert, but I only fixed a couple of the issues you have mentioned. All I did was set up the DAQ correctly for 8 channels, I did not have time to fix the other stuff, needed to go to a meeting. I left the array indicator, didn't think it was a real part of the UI, thought it was there for debugging purposes. 

0 Kudos
Message 6 of 6
(42 Views)