Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Output on USB6008 in ANSI C doesn't work

Solved!
Go to solution

 I tried to program the analog output on an USB6008 device under MSVC++ 6.0 with the newest NI-DAQ 8.8.

 

The lines from the ANSI C Example program "MultVoltUpdates-IntClk.c " work fine with an emulator device, but not as soon as I try to access the actual USB6008 device.

 

 

    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev2/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,4000));
 

When calling the last line about the timing setting, an error occurs:

________________________________________________________


DAQmx Error: Measurements: Requested value is not a supported value for this pro
perty.
Property: DAQmx_SampTimingType
You Have Requested: DAQmx_Val_SampClk
You Can Select: DAQmx_Val_OnDemand

Task Name: _unnamedTask<0>

Status Code: -200077

 

________________________________________________________

 

Is there  any work-around?

Finally, I want to set single values for the analog output voltage in a loop.

When commenting out the  "DAQmxCfgSampClkTiming" call, no voltage is set in an "DAQmxWriteAnalogF64" call to this task handle.

 

Thank you for any hints!

 

0 Kudos
Message 1 of 6
(3,612 Views)
Did you search for this error? You cannot simulate a 6008 so you must have simulated a device that supports hardware timed output. Your actual device does not. You can only used On Demand sampling (software timed) and it probably won't come close to your desired sample rate.
0 Kudos
Message 2 of 6
(3,610 Views)

I forgot to mention, that I actually used for emulation a PCI-6221, since the USB-6008 cannot be emulated.

I'm aware of the low DAC converter rate (< 150Hz) of the USB device, but that is fine with me.

 

What I did not find out, is how to configure the timing correctly in a C call.

Is there any advise ?

 

Thank you!

 

Klaus

 

 

0 Kudos
Message 3 of 6
(3,602 Views)
As the error mentions, you have to use DAQmx_Val_OnDemand for timing.
0 Kudos
Message 4 of 6
(3,596 Views)
Solution
Accepted by topic author ktphys

"DAQmx_Val_OnDemand" is not a valid option for "DAQmxCfgSampClkTiming(.....)" and results in runtime errors, if I put it in anyway.

 

 

 

As an alternative, I tried meanwhile:

 

 

 

 

 DAQmxErrChk (DAQmxCreateTask("",&AO_V_taskHandle));

 

 DAQmxErrChk (DAQmxCreateAOVoltageChan(AO_V_taskHandle,dev+"ao0","", \
  0.0,5.0,DAQmx_Val_Volts,NULL));

 DAQmxErrChk (DAQmxSetSampTimingType(AO_V_taskHandle, DAQmx_Val_OnDemand));

 DAQmxErrChk (DAQmxStartTask(AO_V_taskHandle));

 DAQmxErrChk (DAQmxWriteAnalogF64(AO_V_taskHandle,1,0,1.0, \
  DAQmx_Val_GroupByChannel,&data_v_out,&written,NULL));
(with data_v_out = 2.; --> on return: written = 1)  --> no output voltage measurable

 

 DAQmxErrChk (DAQmxStopTask(AO_V_taskHandle));

 

--> still no output voltage measurable

 

Any other idea?

 

0 Kudos
Message 5 of 6
(3,586 Views)

The last piece of code is actually working.

 

I could locate the real problem now: The pin no. 16 should be "GND" according to the manual, but actually it is floating (at least on my hardware).

Since I always measured pins 14 and 15 (ao0 and ao1) against pin16, I never got a DC signal. When I use pin 13 as ground, everything is o.k.

 

Thank you for your support!

 

Klaus

 

0 Kudos
Message 6 of 6
(3,584 Views)