• 0
cfontana

Reading raw integer data with FDwfAnalogInStatusData16

Question

Hello all,

I am trying to read data from an Analog Discovery 2, but I am a bit confused by the FDwfAnalogInStatusData16() function.
I would prefer to have the raw integer data from the AD2, as I want to histogram them and I would have to convert back the doubles to integers.

On the include file of the C API it is written

DWFAPI BOOL FDwfAnalogInStatusData16(HDWF hdwf, int idxChannel, short *rgu16Data, int idxData, int cdData);

and I do not understand the difference between idxData and cdData.
I tried to guess from the buffer sizes with no success.
Reading from the AD2 I know that the maximum buffer size is 8196 (is this per channel?), so I thought that the idxData parameter is an index of the waveform and that the available samples (that I read with FDwfAnalogInStatusRecord) are a multiple of the buffer size (that I set with FDwfAnalogInBufferSizeSet), but it is not the case.

May I ask for a quick example on how to use FDwfAnalogInStatusData16 to read both channels?

Thanks

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi @cfontana

The cdData specifies the number of samples to return and the idxData specifies the start index.

The only situation when you need idxData to be other than zero would be with recording capture, when the newly captured sample chunk would overflow the recording buffer. In this case you can get with one call the N samples which fit in your buffer and with a second call remaining samples starting with index N.

Share this post


Link to post
Share on other sites
  • 0

Dear attila, thank you for your quick answer!

I am acquiring using an analogue channel as the trigger in normal mode, with a sampling rate of 100 MHz.
According to the documentation I set

  • FDwfDigitalInAcquisitionMode to acqmodeSingle;
  • FDwfAnalogInTriggerSource to trigsrcDetectorAnalogIn;
  • FDwfAnalogInTriggerAutoTimeout to zero;
  • FDwfAnalogInBufferSize to N.

Would this mean that only the first N samples in the buffer would be written for each trigger? In this case I would have to poll the AD2 faster than the trigger rate.
Is this right?

Share this post


Link to post
Share on other sites
  • 0

Hi @cfontana

With single acquisition mode you should leave the idxData zero.
Use the FDwfAnalogInStatusData16 as FDwfAnalogInStatusData in the examples, having the idxData zero.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now