Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ error -200284, error -200292 or warning 200010 occurred

Dear all,

 

In principle I have an easy task to do: Applying a voltage ramp (e.g. 0-6V in approx. 200ms) and synchronously read in an analog signal. The whole procedure should be triggered by an external TTL signal at a rate of one Hz.

 

Hardware:

NI cDAQ-9174

Mod1 NI 9215 (BNC)

Mod2 NI 9264 (DSUB)

Mod3 NI 9402

Mod4 NI 9403

 

Software: python 2.7

 

But, from time to time it returns one of the following errormessage:

RuntimeError: nidaq call failed with error -200284

RuntimeError: nidaq call failed with error -200292

RuntimeError: nidaq generated warning 200010

 

I tried to reduce code, but I wanted to keep the main functionalities:

-----------------------------------------------------------------------------

import ctypes

import thread

import time

import numpy

from PyDAQmx import *

nidaq = ctypes.windll.nicaiu # load the DLL

 

class AnalogInOutputThreadPlot():

   """

   """

   def __init__( self, AO_Vstart,AO_length, AO_time):  

# define waveform, # of samples, ...      

       self.sampleRate = 500

       self.AO_Vstart=AO_Vstart

       self.AO_time = AO_time

       self.AO_length=AO_length

       self.periodLength = int(AO_time*self.sampleRate)

       self.waveform=AO_Vstart + AO_length * numpy.linspace(0,1,int(self.periodLength))      

      

   def run(self,n,tsleep):

       self.taskHandleOut = TaskHandle(0)

       self.taskHandleIn = TaskHandle(0)

       self.taskHandleOut2 = TaskHandle(0)

# prepare the wave form in a DAQmx compatilbe list      

       self.dataIn = numpy.zeros((self.periodLength,),dtype=numpy.float64)      

 

# create AI task including clock

       self.CHK(nidaq.DAQmxCreateTask("",ctypes.byref(self.taskHandleIn)))

       self.CHK(nidaq.DAQmxCreateAIVoltageChan(self.taskHandleIn,

                               "cDAQ1Mod1/ai0","", DAQmx_Val_Diff , float64(-10.0),float64(10.0),  DAQmx_Val_Volts,None))

       self.CHK(nidaq.DAQmxCfgSampClkTiming( self.taskHandleIn,  "", float64(self.sampleRate), DAQmx_Val_Rising,

                               DAQmx_Val_FiniteSamps, uInt64(self.periodLength)))

 

# create AO task including clock                              

       self.CHK(nidaq.DAQmxCreateTask("",ctypes.byref(self.taskHandleOut)))    

       self.CHK(nidaq.DAQmxCreateAOVoltageChan( self.taskHandleOut, "cDAQ1Mod2/ao0", "", float64(-10.0),

                              float64(10.0), DAQmx_Val_Volts, None))

       self.CHK(nidaq.DAQmxCfgSampClkTiming( self.taskHandleOut, "", float64(self.sampleRate),

                                DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, uInt64(self.periodLength)))

                  

# reserve all eserves the hardware resources for AI

       self.CHK(nidaq.DAQmxTaskControl(self.taskHandleIn,DAQmx_Val_Task_Reserve))

      

# implementing internel trigger for AO (slave) via AI (master)

       self.CHK(nidaq.DAQmxCfgDigEdgeStartTrig(self.taskHandleOut, "/cDAQ1/ai/StartTrigger", DAQmx_Val_Rising))

# implementing external trigger for AI

       self.CHK(nidaq.DAQmxCfgDigEdgeStartTrig(self.taskHandleIn, "/cDAQ1Mod3/PFI0", DAQmx_Val_Rising))

# set output buffer

       self.CHK(nidaq.DAQmxCfgOutputBuffer (self.taskHandleOut,500))

 

# start loop of AI and AO ...

 

       for i in range(n):

 

           # start AO and AI in individual threads (slave first)

             thread.start_new_thread(nidaq.DAQmxStartTask,(self.taskHandleOut,))                    

             thread.start_new_thread(nidaq.DAQmxStartTask,(self.taskHandleIn,))

           # actual writing AO ramp

             self.CHK(nidaq.DAQmxWriteAnalogF64( self.taskHandleOut, int32(self.periodLength), 0,float64(2),

                             DAQmx_Val_GroupByChannel,self.waveform.ctypes.data,None,None))

           # actual reading AI

             self.read = int32()

             self.CHK(nidaq.DAQmxReadAnalogF64( self.taskHandleIn, int32(self.periodLength),float64(2),

                             DAQmx_Val_GroupByChannel, self.dataIn.ctypes.data,ctypes.byref(self.read),None,None))                              

           # delay to give tasks enough time to finish

             time.sleep(tsleep)

           # display AI data

             ydata=self.dataIn

             print ydata[0:10]

           # stopping tasks so they can be used again in next run

             self.CHK(nidaq.DAQmxStopTask( self.taskHandleOut ))

             self.CHK(nidaq.DAQmxStopTask( self.taskHandleIn ))

                

       # clear tasks in the end

       self.CHK(nidaq.DAQmxClearTask( self.taskHandleOut ))

       self.CHK(nidaq.DAQmxClearTask( self.taskHandleIn ))          

 

   def CHK( self, err 😞

       """a simple error checking routine"""

 

  

AIO=AnalogInOutputThreadPlot(0, 6, 0.2)

AIO.run(10,3)

-----------------------------------------------------------------------------

 

Does anybody have any idea what I need to change to get rid of the error messages?

Kind regards

0 Kudos
Message 1 of 3
(4,434 Views)

Do you have more information on where the errors occur?

Did you follow the instructions in the error descriptions?

 

e.g. error -200292:

"Some or all of the samples to write could not be written to the buffer yet. More space will free up as samples currently in the buffer are generated.
To wait for more space to become available, use a longer write timeout. To make the space available sooner, increase the sample rate."

 

error -200284:

"Some or all of the samples requested have not yet been acquired.
To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger,  make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock."

 

warning 200010:

"Finite acquisition or generation has been stopped before the requested number of samples were acquired or generated."

 

Best,

 

Anna

 

 

 

 

Anna Vogl
Certified LabVIEW Developer
Message 2 of 3
(4,389 Views)

Thank you for your response!

 

I tried to take the suggestions of the error messages into account, but only with minor success.

I was playing around with sample rates and buffer of both AO and AI, following the following guidlines (which I found in the NI support and the error messages):

AO:

Buffer should be at least 2x the samples to write

In order to avoid glitching, low sample rate and large buffer

AI:

High sample rate makes samples available sooner

In addition, I chose the timeout >> samples to read(write) / sample rate.

 

After some trials, and getting rid of the manual buffer assignment (DAQmxCfgOutputBuffer), I ended up with a setting (AO: sample rate 500/s, buffer 200, samples to write 100, timeout 2s; AI: sample rate 5000/s, buffer 1000, samples to write 100, timeout 2s) which allowed me to runt the simplified program stable for 1k runs.

 

But, if first of all, this setting causes a mismatch between the AO and AI. So if I want to monitor the response to my AO using the AI, I cannot choose all these parameters at will.

Furthermore, when I add additional data analysis, e.g. plotting the data or fitting the AI signal, I get again a variety of error messages depending on what I changed (200015, 200547, 200288, 200284 …).

 

The errors 200015,200547, 200288 occur when the DAQmxWriteAnalogF64 function is called.

The errors 200284 occurs when the DAQmxReadAnalogF64 function is called.

The warning 200010 occurs when the AI task is stopped.

 

I am still puzzled why this is not working …

 

Kind regards

0 Kudos
Message 3 of 3
(4,346 Views)