From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NIDAQBase Counter (NI-6008)

OS: Mac OSX Yosemite 10.10.1

NIDAQ: USB-6008

Driver: NI-DAQmx_Base 14.0.0

Environment: Xcode 6.1.1

 

I'm trying to get the frequency measurement function to work on my mac, and I'm running into endless problems:

(Note: I've developed the same code on a Windows machine where everything work as expected.) 

 

First of all, I can get only a single example from the "Examples" directory to run, but only using it exactly as it is. If I change anything, it doesn't work. For example,

 

changing DAQmx_Val_Falling --> DAQmx_Val_Rising I get the error code: -200077: <err>Requested value is not a supported value for this property.

 

If I change: 

DAQmxBaseReadCounterScalarU32 --> DAQmxBaseReadCounterU32 I get the error code: -200428: Value passed to the Task/Channels In control is invalid.

 

If I copy and paste the example code: (and run with and without the minor modifications shown below)

 

static int gRunning=0;

void main(int argc, char *argv[])

{

    // Task parameters

    int32       error = 0;

    TaskHandle  taskHandle = 0;

    char        errBuff[2048]={'\0'};

    time_t      startTime;

    

    // Channel parameters

    char        chan[] = "Dev1/ctr0";

    

    // Timing parameters

#define     bufferSize 100

    

    // Data read parameters

    uInt32      data[bufferSize];

    int32       samplesToRead = 100;

    float64     timeout = 10.0;

    int32       read;

    

    

    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));

    DAQmxErrChk (DAQmxBaseCreateCICountEdgesChan(taskHandle,chan,"",DAQmx_Val_RisingFalling,0,DAQmx_Val_CountUp));

    //DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Falling,DAQmx_Val_ContSamps,samplesPerChan));

    

    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));

    gRunning = 1;

    // The loop will quit after 10 seconds

    startTime = time(NULL);

    while( gRunning && time(NULL)<startTime+10 ) {

        DAQmxErrChk (DAQmxBaseReadCounterU32(taskHandle,samplesToRead,timeout,data,samplesToRead10,&read,NULL));

        printf("Acquired %ld samples\n",read);

    }

    

Error:

    if( DAQmxFailed(error) )

        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);

    if( taskHandle!=0 ) {

        DAQmxBaseStopTask(taskHandle);

        DAQmxBaseClearTask(taskHandle);

    }

    if( DAQmxFailed(error) )

        printf ("DAQmxBase Error %ld: %s\n", (int long)error, errBuff);

    return 0;

}

 

I get the error code. -200428

 

Summary: 

DAQmx_Val_Falling doesn't work

DAQmxBaseReadCounterU32 doesn't work

 

Any help would be greatly appreciated.  

 

 

0 Kudos
Message 1 of 3
(4,964 Views)

Hi roi3i3ie,

 

you said that this is the only example which you get to run.

Did you only try the examples we provide for the counter based acquisiton?

 

Are the examples we provide for DI/O or analog acquisition working?

 

 

Best regards,

Andi

0 Kudos
Message 2 of 3
(4,947 Views)

Hi Andi, 

 

Thanks for the reply! 

 

No, I only tested these ones. I'm under a bit of time pressure, so I couldn't test everything. I'm also not really using these functions in my final program, as I have some nice GPIB controllable equipment. 

 

If I get an opportunity, I can test these too and report back. 

 

 - Rob

0 Kudos
Message 3 of 3
(4,945 Views)