LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat Scans Using DAQmx Read/Write

Solved!
Go to solution

Hello:

 

I am using DAQmx vi's to generate signals onto the ao0/1 channels an reading signals from the ai0/1 channels of a NI USB 6251 DAQ board. I do so using the Read and Write vi's and a trigger vi. This vi runs successfully for one scan. Now, I need to be able to conduct multiple scans with the same settings but separeted by 5 seconds or so. When I click Scan, the vi scans. However, when I click scan again it does nothing and I don't know how to make it scan again.

 

The SAW RAMP MOD vi (not included) is simply used to generate the shape of the signal.

 

Thank you!

Alfredo
0 Kudos
Message 1 of 23
(4,482 Views)

Hmmmm looks like it should run ... except you aren't using AutoStart on the tasks .  See if the reads and writes are throwing any errors.  Also you could try to expressly stop the tasks, just add a DAQmx Wait until done and a stop task after the reads and writes.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 23
(4,477 Views)

Thank you for the response.

 

I don't know what you mean by Auto Start. I tried your Wait Until Done and Stop vi's but it didn't work. It scans once. Then once it is done I click SCAN again but nothing happens.

Alfredo
0 Kudos
Message 3 of 23
(4,475 Views)

Well, then lets set a few conditional probes on the error chain going through the DAQmx functions.  Something is most likely throwing some error that is tossed out in the next while loop iteration.  And what version of DAQmx is installed?


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 23
(4,470 Views)

Alfredo,

 

Make sure that you force the DAQmx Start Task to run on the AO task before it runs on the AI task.  This task needs to be ready to run and waiting when you start your AI task.  In addition, you use Get Terminal Name with Device Prefix, however you don't provide a 'Local Terminal Name', which I believe you'll want to specify as "ai/StartTrigger".

 

A few other ideas.  Configure your triggers outside of your main while loop.  Use DAQmx Control Task to commit both tasks outside your while loop.  Inside the loop, you'll want to start both tasks (AO first), Read Data from AI, Wait For Done on AO, and call DAQmx Stop on both tasks.  I would probably use a shift register for the DAQmx Task wires.

 

Hope that helps,

Dan

 

Edit:  As Jeff had mentioned, checking for errors with your DAQmx tasks is probably worthwhile.  Typically I would make an error from a DAQmx task be a terminal condition for my while loop.

0 Kudos
Message 5 of 23
(4,468 Views)

Looking at it some more...

Wire a F constant to the autostart input of DAQmx Write.

Upgrade DAAQmx to at least 9.1

for more on the Autostart bug see this thread.

for more on why to commit your tasks outside the loop see Sean's post here


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 23
(4,462 Views)

Dan:

 

As I am still learning about DAQmx, I am having some difficulty implementing your suggestiong to "force the DAQmx Start Task to run on the AO task before it runs on the AI task". I'll keep working at it. Do the DAQmx Read/Write vi's need to be outside of the While Loop? Does that mean that the DAQmx Start vi's remain inside the Whie Loop and the True/False Case Structure?

 

No errors seem to occur when I conduct my first scan. When I try to conduct a second scan it yields a Trigger Error:

 

Error -200557 occurred at Property Node DAQmx Trigger (arg 1) in DAQmx Start Trigger (Digital Edge).vi:1->WMS_Cell Readings.vi

 

You suggest using DAQmx Control Task to commit both tasks outside the while loop. Perhaps this is part of the answer for my previous question but unfortunately I've never used this vi before. I'll look further into this. Could you forward me to a page where this vi is explained in a way that is useful for my application? Thank you!

 

Alfredo

Alfredo
0 Kudos
Message 7 of 23
(4,453 Views)

Hi Jeff:

 

Is an autostart necessary even with the DAQmx Start vi?

 

I am using Labview 2009 v 9.0f3

 

Alfredo

Alfredo
0 Kudos
Message 8 of 23
(4,453 Views)

Alferdo-

There is a bug in DAQmx resolved in NI-DAQ version 9.1 related to DAQmx not releasing some resources properly when using autostart.  You have left the autostart input to the write vi unwired so its a default true calling the write starts the task right then unless you wire a F to the input.  You only need to set the timing once outside the loop (this will fix your error) 

 

Look at the blue text in my latest post.  Clicking on blue text will open the links inside them.  Sean-N really popped the hood and explained the DAQmx Stateflow diagram and how to optomize DAQmx by expressly controlling the task state.

 

@ McDan By the Way- usuing a Shift register to store the DAQmx Task just adds overhead- the reference doesn't change just the data in memory the reference points to-  Sorry about the font change I must have hit a hotkey


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 23
(4,439 Views)

I took your advice and added a F on the autostart terminal of the DAQmx Write vi but was still getting this error.

 

Error -200557 occurred at Property Node DAQmx Trigger (arg 1) in DAQmx Start Trigger (Digital Edge).vi:2->WMS_Cell Readings.vi
Possible reason(s):

Measurements: Specified property cannot be set while the task is running.

Set the property prior to starting the task, or stop the task prior to setting the property.

Property: Start.TrigType

Task Name: _unnamedTask<6E>

 

Then I moved the Trigger and Write vi's outside of the while loop and kept the Start vi's inside and got the following error.

 

Error -200479 occurred at DAQmx Start Task.vi:1

Possible reason(s):

Measurements: Specified operation cannot be performed while the task is running.

Task Name: _unnamedTask<74>\

 

I feel close to solving this issue but am not quite there. Thanks for the help so far!

Alfredo
0 Kudos
Message 10 of 23
(4,434 Views)