Jump to content
  • 0

generating and reading a custom signal


ssm

Question

Dear Help, 

I am generating a custom signal using WaveGen, apply it to DUT and then reading the result using the scope. I know that the speed/rate at which I am reading is limited by the USB and it is recommended not to go beyond 1M. I assumed I am going to lose few samples here and there, but the problem is that I am losing a big chunk of data which it seems more like a sync issue.

Here is the generated signal:

image.png.b9358de6fe117b2570d8db282653578c.png

and here is the signal I am reading:

image.png.12106d2ad06e23159256232677033b9f.png

Is there a way to properly sync the AnalogIn and the AnalogOut to avoid such a problem? I am using the AnalogIn to trigger the scope.

here is the relevant part of the code to configure the scope:

  1.                     // enable scope channels
  2.                     FDwfAnalogInChannelEnableSet(hdwf, -1, true);
  3.                     //FDwfAnalogInChannelEnableSet(hdwf, 1, true);
  4.                     FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeSingle);
  5.                     FDwfAnalogInChannelRangeSet(hdwf, -1, 2);
  6.                     // sample rate
  7.                     FDwfAnalogInFrequencySet(hdwf, EXP->SampleRates[expNumber]);
  8.                     FDwfAnalogInBufferSizeSet(hdwf, AD2ScopeBufferSize);
  9.                     FDwfAnalogInChannelOffsetGet(hdwf, 0, &pvoltInOffsetC0);
  10.                     FDwfAnalogInChannelOffsetGet(hdwf, 1, &pvoltInOffsetC1);
  11.                     // configure trigger
  12.                     FDwfAnalogInTriggerSourceSet(hdwf, trigsrcDetectorAnalogIn);
  13.                     FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 10.0);
  14.                     FDwfAnalogInTriggerTypeSet(hdwf, trigtypeTransition);
  15.                     FDwfAnalogInTriggerLevelSet(hdwf, 0.0);
  16.                     FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive);
  17.                     FDwfAnalogInChannelFilterSet(hdwf, -1, filterAverage);
  18.                     // wait at least 2 seconds with Analog Discovery for the offset to stabilize, before the first reading after device open or offset/range change
  19.                     FDwfAnalogInConfigure(hdwf, true, false);
  20.                     Wait(EXP->SetupWaitingTime[expNumber]);

here is the wavegen configuration:

FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true);

  1.                     // set custom function
  2.                     FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcCustom);
  3.                     // get channel offset
  4.                     FDwfAnalogOutNodeOffsetGet(hdwf, 0, AnalogOutNodeCarrier, &pvoltOutOffset);
  5.                     // set custom waveform samples, normalized to ±1 values
  6.                    FDwfAnalogOutNodeDataSet(hdwf, 0, AnalogOutNodeCarrier, InputFileSamples, NoSamplesInFile);
  7.                    FDwfAnalogOutNodeFrequencySet(hdwf, 0, AnalogOutNodeCarrier, EXP->CustomSignalFreq[expNumber]);
  8.                    FDwfAnalogOutNodeAmplitudeSet(hdwf, 0, AnalogOutNodeCarrier, EXP->MaxVdd[expNumber]);
  9.                     FDwfAnalogOutRepeatSet(hdwf, 0,EXP->RepeatedTimes[expNumber]);
  10.                     FDwfAnalogOutConfigure(hdwf, 0, true);
  11.                     Wait(EXP->SetupWaitingTime[expNumber])

this is the Acquisition code:

  1.                    // begin acquisition
  2.                     FDwfAnalogInConfigure(hdwf, false, true);
  3.                     FDwfAnalogOutConfigure(hdwf, 0, true);
  4.                     while(true){
  5.                         FDwfAnalogInStatus(hdwf, true, &sts);
  6.                             if(sts == DwfStateDone) {
  7.                                 break;
  8.                             }
  9.                         //Wait(0.001);
  10.                     }
  11.                     FDwfAnalogInConfigure(hdwf, false, false);
  12.                     FDwfAnalogOutConfigure(hdwf, 0, false);
  13.                     FDwfAnalogInStatusData(hdwf, 0, EXP->ScopeC0Samples, AD2ScopeBufferSize);
  14.                     FDwfAnalogInStatusData(hdwf, 1, EXP->ScopeC1Samples, AD2ScopeBufferSize);

Note that this problem is happening only at certain sampling frequencies, even >2M still things are working.

the scope buffer here is 8192 and wavegen buffer is 4096,

sampling rate is 4194304 for the scope, and 1024 or 4194304/4096 for the wavegen signal 

thank you for the help

ssm

Example of out of sync signal:

image.png.b92c816f31219ca39829eb79014b06b3.png

example of part of the signal is gone:

image.png.7cc541b332dcec513720ea644ab08c91.png

here I used a very short pulse (5 sample points) at the start of the custom signal to trigger the AnalogIn, but this pulse is dragged for a long time, not sure why:

image.png.986372d1ea847ecb01d274bf1942b5ec.png

 

 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

Hi @ssm

The FDwfAnalogOutNodeFrequency for standard and custom waveform = 1 / the entire waveform period
If you have a custom waveform with 2000 samples and specify 1kHz, the sample rate will be 2MHz.

By default the signal will be generated continuously until stopped, the run time is 0 (infinite)
If you want to have finite repeat time first you should specify a run time, like:
FDwfAnalogOutRunSet(hdwf, 0, 1.0/secPeriod secPeriod)
FDwfAnalogOutRepeatSet(hdwf, 0, 100)
You can also specify trigger, wait...

image.thumb.png.0ebd76d0e6f502656a1795565135ce22.png

Link to comment
Share on other sites

Hi @ssm

The acquisition rate is limited only for recording. Normal captures up to 8/16ki with AD can go up to 100MHz.
You are missing the: FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true)
The custom waveform should be normalized to +/-1 values
Note the FDwfAnalogOutNodeFrequencySet refers to the waveform period and not sample rate.
The FDwfAnalogInConfigure(hdwf, false, false); at the end is not required.
The wait is only recommended before performing the first capture, after connecting to the device or changing the offset level in order this to settle.

Link to comment
Share on other sites

>> The acquisition rate is limited only for recording. Normal captures up to 8/16ki with AD can go up to 100MHz.

so I understand from this I should not have any missing samples
>> You are missing the: FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true)

I added this part, missed few lines of code there
>> The custom waveform should be normalized to +/-1 values

they are normalized
>> Note the FDwfAnalogOutNodeFrequencySet refers to the waveform period and not sample rate.

this part still not very clear, is it how many times the uploaded signal is repeated?
>> The FDwfAnalogInConfigure(hdwf, false, false); at the end is not required.

I will take it out
 

thank you again for your help

Link to comment
Share on other sites

I am still getting shifted or out of sync problems, sometimes a chunk of the signal is gone. I added pictures in the main question,

Is there a way to fix this issue or I just have to live with it?

thank you for the help

 

Link to comment
Share on other sites

Hi @ssm

The analog-out could be stopped, restarted... I don't know how much run time have you specified, use:
FDwfAnalogOutRunSet(hdwf, 0, 1.0 / EXP->CustomSignalFreq[expNumber])

The out-in you can synchronize with:
FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1)

Relative to middle, zero is middle of capture:
FDwfAnalogInTriggerPositionSet(hdwf, 0)

Trigger to be on the left of the capture use:
FDwfAnalogInTriggerPositionSet(hdwf, 0.5 * AD2ScopeBufferSize / EXP->SampleRates[expNumber] )

Link to comment
Share on other sites

the mistake was here:

FDwfAnalogInTriggerSourceSet(hdwf, trigsrcDetectorAnalogIn);

not sure why I used trigsrcDetectorAnalogIn instead of trigsrcAnalogOut1

FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1)

working perfectly now.

thanks a million for the great help

ssm

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...