LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

triggering issue with DAQ Assistant

Hi there. I have a quick question: (Labview 8.0, PCI-MIO-16E-4, BNC-2090)
 
I am having an issue with triggering. My DAQ Assistant is inside a for loop which is inside a while loop. The for loop runs 10 times before the while loop repeats. My goal of the trigger is to start the 10 iterations of the for loop, and then repeat the 10 iterations of the for loop every time the trigger starts again and in the meantime the while loop counts how many times the whole sequence of for loops repeats. Still with me?
 
However, when I use the starting trigger, my for loop only runs once, not ten times. And then when the next trigger occurs, the second iteration of the for loop occurs. Do you see what I mean? So basically what I am having a hard time with is somehow being able to trigger the 10 iterations of the for loop (one iteration of the for loop isn't good enough) when it is inside a while loop.
 
I'll attach my program (it is a little messy cause I am a Labview beginner)
 
Thanks a lot for your help
0 Kudos
Message 1 of 7
(3,374 Views)

Hello Cameroon,

Please correct me if I am wrong, but from your post I believe you want to have your for loop run 10 times for every 1 trigger you get.  I have taken a look at your code, and for every trigger you receive 1024 points sampling at a rate of 1KHz.  Now you have a couple of options to solve your problem.  The easiest way to fix this is to take your DAQ Assistant outside of your For Loop so it runs only once per loop iteration.  You would then specify to acquire 10 240 points and in each loop iteration you address the next set of 1024 points.  This however might not be desirable since you are acquiring approximately 10 seconds of data before processing any of it.  If you want to acquire data in your for loop so that you are reading in data each iteration you will need to use the DAQmx VIs and not the Express VIs. 

To see how to setup an analog trigger task using the DAQmx VIs please see the example called Acq&Graph Voltage-Int Clk-Analog Start w Hyst.vi in NI Example Finder.  You can find this example in NI Example Finder under the browse tab by selecting Hardware Input and Output >> DAQmx >> Analog Measurements >> Voltage.  You can access NI Example Finder from LabVIEW under the help menu.

In your example you would want to create a finite task with an analog start trigger.  You would tell your task to acquire 10 240 points.  All your task configuration would not be performed inside your for loop.  Inside the for loop you would perform a DAQmx read with 1024 points specified.  After your for loop you would stop the task and start the whole process over the next loop iteration.  This way you only trigger once for all 10 loop iterations.

I hope this clarifies things. 

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 7
(3,361 Views)

Okay so let me see if I get this straight:

  • The DAQ mx Create Channel, Sample Clock, Trigger, Stop and Start VI's would be inside while loop but outside for loop
  • The DAQ mx read is INSIDE the for loop

Is this right?

Thanks for your help by the way. Oh and option number you mentioned is preferred.

Cameron

0 Kudos
Message 3 of 7
(3,359 Views)

Cameron,

I would place the DAQmx Create Channel, Sample Clock, and Trigger outside your while loop.  Place the start task inside your while loop but outside your for loop.  Next, have only the DAQmx read inside your for loop.  Outside your for loop you would have a stop task.  This allows you to only configure your task once.  There is no need to put initialization inside your while loop.

In the example I mentioned before a clear task is used.  In order to do the above mentioned task you will need to use a stop task instead of the clear task.  Since that is a little confusing I've attached a picture of this.  I modified a shipping example and attached a picture of the block diagram to demonstrate what I mentioned above.

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 4 of 7
(3,345 Views)

Hi Jesse -

You've been a huge help so far and I seem to have a little problem. When I try and run my program I get this error:

"Error 1 occured at The vectors can not be empty arrays

Possible reason(s):

LabVIEW:  An input parameter is invalid.
---
NI-488:  Command requires GPIB Controller to be Controller in Charge."

I am not sure why this is happening and the error warning goes straight to the uppermost 3D curve graph. I will send you my updated program with all the changes you told me to make. I have a feeling it is an issue with the Analog Reading DAQ mx VI but I cannot figure why that is. I've tried fiddling with it for over two hours and gotten nowhere. Your expertise is always appreciated.

Cheers,

Cameron

0 Kudos
Message 5 of 7
(3,333 Views)

Cameron,

I have taken a look at your application and it is a little hard to understand exactly where you are having the problem.  It sounds as if one of your arrays is empty, and an empty array is an invalid input somewhere in your application.

A couple things to note/try.  First, when you are configuring your retriggerable task, you specify the hysteresis level to be 5V when the trigger level is 5V.  This might be causing you problems if you signal does not go below 0V.  Perhaps a hysteresis value of 1V would be better.

Next, run your application in highlight execution mode while looking at the block diagram.  To do this configure your front panel however you need to and then open your block diagram.  Next, turn on the highlight execution option (4 buttons left of the run button.  It looks like a light bulb).  Finally, run your application and see if you are getting data from your DAQmx read, and find exactly where the error is coming from.

This error might also occur if you do not receive a trigger within 10 seconds because your DAQmx read will return an empty array.  To increase this time, make the timeout on the DAQmx read larger.

I hope this helps,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 6 of 7
(3,318 Views)
Jesse-
 
Thanks for all your help. Two things went wrong but I figured it out:
 
1) I wrote the trigger name as PF10 instead of PFI0 (see the subtle difference?)
2) I had a faulty BMC wire for my input signal (not my trigger)
 
But it works nicely now and I really appreciate time/effort
 
Thanks,
 
Cam
0 Kudos
Message 7 of 7
(3,315 Views)