Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

single sample acquisition

How do I take a single analogue sample? I have a NI-6259-USB and tried the following (amongst 50,000 variants):

    DAQmxErrChk(DAQmxCreateTask("ReadDiffAnalogueChannel", &taskHandle));
    DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai1", "", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, NULL));
    DAQmxErrChk(DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_FiniteSamps, 1));
    DAQmxErrChk(DAQmxStartTask(taskHandle));
    DAQmxErrChk(DAQmxReadBinaryI16(taskHandle, 1, 1.0, DAQmx_Val_GroupByChannel, data, 1, &read, NULL));


I just want the controlling software to initiate a sample and read the value. Nothing fancy.

I get the message "Requested value is not a supported value for this property"

Can anyone put me back on the straight and narrow?

Many thanks,
Richard Aston



0 Kudos
Message 1 of 8
(7,833 Views)
Hi Richard,
 
I have recreated the issue and the reason for the error is that the FiniteSamples valid values start at 2 not 1, which is why you are getting this error, try changing the line:
DAQmxErrChk(DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_FiniteSamps, 1));
to
DAQmxErrChk(DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_FiniteSamps, 2));

All the best,
Applications Engineer
0 Kudos
Message 2 of 8
(7,823 Views)
Hi, Rob,

Thank you for your reply.  Unfortunately, that was attempt number 37955, so it's already been tried!  It results in the same message:

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

Task Name: ReadDiffAnalogueChannel


Status Code: -200077

Any other ideas? Any help is very much appreciated!

Richard



0 Kudos
Message 3 of 8
(7,821 Views)
Hi Richard,
 
Seems to imply that the property you are trying to use is not accepted by the card, but a simulated device here says otherwise (granted under a different language) - could you please include the project you are using in a zip file, Measurement Studio version and Visual Studio version you are using (2005/2008/Express etc) and I will try it out here for you.
 
All the best,
Applications Engineer
0 Kudos
Message 4 of 8
(7,818 Views)
Hi, Rob,

Thank you for your continued assistance. I have attached the ZIP file as requested.

This is work-in-progress and I have got round the sampling problem by taking a number of samples and averaging them.  It isn't really an ideal solution but it does help me move forward.

I have assumed that by selecting the 'DAQmx_Val_Diff' mode, the reference channel is automatically selected; so, selecting ai1 selects ai9 as the reference channel, etc.  I only mention this because the readings wander all over the place.  Can you confirm that I am doing this bit right?

Many thanks
Richard.
0 Kudos
Message 5 of 8
(7,813 Views)

Hi Richard,

Thanks for that, although sadly I am unable to run your program on my machine (VS 2005/08) as it won't up convert correctly. I am in the process of verfying this at a lower level (granted under a different language) just to ensure this is do-able etc. I will let you know what I find,

Kind Regards,

Applications Engineer
0 Kudos
Message 6 of 8
(7,809 Views)

Hi Richard,

The AI channel will not do the implicit timing you require, this is due to it being a timing type for a counter source and is normally used in this manner, I would suggest just using this function to get the finite samples in from your system:

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,sampsPerChan));

Here are some KB's of use regarding this:

DAQ Sampling Types & Uses

Implicit Meaning for DAQmx Timing

All the best,

Applications Engineer
0 Kudos
Message 7 of 8
(7,804 Views)
I'll try that.

Many thanks,
Richard
0 Kudos
Message 8 of 8
(7,801 Views)