LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping and Restarting DAQ Write and Read Operation

Hi All,

 

I am using USB- 6251 DAQ , generating a waveform in the 2 output channels and acquiring data from the 16 channels. I used to get this memory buffer overflow error frequently when I used to run the program continuously.

So I thought that I should run it for a certain time and then Refresh the buffers and memory and then again restart the task. But there seems to be a problem with it.

 

I use the code as below=

 

  snip1.JPG

 

Now I get an Error that the write task cannot be started again as the buffers are previously allocated. I also have this read and write operation synchronized with the write waveform being altered during run time.

 

Please suggest a way to solve this issue.

 

Thank You

Sanjeev

0 Kudos
Message 1 of 4
(2,512 Views)

Hi Sanjeev,

 

I think the "quick and dirty" way to fix your program, would be to change the unreserve function in your write task to a Clear Task.vi.

 

However, you should probably address the underlying issue, which is the buffer overflow.  That indicates that you are trying to write to the buffer faster from LabVIEW than you are outputing on your DAQ card.  In general, National Instruments recommends running your software loop at about 10 Hz or once every 100 ms.  To do this you will need to write out 1/10th of the samples you are writing out in a second at a time, i.e. your Write Ramp sample No.s needs to be 1/10th of your AO Write Sample rate.

 

Also, am I understanding your program correctly in that your Analog Out task is the slave task and your Analog In the master (per your synchronization scheme)?  If so, you should have a DAQmx Write outside of the write loop (as well as one inside) and then start the Analog Out task prior to the loop.  The task will not start outputing sample until it sees the ai/StartTrigger.

 

Have a great day,


Chris V 

Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,495 Views)

Hi Chris,

 

Thank You for your reply, I was actually waiting for this reply. 🙂

 

I did try with the clear task, it shows me an error 200547, that one needs to release resources of a prior write task before creating a new one again, I searched ni.com for this error, it asks to use standard DAQ functions which I think are the ones I use.(http://digital.ni.com/public.nsf/allkb/94596472EED1EC54862571330015A408).

 

Reg the write and read samples, I have set it at 1/10th as you have mentioned, as I am also running the program with 10 Hz's of signal generation.

 

Also , yes I am having the write as the slave task and read as the master, I will try it out with placing a write before the loop with the start task as you have mentioned, but what about the "data" port to this write task( which is placed outside), should I rewire to the same as on the other write task or leave it blank?.

 

Thank You

Sanjeev

 

0 Kudos
Message 3 of 4
(2,485 Views)

Hi Sanjeev,

 

The write before the start needs to be the data you want the task to start outputing as soon as the start trigger is received.  There needs to be something in that buffer so that when the AI task starts there are samples ready to be written.  It appears that you are trying to recreate something like this with your occurances, but it would be much better practice and more readable if you just enforced program flow with error wires.

 

I'm not quite sure about that error.  It could be because somehow your output task is not getting started again, but I'm not sure.  What function is producing this error?  Can you tell if put the VI in highlight execution mode?

 

Have a great day,

 

Chris V 

Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(2,469 Views)