03-03-2022 12:54 PM
Hello,
I'm new to LV and emergency-learning it for a client project. I've been working through "LabVIEW for Everyone" in my evenings, and I'm very open to criticism and suggestions. I'm trying to grasp and implement what I've learned as I'm incrementally developing this system.
The gist of this project is that I am controlling up to 2 motors (VISA), and recording the motor positions and the force (NI-9202 / cDAQ-9181).
The test stops when a certain force, or distance (not implemented) is reached, or the user halts the test.
Specifically, I'm stuck where I want to be able to Stop the Test, and shutdown the motors, data collection, etc. without Exiting.
in the RUN State, there are two potential tests (1-motor and 2-motors). I have currently a little toggle switch as a placeholder to let me select between the cases (True/False).
Each case has a data acquisition loop, so I guess they are "parallel loops" but only one will ever be running at a time.
I'd like to use one 'Stop Test' button for both cases, but I can't figure out how to do it. I've tried a lot of suggestions I've found in the forums, and searching, and I think it's a PEBKAC problem and I'm not thinking about this correctly.
I'm afraid I need a restructure - but I'm at a bit of a loss. Enqueue/Dequeue is a little lot daunting, and I'm not sure if it would even help in breaking this loop?
Any guidance/thoughts is greatly appreciated. I've shared my code - apologies, it's got VISA and DAQ stuff.
03-04-2022 12:07 PM
I thought a picture might be more helpful. Since the loops aren't running at the same time - in one of the loops the state of the button doesn't get updated.
afaik I need the loops to collect and display the data live.
03-04-2022 01:21 PM
Hi v,
@v_kaiser wrote:
I'm new to LV and emergency-learning it for a client project. I've been working through "LabVIEW for Everyone" in my evenings, and I'm very open to criticism and suggestions.
I think it's a PEBKAC problem and I'm not thinking about this correctly.
I'm afraid I need a restructure - but I'm at a bit of a loss.
Any guidance/thoughts is greatly appreciated. I've shared my code - apologies, it's got VISA and DAQ stuff.
You really should learn more LabVIEW basics before continuing that project:
Really: take note of (all) those training resources offered at the top of the LabVIEW board. Learn about "THINK DATAFLOW!" and all its implications…
@v_kaiser wrote:
Specifically, I'm stuck where I want to be able to Stop the Test, and shutdown the motors, data collection, etc. without Exiting.
in the RUN State, there are two potential tests (1-motor and 2-motors). I have currently a little toggle switch as a placeholder to let me select between the cases (True/False).
Unfortunately you attached only a small portion of your project. Mostly all subVIs are missing!
Those VIs in both cases are missing too…
@v_kaiser wrote:I'd like to use one 'Stop Test' button for both cases, but I can't figure out how to do it.
Due to DATAFLOW your mainVI waits until those "motor test" subVIs are finished. Right now there is no way to tell those subVIs they should stop: you need to change the code architecture!
When you want to handle one UI in parallel to your motor test code then that UI handler needs to run in parallel to the motor testing code…
03-04-2022 01:27 PM - edited 03-04-2022 01:28 PM
Hi v,
@v_kaiser wrote:
I thought a picture might be more helpful. Since the loops aren't running at the same time - in one of the loops the state of the button doesn't get updated.
As I said before: learn the LabVIEW basics, like "THINK DATAFLOW!"
In the TRUE case the stop button is read BEFORE the loop - and so the value inside the loop wil NEVER change: DATAFLOW!
What exactly is the point of a FOR loop set to iterate "-1"?
Why did you replace the WHILE loop by a FOR loop?
03-04-2022 02:33 PM
GerdW,
Thank you for all this information. I will add "THINK DATAFLOW" to my reading material.
I am using the waits and locals to help me debug, and restructuring once pieces are working. I will clean those up as you suggest when I'm ready to port into the final codebase. Thank you for that feedback.
I suspected, thank you. I will restructure accordingly. I wanted to make sure there wasn't a suitable function I didn't know about.