Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i determine the values for daq-start and daq_rate.

I am trying to acquire a 60hz sine wave on a single channel. I tried the NI example DAQsingleBufAsync. I keep getting errors like daq_start returned error 10111. So I changed some of the values and now I get daq_rate returned error 10685. How do I determine what values I need on a single channel, 60hz wave, to sample every 2 milli seconds?
0 Kudos
Message 1 of 7
(3,334 Views)
What NI DAQ device are you using? The 10685 error means that you are trying to sample faster than the hardware will allow.

What are you entering for the sampling rate? The default sampling rate for the example program is 1000 Hz and this should work regardless of the NI hardware you have. There is a variable entitled 'SampRate' and this variable is the input parameter for the rate parameter of the DAQRate function.

Regards,

Todd D.
0 Kudos
Message 2 of 7
(3,334 Views)
Sorry. I am using a PCI-MIO-16E-4. Initially I was trying to use it just as it was without modification.

dSampRate = 1000.0
ulCount = 100
iUnits = 0
iSampTB = 0
uSampInt = 0

I need to sample a mimimum of 2 milliseconds for 4 seconds and find the peak value over this time span. I didn't think that I would have to change anything except the count (from 100 to 4000).
0 Kudos
Message 3 of 7
(3,334 Views)
Hi,

I am also using the same card and i went through the same program.I was wondering why they have chosen iSampGB and uSampInt=0??The function help of DAQ_Rate tells that you have to input some number for Timebase and Sampleinterval.
0 Kudos
Message 4 of 7
(3,334 Views)
Hi Sally,

Here is the snippet of code from the example program with all of the variables set. With these values, the program runs for me. I'm using a PCI-MIO-16E-1 which is very similar to your hardware.


i16 iStatus = 0;
i16 iRetVal = 0;
i16 iDevice = 1;
i16 iChan = 1;
i16 iGain = 1;
f64 dSampRate = 1000.0;
u32 ulCount = 100;
f64 dGainAdjust = 1.0;
f64 dOffset = 0.0;
i16 iUnits = 0;
i16 iSampTB = 0;
u16 uSampInt = 0;
static i16 piBuffer[100] = {0};
i16 iDAQstopped = 0;
u32 ulRetrieved = 0;
static f64 pdVoltBuffer[100] = {0.0};
i16 iIgnoreWarning = 0;
i16 iYieldON = 1;

If you are wanting to acquire 4 seconds worth of data you would increase the count to 4000 and you will want to increase the buffer size to 4000 as w
ell. I made these changes and the code took 4 seconds to execute and then returned the data.

So, the variables that would need to be changed are as follows:

u32 ulCount = 4000;
static i16 piBuffer[4000] = {0};
static f64 pdVoltBuffer[4000] = {0.0};

I have attached the .c file to this discussion so you can take a look at all of the code to make sure you haven't changed anything else. Acquiring at 1kHz should be fine to acquire a 60 Hz wave.

Regards,

Todd D.
0 Kudos
Message 5 of 7
(3,334 Views)
The timebase and sample interval parameters for the DAQ_Rate function are actually outputs. Based on the the desired rate you input to DAQ_Rate this function will figure the optimal timebase and sample interval to pass to the DAQ_Start of Scan_Start functions. The DAQ_Rate function does a lot of the work for you since you don't have to determine the timebase and sample interval to use. I hope this helps.

Regards,

Todd D.
0 Kudos
Message 6 of 7
(3,334 Views)
Hi,

Thanks.that will help.
I have just started to use the AI-16E-4 card.I am just trying to play around with it.I am using the SC-2040 at the front side of the DAQ card.I was just thinking about giving a sinusoidal sigal of say 1KHz and run this same program DAQsinglebufAsyn.c. I was planning to run it by using the Visual C++ compiler. I was wondering whether the error handling functions and the code for plotting the acquired dat in the .c file work for this Visual C++ compiler.

Thanks
0 Kudos
Message 7 of 7
(3,334 Views)