Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog out triggered by PFI? (DAQmx C)

I'm trying to trigger a change in an analog output signal based on a digital input.

 

  1. AO = 1V
  2. DI Trigger rises
  3. Prepare AO for 2V
  4. DI Trigger falls=>AO goes to 2V

 

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
0 Kudos
Message 1 of 3
(3,221 Views)

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. 

 

0 Kudos
Message 2 of 3
(3,210 Views)

Thanks Elleryjh for your post!! Smiley Happy

I was able to solve my problem with your indication.

 

Miko
0 Kudos
Message 3 of 3
(2,865 Views)