• 0
Daniel Rech

Analog Discovery 2 Trigger Setup Limitation --> 15ms?

Question

Hi,

I wrote a small programm to test the speed limitations of triggering and I have a problem:

After collecting data the setup for the next trigger takes 15ms.

 

The application I'm building requires to capture 10ms of data with 100000 Hz, so I want to capture 1000 samples. After that I only have 10ms to setup the next trigger.

The programm collects all the triggers with not too many samples. But if I capture more than 500 samples (5ms) then I start missing triggers. What can I do to do this high speed data acquisition with the Analog Discovery 2?

 

This is the cpp-Code I use:

 

#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "sample.h"

int bufferSize = 500;
// int bufferSize = 600;
// int bufferSize = 1000;

int terminate = 0;
void my_handler(int s) {
    terminate = 1;
}

int main(int carg, char **szarg) {
    signal (SIGINT, my_handler);

    HDWF hdwf;
    STS sts;

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

    FDwfAnalogInFrequencySet(hdwf, 100000.0);
    FDwfAnalogInBufferSizeSet(hdwf, bufferSize);

    FDwfAnalogInChannelEnableSet(hdwf, 0, true);
    FDwfAnalogInChannelRangeSet(hdwf, 0, 4.99);

    // disable auto trigger
    FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 0);
    // one of the analog in channels
    FDwfAnalogInTriggerSourceSet(hdwf, trigsrcExternal1);
    FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge);
    FDwfAnalogInTriggerChannelSet(hdwf, 1);
    FDwfAnalogInTriggerLevelSet(hdwf, 1.5);
    FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive);
    // wait for the offset to stabilize
    Wait(2);

    printf("Starting repeated acquisitions:\n");
    int iTrigger;
    for(iTrigger = 0; iTrigger < 200; iTrigger++){
        // begin acquisition
        FDwfAnalogInConfigure(hdwf, false, true);

        while(true){
            FDwfAnalogInStatus(hdwf, true, &sts);
            if(sts == DwfStateDone) {
                break;
            }
            if (terminate == 1) {
                break;
            }
        }
        if (terminate == 1) {
            break;
        }
    }
    printf("#%i\n", iTrigger+1);
    FDwfDeviceCloseAll();
}

 

Compile it with

gcc -ldwf trigger.c && ./a.out

 

It waits for triggers on external trigger source 1.

 

The only way I see to solve this is to not care about triggers and capture the whole signal but I would really like to solve it in a nice way.

Thank you for your replies :)

Daniel

Edited by Daniel Rech

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hello,

Starting with the WaveForms version 3.3.x the single mode acquisitions are automatically rearmed after done status with data read option.
This way, without the need to re-configure you should gain a few millisecond sparing for repeated acquisitions.

printf("Starting repeated acquisitions:\n");
FDwfAnalogInConfigure(hdwf, false, true);

int iTrigger;
for(iTrigger = 0; iTrigger < 200; iTrigger++){

  while(true){
    FDwfAnalogInStatus(hdwf, true, &sts);
    if(sts == DwfStateDone) {
 	  // analog in is rearmed for next acquistion
      break;
    }
  }
  FDwfAnalogInStatusData(hdwf,...
  ...

 

On the other hand, at 100kHz you should be able to record a large number of samples for further processing.

Edited by attila

Share this post


Link to post
Share on other sites
  • 0

I know, that I could use record mode but I need the triggers to clarify when the signal started and the application requires the 50Hz (== 20ms) rate.

Thank you for your response.

Right now we use 3.2.6 but I will try to get 3.3 running.

Share this post


Link to post
Share on other sites
  • 0

I get weird triggering behavior with the same code and 3.3 version. Not it seems that there are 400 triggers but my normal scope only shows 70 :(

Is there an API change in 3.3 that I missed?

Share this post


Link to post
Share on other sites
  • 0

Hi Attila, 

How  can we expect the system to behave if it is configured with both: 

FDwfAnalogInConfigure(hwdf, c_bool(True), c_bool(True))

FDwfAnalogInTriggerAutoTimeoutSet(hdwf, 0)

This seems to be contradictory by enabling the auto-trigger in the ...Configure command, then disabling the auto-trigger in the ...TimeoutSet command.

Thanks!

 

Share this post


Link to post
Share on other sites
  • 0

Hello,

Calling the AnalogInTriggerAutoTimeoutSet function after AnalogInConfigure will stop the acquisition.
First setup the instrument with the *Set functions, call *Configure to start it, wait for the acquisition using *Status.

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