Data Acquisition Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Sebastian1516

Configurable DAQ Output Behavior on Stream Buffer Underrun

Status: New

Currently when streaming analog or digital samples to DAQ board, output stays at the level of last sample received when buffer underflow occurs. This behavior can be observed on USB X Series Multifunction DAQ boards. I have USB-6363 model. The exact mode is hardware-timed, buffered, continuous, and non-regenerating. The buffer underflow error code is -200290 “The generation has stopped to prevent the regeneration of old samples. Your application was unable to write samples to the background buffer fast enough to prevent old samples from being regenerated.”

 

I would like to have an option to configure DAQ hardware to immediately set voltage on analog and digital outputs to a predefined state if the buffer underrun occurs. Also, I would like to have an option to immediately set one of PFI pins on buffer underrun.  

 

I believe this could be accomplished by modifying X series firmware and providing configuration of this feature in the DAQmx API. If no more samples are available in the buffer the DAQ board should immediately write predefined digital states / analog levels to outputs and indicate buffer underrun state on PFI line. Then it should report error to PC.

 

Doing this in firmware has certain advantages:

  1. It can be done quickly (possibly within the time of the next missing sample – at 2Ms/s that’s 0.5us).
  2. Handles all situations (software lockups, excessive CPU loading by other processes, loss of communication do to bus traffic, interface disconnection…)
  3. It does not require any additional hardware (to turn off outputs externally).
  4. Buffer underrun indication on PFI line could provide additional safety measure (it could be used for example to immediately disable external power amplifier connected to DAQ AO). 

Doing this using other methods is just too slow, does not handle all situations, or requires additional external circuitry.

 

Setting outputs from software, once error occurs, is slow (~25ms / time of 50000 samples at 2MS/s) and does not handle physical disconnection of the interface. Analog output does eventually go to 0 V on USB-6363 when USB cable is disconnected, but it takes about half a second.  

 

Using watchdog timer would also be too slow. The timer can be set to quite a short time, but form the software, I would not be able to reset it faster than every 10ms. It also would require switching off analog channels externally with additional circuitry, because watchdog timer is not available for analog channels.

 

The only viable solution right now is to route task sample clock to PFI and detect when it stops toggling. It actually does stop after last sample is programmed. Once that occurs, outputs can be switched off externally. This requires a whole lot of external circuitry and major development time. If you need reaction time to be within time of one or two samples, pulse detector needs to be customized for every possible sampling rate you might what to use. To make this work right for analog output, it would take RISC microcontroller and analog electronic switches. If you wanted to use external trigger to start the waveform, microcontroller would have to turn on the analog switch, look for beginning of waveform sample clock, record initial clock interval as reference, and finally turn off the switch if no pulse is received within reference time.

 

I’m actually quite impressed how well USB-6363 handles streaming to outputs. This allows me to output waveforms with complexity that regular arbitrary generators with fixed memory and sequencing simply cannot handle. The buffer underflow even at the highest sampling rate is quite rare. However, to make my system robust and safe, I need fast, simple, and reliable method of quickly shutting down the outputs that only hardware/firmware solution can provide.

 

Thanks,

Sebastian

2 Comments
John_P1
Trusted Enthusiast

I wanted to propose an alternative solution for this one small piece of your request:

 

The only viable solution right now is to route task sample clock to PFI and detect when it stops toggling. It actually does stop after last sample is programmed. Once that occurs, outputs can be switched off externally. This requires a whole lot of external circuitry and major development time. If you need reaction time to be within time of one or two samples, pulse detector needs to be customized for every possible sampling rate you might what to use.

 


You can use an internal X Series counter to achieve this.  Configure the counter as an "Edge Count Task" (strange, I know) using the internal 100 MHz timebase as the source of edges to count.  Set the initial count to be (2^32)-N-1 where N is (100 MHz / AO Sample clock rate).  Enable the "Count Reset" feature and set the AO sample clock to be the reset signal with the reset count equal to your initial count.  Export the "Counter Output Event" to one of the PFI lines.  The counter should use the AO Start Trigger signal as its Arm Start.

 

When the counter rolls over, the output will toggle over to the high state.  The counter won't roll over as long as sample clock pulses are resetting the counter back to the initial value.  Once sample clock pulses stop, the counter will immediately roll over and toggle the line to high.  Be careful though, because once the counter rolls over again (~43 seconds) the line will go back low (I'm sure we could think of a way around this).

 

 

The rest of the stuff that you mentioned would be useful as well, but there isn't a good way to implement it with current X Series hardware features.

John Passiak
Sebastian1516
Member

Thanks for the alternative solution. It works perfectly. Now at least, I have a hardware timed pulse output when generation stops due to buffer underrun or other reason. The only thing I changed was to set initial count to 100MHz / SamplingFreq + 1 and count down. I still have to have a circuit to switch the output off externally, but at least it is simplified.