LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NIDAQmx usb6229: wrong frequency acquisition

Hello, I'm using CVI 9.0 in order to acquire continuosly an analogic voltage signal using USB6229 in une analog channel.

In the acquisition program, settings and start signal are  executed in a determinate funcion, while reading and stop procedure in an other one.

Start function is:

 

START ADC ACQUISITION */
void StartAdc(void){
    short status = 0;
    DAQmxCreateTask ("", &P.Power.Adc.taskmodpower_diode);
    status = DAQmxCreateAIVoltageChan (P.Power.Adc.taskmodpower_diode, "Dev1/ai0", "", DAQmx_Val_RSE, -0.4, 0.0, DAQmx_Val_Volts, NULL);
    if(status!=0) Failure(GetDAQErrorString(status));
    status = DAQmxCfgSampClkTiming (P.Power.Adc.taskmodpower_diode, "OnboardClock", 5000, DAQmx_Val_Rising,DAQmx_Val_ContSamps,    40000*P.Spc.TimeM);
    if(status!=0) Failure(GetDAQErrorString(status));
    status=DAQmxStartTask (P.Power.Adc.taskmodpower_diode);
    if(status!=0) Failure(GetDAQErrorString(status));
    }

 

P structures are defined into a librarie (so are global variables), and  P.Spc.TimeM is the time measure (of about 1s).

Reading function, called approximetely 1s after start, is:

 

/* STOP ADC ACQUISITION */
void StopAdc(void){
    short status;
    double stdev,value;
    status = DAQmxReadAnalogF64 (P.Power.Adc.taskmodpower_diode, -1, 0, DAQmx_Val_GroupByChannel, P.Power.Adc.Data, 40000*P.Spc.TimeM, &num_read, 0);
    status = DAQmxStopTask (P.Power.Adc.taskmodpower_diode);
    if(status!=0) Failure(GetDAQErrorString(status));
    StdDev (P.Power.Adc.Data, num_read, &value, &stdev);
    P.Step[P.Power.Step].Actual_mean_pow=(long)(value*ADC_FACTOR);
    P.Step[P.Power.Step].Actual_std=(long)(stdev*ADC_FACTOR);
    status = DAQmxClearTask (P.Power.Adc.taskmodpower_diode);
    if(status!=0) Failure(GetDAQErrorString(status));
    }

 

My questions are:

1)FUNCTION DAQmxCfgSampClkTiming: with a clock rate, for exempre, equal to 100, when I call the reading function the value num_read=0 (the function doesn't read any value); the same happen if I use clock rates inferior to abount 4000Hz: is there a minimin frequence with wich I can set the clock?

2)FUNCTION DAQmxCfgSampClkTiming: variyng rate of cloc, for exempre from 4000 to 7000, number of read sample  num_read is always equal to 16384 and is fixed: there are discrete values of clock rate that I can choose? If I put clock rate at 10000  num_read is equal to the double of the previus value, ie 32768: it is somerelationship with the power of 2?

When I performe a measure the effective time is about 1 second while, for example, with a rate of 4000 I acquire 16384 sample and the time of measure shoud behigher than 4 seconds.

3)What happen if I put DAQmxStopTask before DAQmxReadAnalogF64?The program will stop acquisition and read only samples acquired until the stop signal?If I do this the program doesn't read anything and num_read=0.

 

My aim is to monitor the power of a laser while a certain measure is done: I call the Start function when the measure began and I call the Stop function when  the measure finish, reading exactly the number of sample acquired during measure time. What happen realness with the function I wrote?

 

I thank you for the courtesy.

 

Daniele

0 Kudos
Message 1 of 2
(3,291 Views)

Ciao Daniele,

 

the maximum sample clock for your device is 250 KS/s and there's no minimum, as stated in the specifications manual:

 

http://www.ni.com/pdf/manuals/371290g.pdf

 

You can take a look at the examples shipped with CVI:

Help->Find Examples-> Hardware Input and Output->DAQmx->Analog Measurements->Voltage->ContAcq-IntClk.prj

 

In these example you'll see that at line 134 and 135 there's the RegisterEvent function that you haven't used in your code. This function register an event when the specified number of samples is written from the device to the buffer or from the buffer to the device.

Try to make this change and see what happens.

 

When you stop the task you set the task from the running state to the idle state so you're not acquiring anymore and you should get num_read=0

 

I hope this helps!

 

Ciao,

 

Andrea 

Andrea N.
Principal Applications Engineer - Semiconductor EMEA
National Instruments Italy
Certified LabVIEW Architect - Certified TestStand Architect
0 Kudos
Message 2 of 2
(3,270 Views)