LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -200279 occurred at Convert Analog Signal to Digital Signal LV 2012.vi

Solved!
Go to solution

Hi,

I'm using the NI USB-6212 and I'm trying to convert an analog signal to digital in real-time using some code I found online, found here (also attached):

http://forums.ni.com/t5/Example-Programs/Convert-an-Analog-signal-to-a-Digital-Signal-Using-DAQmx/ta...

 

The sample rate appears to be limited to 1000Hz, anything above 5000Hz and I get the Error -200279 after a few seconds. I would like to acquire the analog input at 50KHz.  

 

I've read the NI Knowledge Base from here: http://digital.ni.com/public.nsf/allkb/AB7D4CA85967804586257380006F0E62

but I'm still confused how to approach this problem. Do I need to set up a producer/consumer design or is there any other way around this?

Thanks,

W

 

0 Kudos
Message 1 of 7
(2,706 Views)

(deleted)

0 Kudos
Message 2 of 7
(2,703 Views)

The code you attached (and the example you cited) seem weird to me.  I would have expected another algorithm to create the Digital Output (something like "Convert the voltage to a U16 or I16 number, then convert number to array of bits, and write the array to a Port).  But the broader question is why are you getting the error?

 

I recommend forgetting about the Digital Out part and just write a (very small, very simple) VI that produces single A/D values at 1KHz.  How are you configuing the DAQmx code?  Are you using a MAX Task?  What are the parameters?  It should be possible to have a loop that runs at 1KHz, outputting one numeric (voltage) values per loop from a single-point A/D read, should be able to continue for weeks without failing.  But it is failing for you, suggesting that there's a problem in the DAQ Analog Input code.

 

Bob Schor

0 Kudos
Message 3 of 7
(2,667 Views)

Hi Bob,

 

I should note that this is being used for an optical encoder. The input is light intensity (voltage) which produces a spike at ~10Hz. The spike has a shape to it, which I would like to convert to a rectangular pulse. The only output I need is either a 0 or a 1 indicating if the light intensity is low or high, respectively. I hope that clarifies why there is not another algorithm to convert to U16 or I16 (if I understood the first part of your response correctly).

 

I'm still new to LabVIEW, by "configuring the DAQmx code", do you mean how I am inputting the parameters? I've done it directly in LabVIEW, I did not use MAX Task. It is possible to run at 1KHz, in which it converts a sine wave to a rectangular wave. The Error -200279 only occurs when I set the Sample Rate on the Analog Input to 5KHz or above, then the error occurs after ~3 seconds. I think the problem is at higher sampling rates, the buffer is filling up and overwriting itself. So the issue might be somewhere downstream? Is there something in the While Loop that has a default setting of 1KHz? Because if I sample outside the While Loop at 5KHz, then the processes inside the While Loop won't be able to keep up.  Please let me know if my understanding is incorrect. 

 

Thanks,

W

0 Kudos
Message 4 of 7
(2,575 Views)

Hi Bob,

I should add that the application of this code is for an optical encoder, so the only output I need are 0 and 1 for low light intensity (low AI voltage) and high light intensity (high AI voltage), respectively. (The analog input "spikes" have a shape to it, and I would like to convert that shape to a rectangular pulse.) That is why there is not another algorithm to convert the voltage to a U16 or I16 number. 

 

I am still new to LabVIEW, when you say "configuring the DAQmx code", are you referring to where the parameters are input? If so, all the parameters are selected directly in LabVIEW at the front panel, I did not use MAX Task. The code has worked for converting a sine wave (10Hz) to a rectangular pulse when sampling at 1KHz. If I increase to 5KHz, I get Error -200279 after ~3 seconds. I can delay this error by increasing the samples per channel (I believe this increases the buffer size?), but it still occurs after ~10 seconds. This suggests to me something downstream is causing the error. I think the buffer is filling up faster than the data is processed and output, but I don't know to fix this. 

 

Thanks,

W

0 Kudos
Message 5 of 7
(2,600 Views)
Solution
Accepted by topic author WCSRI

You are only reading 1 sample at a time, so acquiring at 5kHz means everything in that loop has to occur at faster than 0.2 msec in order to keep up.  You are relying on software timing and it just won't.

 

You should try accumulating all the samples that you can using N samples, do processing on the arrays, and output the digital output using hardware timing.

0 Kudos
Message 6 of 7
(2,595 Views)

Moreover, with an optical encoder as a sensor, you'd be far better off with a counter input task in the first place.  Look at examples related to counter input and position measurement.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 7 of 7
(2,579 Views)