Quantcast
Channel: Digital I/O topics
Viewing all articles
Browse latest Browse all 2167

Error -200077 in DAQmxCfgSampClkTiming

$
0
0

I'm trying to use an NI USB-6002 device as a shutter controller. It should receive a trigger signal input and in response send one or more pulses along its digital output lines. Based on the example in this link, I wrote up this code in C++:

 

            char startTrigPort[256] = "/Dev1/port2/line0"; // source trigger port
            char taskName[256] = "Trigger test task";
            int numSamples = 1000;
            int samplesPerSec = 100;
            TaskHandle handle;
            error = DAQmxCreateTask(taskName, &handle);
            if (error) {
                return logError(error, "CreateTask");
            }
            char outChan[256] = "Dev1/port0/line0";
            error = DAQmxCreateDOChan(handle, outChan, "", DAQmx_Val_ChanForAllLines);
            if (error) {
                return logError(error, "CreateDOChan");
            }
            error = DAQmxCfgSampClkTiming(handle, "OnboardClock", samplesPerSec, DAQmx_Val_Rising,
                DAQmx_Val_FiniteSamps, numSamples);
            if (error) {
                return logError(error, "CfgSampClkTiming");
            }
            error = DAQmxCfgDigEdgeStartTrig(handle, startTrigPort, DAQmx_Val_Rising);
            if (error) {
                return logError(error, "CfgDigEdgeStartTrig");
            }
            // 10000 matches number in CfgSampClkTiming
            // Wait 10s for writing to complete (maybe should vary based on length of
            // data being written?)
            uInt32 *sequence = new uInt32[numSamples];
            for (int i = 0; i < numSamples; ++i) {
                sequence[i] = (i / 50) % 2;
            }
            int32 numWritten = 0;
            error = DAQmxWriteDigitalU32(handle, numSamples, false, 10,
                DAQmx_Val_GroupByScanNumber, sequence, &numWritten, NULL);
            if (error) {
                return logError(error, "WriteDigitalU32");
            }
            if (numWritten != numSamples) {
                LogMessage(("Didn't write all of sequence; wrote only " + boost::lexical_cast<string>(numWritten)).c_str());
                return 1;
            }

(the logError function just calls DAQmxGetErrorString, logs the result, and then returns the original error code)

 

As suggested in the title, I'm getting an error -200077  when I call DAQmxCfgSampClkTiming, with the error message being "Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property."

 

I don't know what's going wrong here. According to the documentation, the parameters to that function seem correct, and our device really ought to be capable of 100 samples per second for 10 seconds, so I doubt the sample rate or number of samples is an issue. Any advice?


Viewing all articles
Browse latest Browse all 2167

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>