• 0

Having trouble getting 16k samples from Analog In API function



I see in the specs that the max buffer size is over 16k points, but it seems that I can only get 8192 samples from this code. "FDwfAnalogInBufferSizeInfo" returns 8192.  How can I get the 16k samples?  I would like to get 16k samples for each ADC channel.  I am using the Analog Discovery 2. Thanks!

int main(int carg, char **szarg)
    HDWF hdwf;
    STS sts;
    double* rgdSamples;
    int cSamples;
    int cChannel;
    char szError[512] = { 0 };

    int channum = 0;

    cout << "hello world!";


    printf("Open automatically the first available device\n");
    if (!FDwfDeviceOpen(-1, &hdwf)) {
        printf("Device open failed\n\t%s", szError);
        return 0;

    // get the number of analog in channels
    FDwfAnalogInChannelCount(hdwf, &cChannel);

    // enable channels
    for (int c = 0; c < cChannel; c++) {
        FDwfAnalogInChannelEnableSet(hdwf, c, true);

    // set 5V pk2pk input range for all channels
    FDwfAnalogInChannelRangeSet(hdwf, channum, 5);

    // 10MHz sample rate
    FDwfAnalogInFrequencySet(hdwf, 10000000.0);

    // get the maximum buffer size
    FDwfAnalogInBufferSizeInfo(hdwf, NULL, &cSamples);
    FDwfAnalogInBufferSizeSet(hdwf, cSamples);

    // acquisition mode set added by Phil
    FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeSingle);

    rgdSamples = new double[cSamples];

    // configure trigger
    FDwfAnalogInTriggerSourceSet(hdwf, trigsrcNone);


    // start
    FDwfAnalogInConfigure(hdwf, 0, true);

    printf("Waiting for triggered or auto acquisition\n");
    do {
        FDwfAnalogInStatus(hdwf, true, &sts);
    } while (sts != stsDone);

    FDwfAnalogInStatusData(hdwf, channum, rgdSamples, cSamples);
    fopen_s(&gDatLog, "ADC_results.txt", "a");

    for (int i = 0; i < cSamples; i++)
        fprintf(gDatLog, "%lg\n", rgdSamples);

    // close the device

    return 0;

Link to post
Share on other sites

2 answers to this question

Recommended Posts

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