Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

cDAQ 9178+NI Output Module 9266. Repeated Overwriting of Continuously Generated Data to Buffer Causing Error. Help With Buffer Size and Sampling Rate

Solved!
Go to solution

Hello, I am using the cDAQ 9178 chassis with the NI 9266 Current Output Module. I am lost on how to set a buffer size and sampling rate for continuous generation of data. 

I have a basic circuit with a switch that is activated when the output is 20 mA, and off when the current is 0 mA.

 

I am using the NIDAQmx Python API, but the problem for me is understanding the logic of what I should be doing, as opposed to the syntax in Python. In order to continuously output 20mA, I believe the steps are:

1) Create a task and assign an AO current channel

2) set the timing of the task to be continuous

3) set the sampling rate and number of samples per channel

4) write to the channel

 

So I have 4 of these switches in my circuit. I want to be able to turn them all on, and then all off. However, I don't understand how to set the buffer so that I don't overwrite or underwrite to the buffer. 

Currently, I am just randomly assigning values to the sampling rate (200) and buffer size (1000). With these values, I am able to activate the switches when I hit "OK" on my GUI, but then it takes 3 seconds to activate, and when I try to turn it off, I get an error -200018: DAC conversion attempted before data to be converted was available. Decrease the output frequency to increase the period between DAC conversions, or reduce the size of your output buffer in order to write data more often. If you are using an external clock, check your signal for the presence of noise or glitches.

 

I am basically assigning random values and getting overload of buffers and underwriting to the buffer so I would like some assistance in finding information on how to approach this problem. I have already read through https://zone.ni.com/reference/en-XX/help/370466AH-01/mxcncpts/buffering/#:~:text=NI%2DDAQmx%2019.5%2.... and related posts but I am still lost.

0 Kudos
Message 1 of 8
(313 Views)
Solution
Accepted by topic author NewtoProgramming

If you need to update the current based on user inputs, you can altogether skip steps 2 and 3.

 

You need the sampling rate only if you're generating strictly time waveforms.

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
Message 2 of 8
(309 Views)

If I don't set continuous output, won't it only send 20 mA? 

For example, in Python I would write:

 

task.write(0.02)

but wouldn't this only send out 1 instance of 0.02A, instead of continuously outputting 20 mA.


Please correct me if I'm wrong.

0 Kudos
Message 3 of 8
(303 Views)

Many output DAQ devices will retain the most recent output value you set until you update it again.  So if you *don't* configure your task to have a buffer and a clock, you'll operate in on-demand mode.  The moment you write a 20 mA output, the driver and device make it happen as fast as possible.  That 20 mA output will continue until some future time when you write a 0 mA output.

 

That's why Santhosh suggested skipping steps 2 & 3 -- that would leave you with a simpler, on-demand task that would respond almost instantly to each write.

 

(Some devices, notably those based on Delta-Sigma converters, do not support on-demand mode and will not retain outputs indefinitely.  I don't think any of the current output devices like your 9266 would be like this though.)

 

 

-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?
0 Kudos
Message 4 of 8
(293 Views)

Oh, I see! I wasn't aware that on-demand sampling is a thing. I thought that was only for Digital IO where you set logic to high/low. 

Is on-demand timing a property I should be able to find on datasheets? I have not been able to locate anything on the cDAQ 9178 or NI 9266 modules.

 

Thank you for your help

0 Kudos
Message 5 of 8
(260 Views)

On-demand sampling is the basic feature of all DAQ and hence not explicitly mentioned.

-Santhosh
Semiconductor Validation & Production Test
Soliton Technologies
NI CLD, CTD
LabVIEW + TestStand + TestStand Semiconductor Module (2013 - 2020)
NI STS for Mixed signal and RF
0 Kudos
Message 6 of 8
(258 Views)

I see. Thank you for your help! 

 

I will update my code and see if it works as intended. 

 

Cheers

0 Kudos
Message 7 of 8
(250 Views)

I just had some time to work on the code and I removed steps 2 and 3 and it worked perfectly!! 


Thank you so much for your help. I appreciate the guidance!

0 Kudos
Message 8 of 8
(232 Views)