• 0
clf

Waveforms SDK: analogout_custom: Unexpected AWG duration, repetition, and phase shift

Question

Hello All,

I'm playing around with the "analogout_custom" C sample program that comes with the Waveforms SDK (/usr/share/digilent/waveforms/samples/c/analogout_custom.cpp).  I've made some observations that don't align with my expectations.  I'm hoping one (or more) of you could kindly offer some insight on what is happening.

I'm running libdwf.so.3.4.7 on an Ubuntu 16.04 x86-64 machine.  I have an Analog Discovery 1 and an Analog Discovery 2 wired such that

  • ad1.aout1 --> ad2.ain1+
  • ad1.gnd --> ad2.ain1-

I'm playing the waveform out through the Analog Discovery 1 and the "analogout_custom" program.  I'm capturing the resulting waveform through the Analog Discovery 2 and the Waveforms 2015 oscilloscope.

I've attached my Waveforms 2015 oscilloscope configuration file.  I've also attached a screenshot of the Waveforms 2015 oscilloscope showing the results of two runs of "analogout_custom".  Channel 1 (yellow) displays the waveform produced by my most recent run of "analogout_custom".  Reference 1 (gray) displays a waveform that was captured on Channel 1 during a prior invocation of "analogout_custom" and saved off as a reference waveform.

Expectations:

1) A waveform consisting of 4096 samples played at 10 kHz should have a duration of ~0.5 seconds.

2) The waveform should play once, given the default of AnalogOutRepeat = 1.

3) The waveform should begin playing at the first sample, which always has the same value.

4) The generated waveform should be consistent for all invocations of "analogout_custom".

Unexpected observations:

1) The waveform has a duration of ~1.8 seconds, as highlighted by the cursors' delta X in the oscilloscope screenshot.

2) The waveform plays more than once, as indicated by the multiple peaks on the yellow waveform in the oscilloscope screenshot.

3) The waveform does not begin playing at the first sample, as indicated by the different values at x=0 for the yellow and gray waveforms.

4) The played waveform is not consistent between invocations, as indicated by the yellow and gray waveforms not aligning.

Here's the "analogout_custom.cpp" source code for your convenience:

#include "sample.h"
int main(int carg, char **szarg){
    HDWF hdwf;
    double rgdSamples[4096];
    char szError[512] = {0};

    // generate custom samples normalized to +-1
    for(int i = 0; i < 4096; i++) rgdSamples = 2.0*i/4095-1;

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

    }

    printf("Generating custom waveform for 5 seconds...");
    // enable first channel
    FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true);
    // set custom function
    FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcCustom);
    // set custom waveform samples
    // normalized to ±1 values
    FDwfAnalogOutNodeDataSet(hdwf, 0, AnalogOutNodeCarrier, rgdSamples, 4096);
    // 10kHz waveform frequency
    FDwfAnalogOutNodeFrequencySet(hdwf, 0, AnalogOutNodeCarrier, 10000.0);
    // 2V amplitude, 4V pk2pk, for sample value -1 will output -2V, for 1 +2V
    FDwfAnalogOutNodeAmplitudeSet(hdwf, 0, AnalogOutNodeCarrier, 2);
    // by default the offset is 0V
    // start signal generation
    FDwfAnalogOutConfigure(hdwf, 0, true);
    // it will run until stopped or device closed
    Wait(5);
    printf("done\n");
    // on close device is stopped and configuration lost
    FDwfDeviceCloseAll();
}

Thanks in advance!

Chris

(This is a repost. Original post somehow ended up in Home > Digilent Technical Forums > Scopes & Instruments > WaveForms Live and OpenScope feedback.)

analogout_custom_libdwf.so.3.4.7_unexpected_period_unexpected_repeat_unexpected_phase_shift.png

analogout_custom.dwf3scope

Edited by clf

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1

Hi @clf

The frequency defines the custom waveform frequency and not the sample rate.
Probably you have unchecked the default Noise option in Scope and the 800Hz acquisition rate hides/interferes with the generated 10kHz slopes.

To have 10kHz sample rate set the frequency to sample rate / number of samples, 10kHz/4k.
To have 0.5sec waveform period set frequency to 2Hz.

Share this post


Link to post
Share on other sites
  • 0

Thanks @attila.  I was looking at a time scale that was off by orders of magnitude.  I hadn't realized the frequency parameter had different meanings for "funcCustom" (frequency = repeat rate of waveform) versus "funcPlay" (frequency = sample rate).  This fact is mentioned, though, in the the SDK Reference Manual's entry for FDwfAnalogOutNodeFrequencyInfo().

For anybody curious, I've attached Waveforms 2015 oscilloscope screenshots of the AWG "funcCustom" and "funcPlay" renderings for the same sample vector.  Screenshot "awg_custom_[...]" was produced using the "analogout_custom" C sample program mentioned earlier, and shows the entire waveform repeating at frequency=10kHz.  Screenshot "awg_play_[...]" was produced by a slightly modified version of the "analogout_custom" program, where "funcCustom" was replaced with "funcPlay", and shows the samples being output at frequency=10kHz.

Chris

awg_play_generates_samples_at_10kHz.png

awg_custom_repeats_waveform_at_10kHz.png

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