Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

NIDAQBase Counter (NI-6008)

$
0
0

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)

 

staticint 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);

    return0;

}

 

I get the error code. -200428

 

Summary: 

DAQmx_Val_Fallingdoesn't work

DAQmxBaseReadCounterU32 doesn'twork

 

Any help would be greatly appreciated.  

 

 


Viewing all articles
Browse latest Browse all 1271

Trending Articles