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:
// 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.)
Question
clf
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
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.dwf3scope
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.