• 0
Mahito

Waveforms SDk Trigger delay from analog Out source

Question

Hi,

I'm recently working on the Waveforms SDK with the Analog Discovery 2. I manage to trigger my AnalogIn with the AnalogOut sinus that I generate. My aim is to acquire my sinus in order to calculate the phase shift.

Is there a way to get the delay between the start of the AnalogOut generation and the trigger pulse attached to it ?

Thank you.

Here is the code that I'm using :

FDwfAnalogOutNodeEnableSet(hdwf, 0, AnalogOutNodeCarrier, true);
FDwfAnalogOutNodeFunctionSet(hdwf, 0, AnalogOutNodeCarrier, funcSine);
FDwfAnalogOutNodeFrequencySet(hdwf, 0, AnalogOutNodeCarrier, 1000.0);
FDwfAnalogOutNodeAmplitudeSet(hdwf, 0, AnalogOutNodeCarrier, 1);    
FDwfAnalogOutNodeOffsetSet(hdwf, 0, AnalogOutNodeCarrier, 1);

FDwfAnalogOutRunSet(hdwf, 0, 2.0/1000.0);
FDwfAnalogOutRepeatSet(hdwf,0,0);

FDwfAnalogOutConfigure(hdwf, 0, true);

FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 0);
FDwfAnalogInChannelRangeSet(hdwf, 0, 5);
FDwfAnalogInBufferSizeSet(hdwf, 40);
FDwfAnalogInFrequencySet(hdwf, 10000.0);
FDwfAnalogInAcquisitionModeSet(hdwf, 0);
FDwfAnalogInTriggerSourceSet(hdwf, trigsrcAnalogOut1);
FDwfAnalogInTriggerTypeSet(hdwf, trigtypeTransition);

FDwfAnalogInConfigure(hdwf, 0, true);

  while(true){
        FDwfAnalogInStatus(hdwf, true, &sts);
        if(sts == DwfStateDone){
            break;
        }
    }
FDwfAnalogInStatusData(hdwf, 0, rgdSamples, 40); // This acquisition ins not starting at the offeset point but at the falling edge

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @Mahito

In your code you are generating 1kHz sine. With the run length set to 2ms it will generate trigger signal at this rate and repeat indefinitely (0).
With the scope you are capturing 40 samples at 10kHz, 4 sine periods.
The scope triggers on analogout/wavegen-1. The trigger type (level, condition...) is only relevant if you set the trigger source to detector-analogin.

The default trigger position is 0sec, at the middle of the capture.
If you want the trigger to be at the first captured sample, on the left, use samples/2/rate
FDwfAnalogInTriggerPositionSet(hdwf, 40.0/2/10000)

Share this post


Link to post
Share on other sites
  • 0
On 11/28/2019 at 3:24 PM, attila said:

Hi @Mahito

In your code you are generating 1kHz sine. With the run length set to 2ms it will generate trigger signal at this rate and repeat indefinitely (0).
With the scope you are capturing 40 samples at 10kHz, 4 sine periods.
The scope triggers on analogout/wavegen-1. The trigger type (level, condition...) is only relevant if you set the trigger source to detector-analogin.

The default trigger position is 0sec, at the middle of the capture.
If you want the trigger to be at the first captured sample, on the left, use samples/2/rate
FDwfAnalogInTriggerPositionSet(hdwf, 40.0/2/10000)

I tried this and it works thanks ! I still have a question, is the time between the wavegen start and the acquisition start is measurable ? Does the SDK allow to have such information ? For example if my signal has a frequency of 2Mhz and an acquisition sampling of 20Mhz, does the time between the acquisition start and the wavegen start is below the sampling rate ?

Thanks again

Share this post


Link to post
Share on other sites
  • 0

Hi @Mahito

The trigger setting takes in consideration the ADC/DAC delays and configures the capture to compensate these.

For trigger on analog inputs (detector-analog-in scope channel1/2) the FDwfAnalogInTriggerPositionStatus returns the trigger position, based on signal interpolation of the trigger level, triggering sample and the previous one, but you are not using such trigger.

image.thumb.png.b56f883939566eb53727729cbb57e756.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