06-22-2010 04:30 PM
I'm trying to trigger a change in an analog output signal based on a digital input.
I have the digital trigger going into PFI1, which seems to work to trigger a continuous sine wave in MAX, but I'm unable to do it with the DAQmx C SDK.
I think it's a combination of DAQmxCfgSampClkTiming and/or DAQmxCfgDigEdgeStartTrig, but I'm unable to get it working.
Here's my code, simplified:
void setup(){
DAQmxCreateAOVoltageChan(handle,"Dev0/ao1","",-10.0,10.0,DAQmx_Val_Volts,"");
DAQmxCfgDigEdgeStartTrig (handle, "Dev0/PFI1", DAQmx_Val_Falling);
}
void changeVoltage(float v){
DAQmxWriteAnalogScalarF64(handle,true,100.0,Voltage,NULL);
}
The call to DAQmxWriteAnalogScalarF64 produces error -200262: An attempt has been made to configure a trigger without configuring the appropriate sample clock properties or when Sample Timing Type was set to On Demand.
So I added:
DAQmxCfgSampClkTiming(handle, NULL, 500000, DAQmx_Val_Falling, DAQmx_Val_HWTimedSinglePoint, 1);
but now DAQmxWriteAnalogScalarF64 produces error -89120: Source terminal to be routed could not be found on the device.
So what am I missing here? Thanks for any and all help!
DAQmxWriteAnalogScalarF64
06-23-2010 09:45 AM
I solved it. I was able to accomplish this with:
void setup(){ DAQmxCreateAOVoltageChan(handle,"Dev1/ao1","",-10.0,10.0,DAQmx_Val_Volts,""); DAQmxCfgSampClkTiming(handle, "PFI1", 1000, DAQmx_Val_Falling, DAQmx_Val_HWTimedSinglePoint, 1); } void changeVoltage(float v){ DAQmxWriteAnalogScalarF64(handle,true,100.0,v,NULL); }
I think the problem was referring to "Dev1/PFI1" instead of just "PFI1" - it doesn't know where to look when I give it the device name.
12-02-2011 09:48 PM - edited 12-02-2011 09:53 PM
Thanks Elleryjh for your post!!
I was able to solve my problem with your indication.