Jump to content
  • 0

Waveform SDK setting AnalogIn Filter


alpanth

Question


	int st = 0;

    int fsfilter;
    st = FDwfAnalogInChannelFilterInfo(DWF.hdwf, &fsfilter);
    assert(st);

    if(IsBitSet(fsfilter, filterAverage))
    { 
        st = FDwfAnalogInChannelFilterSet(DWF.hdwf, 0, filterAverage);
        assert(st);

        FILTER filter;
        st = FDwfAnalogInChannelFilterGet(DWF.hdwf, 0, &filter);
        assert(st);

        assert(filter == filterAverage);
    }

Hi,

I am using ADP3450, where I am trying to set the average filter on channel 0 (first thing after opening the device).

It is always failing at the last assert when comparing the filter. Where it should be set to average but it is set to normal.

Is there something wrong with the code or what could be the problem here?

 

Best regards, Alex

 

 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hi @alpanth

Probably the sample rate (FDwfAnalogInFrequency) is at maximum, = system frequency (100MHz), and due to this decimate sampling is used instead of decimate. With external sampling clock (FDwfAnalogInSamplingSource) averaging is similarly changed to decimate.

Link to comment
Share on other sites

  • 0

Indeed thank you is there some indicator that i missed which would have pointed me to this? Or did I just miss it in the documentation?
Because just from the API calls / checking if it was set with the get method as recommended in the doc I could not know that the sample rate is initially at max. In turn "blocking" the average filter.

Edited by alpanth
Link to comment
Share on other sites

  • 0

Similar problem with "FDwfAnalogInChannelRangeSet" and Get.

I used the provided "analogin_acquisition.cpp" example and just called "FDwfAnalogInChannelRangeGet" after the Wait(2) to check if the range on channel 0 is actually set to 5 V.

But the range I get back is always 54.49315154 V.

Below part of the example with the get method added.

    // enable channels
    for(int c = 0; c < cChannel; c++){
        FDwfAnalogInChannelEnableSet(hdwf, c, true);
    }
    // set 5V pk2pk input range for all channels
    FDwfAnalogInChannelRangeSet(hdwf, -1, 5);
    
    // 20MHz sample rate
    FDwfAnalogInFrequencySet(hdwf, 20000000.0);
        
    // get the maximum buffer size
    FDwfAnalogInBufferSizeInfo(hdwf, NULL, &cSamples);
    FDwfAnalogInBufferSizeSet(hdwf, cSamples);
    
    rgdSamples = new double[cSamples];

    // configure trigger
    FDwfAnalogInTriggerSourceSet(hdwf, trigsrcDetectorAnalogIn);
    FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 10.0);
    FDwfAnalogInTriggerChannelSet(hdwf, 0);
    FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge);
    FDwfAnalogInTriggerLevelSet(hdwf, 1.0);
    FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive);

    // wait at least 2 seconds with Analog Discovery for the offset to stabilize, before the first reading after device open or offset/range change
    Wait(2);

    double range = 0;
    FDwfAnalogInChannelRangeGet(hdwf, 0, &range);
	printf("range: %f\n", range);

 

Link to comment
Share on other sites

  • 0

Hi @alpanth

Yes, the range and offset get returns the actually available full scale ADC range and the configured offset DAC voltage.
This is useful to know the reading resolution, where does the signal clip, to convert the samples to voltage units in case the 16bit data function is used...

image.png

Link to comment
Share on other sites

  • 0

Hi @attila,

right so in case of the ADP3450 there are only two ranges (~2V and ~50V), so two possible return values from the "FDwfAnalogInChannelRangeGet"?

Meaning there is no actual difference in setting a range of 5 or 50 V?

Link to comment
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
×
×
  • Create New...