10-11-2024 12:05 PM
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!
10-11-2024 01:15 PM
Don't have the latest version of LabVIEW on this computer, so I cannot look at your VI, but:
Based on your message, it looks like you have decided on #3.
10-11-2024 01:33 PM
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.
10-11-2024 02:03 PM
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.
10-12-2024 01:04 PM - edited 10-12-2024 01:39 PM
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.
10-12-2024 01:33 PM
@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.
- 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.
10-14-2024 09:51 AM
Hey guys, thanks for taking the time to provide the feedback and assistance. Looks like I have some work to do. I will go back and revisit this version of the code before I start thinking about scaling it up.
I do really appreciate the feedback guys, I am still quite new and learning from the knowledge base and youtube, so I'm very aware that there are holes in my understanding.
10-14-2024 10:02 AM
All you probably need is a simple state machine and use the outer loop for all spinning. No inner loop needed.