Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -200077 in DAQmxCfgSampClkTiming

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?

0 Kudos
Message 1 of 9
(5,877 Views)
According to the documentation for the device, it only supports software timing for digital I/O. I don't know what documentation you might have read but it was obviously for a different device. The link you have referred to was not using a 6002.
0 Kudos
Message 2 of 9
(5,854 Views)

Okay, so it turns out the USB-6002 doesn't have an onboard clock. Fortunately conceptually I shouldn't need it; advance trigger mode should be fine. Assuming I understand it correctly: when an external trigger comes in, the card should move to the next set of outputs in the sequence I've pre-loaded onto it.

 

Unfortunately, I still get the same -200077 error when I try to use "Dev1/PFI0" as the clock terminal instead of "OnboardClock". Dev1/PFI0 is listed as a valid terminal by DAQmxGetDevTerminals, so I would expect it to be a valid clock for DAQmxCfgDigEdgeStartTrig. Any ideas what's going wrong?

 

EDIT: heh, simultaneous with the response from Dennis_Knutson.

0 Kudos
Message 3 of 9
(5,852 Views)

Further digging turned up the WriteDigChan_ExtClk example program, which also doesn't work, with the same error, but lead me to the DAQmxGetExtendedErrorInfo() method, which has this to say:

 

DAQmx Error: Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.

Property: DAQmx_SampTimingType

Requested Value: DAQmx_Val_SampClk

Possible Values: DAQmx_Val_OnDemand

 

Attempting to use DAQmxSetSampTimingType() with a value of DAQmx_Val_SampClk throws the same error. Does this mean that using the DAQmxCfgSampClkTiming method is completely impossible for this device? If so, how do I go about accomplishing my task? Which, again, is to load a sequence of outputs onto the card, and have it advance to the next set of outputs each time it receives an input trigger. E.g. on the first trigger it should set Dev1/port0/line0 to 1, on the second trigger it should set that line to 0 and set line 1 to 1 instead, etc.

0 Kudos
Message 4 of 9
(5,829 Views)
I think you'll have to monitor the line with a DAQmx Read and and when you see a logic one, do a DAQmx Write set for 1Samp. Your digital pattern cannot be loaded to the card. You would have create an array and with each write, index the array to get the row.
0 Kudos
Message 5 of 9
(5,825 Views)

At that point you're not doing external trigger; you're doing everything in software and thus subject to the horrendously slow and variable delays of the computer clock. Basically you're saying that the USB-6002 can't do even extremely basic external trigger tasks (input in -> generate specified output). I'm not saying you're wrong, but I'd like to know how I'd determine what its actual capabilities are, ideally through the API. Ultimately we're trying to write code that will run on many NI DAQs, and being able to programatically determine their capabilities would make our users' lives a lot simpler.

0 Kudos
Message 6 of 9
(5,816 Views)
I've never used this basic device and I'm unsure of its trigger capabilities but you certainly can't use any sort of internal or external clock for writing.

I also don't use c++ but you can use the api to get a device's capabilities. There is a device property and from that you should be able to get specific information. I found an article about doing it with .NET at http://www.ni.com/example/30818/en/. Perhaps that will help.
0 Kudos
Message 7 of 9
(5,785 Views)

Hrm, that does appear to be the case. How vexing.

 

Well, thank you for your assistance! Guess we're going to have to switch in an old NI-6251 PCI card instead. Which of course I'm also having problems with, but they're different problems so perhaps I should make a new thread, with a less specific title. I hesistate to call this progress, but it is at least movement...

0 Kudos
Message 8 of 9
(5,730 Views)

Hi there, 

 

Unfortunally the USB-6002 does not have any clock onboard, it uses software time (on demand clock), this mean that it will use the computer software clock. for example, if you have a lot of programs running in your computer, the clock that your application will have is going to be a slow clock.

 

so for your application you do not need to set any clock settings in your program. you have to delete that part of the code.

 

Regards

0 Kudos
Message 9 of 9
(5,722 Views)