ni.com is currently undergoing scheduled maintenance.
Some services may be unavailable at this time. Please contact us for help or try again later.
07-24-2019 03:37 PM
Hello All,
I am new to LabVIEW and I have trouble while using the DAQmx related functions. I am using LabVIEW 2017 and PCIe6321 boardLabVIEW-left (initiate tasks AO/DO tasks)
LabVIEW-2-1, tasks procedure, with waiting for external trigger (start digital edge)
LabVIEW2-2, tasks process, with no waiting for the trigger
LabVIEW-3 stop the task when stop the labVIEW and clear the tasks
This is my first time posting a question here and sorry for the large pictures, this program has lots of subvi so I post the section where I have problem with in picture form.
basically I try to create 2 outputs, 1 AO and 1 DO, and for 2 scanning modes. one is default and the other one is circular scan which requires waiting for external trigger.
In the picture above, I have the main loop and created an event structure with value change of the "scan mode". and the idea is that it will only go to the task that waits for the external trigger (single pulse) in the "save circular" scan mode.
there are 6 values for the "scan mode", 4 preview modes and 2 save modes (named "save 3D", "save circular"). Originally with no trigger function, when I process the save 3D tasks, will finish outputting the signal and then change the "scan mode" from "save 3D" to "preview 3D". right now with "start digital edge" trigger on the "save circular" case, if it has been ran once, the "save 3D" case will be also affected and requires a external trigger to run.
I am wondering if I set up this correctly? I need an external single pulse trigger to get the "save circular" event, but not the "save 3D" event.
Also, is it possible to use the trigger as something like value change and ran a certain even structure? how to setup that part?
Thank you very much,
Link
08-15-2019 10:34 AM
Hey Link,
Thank you for posting to the forums. My advice since you are fairly new is to try with one of the examples that come with DAQmx and build off of that. The examples can create some good starting points. You can find them by going to Help>>Find examples>>Hardware Input and Output>>DAQmx when opening up LabVIEW .
But to help out the current situation, you should be able to set up a trigger and based upon that either go into a certain event, start data collection, etc. Our examples have a triggering example too.
Regards,
MrJacket
08-15-2019 11:29 AM
For someone new to LabVIEW, you're tackling a fairly complex app here. I can't give transmit years of experience in the couple of paragraphs I have time for so let me hint at a few things you can explore:
1. Neatness really does count. Neat code with orderly wiring is much easier for others to read and interpret "at a glance." Often, YOU are one of those others, several months later.
2. Putting entire running DAQ tasks inside individual event cases is a LabVIEW no-no. It's considered bad practice to tie up an event-handling loop that way by having time consuming things inside one of the event cases.
3. You'll benefit by learning about "state machines", especially "event-driven" ones. You can find a lot of info here with some searching. Basically, an event (handled in the event loop) signals to a parallel state machine to change state and perform the long-running DAQ code.
(Sometimes, these might better be thought of as "action machines", but you won't find that terminology much.)
-Kevin P
08-15-2019
11:38 AM
- last edited on
05-13-2025
01:50 PM
by
Content Cleaner
Here's a link describing the State Machine architecture.
You might also find that if you're able to directly post snippets or VIs you can get help from a larger number of people.
The Producer/Consumer design is also often helpful when it comes to acquisition followed by processing, but you'd probably need to look at an event driven loop as one of your enqueuers. (I think that link only covers the basic idea)