Signal acquiring on fast ADC using external trigger

Applications, development tools, FPGA, C, WEB
Post Reply
heliosh
Posts: 2
Joined: Sat Aug 20, 2016 1:20 pm

Signal acquiring on fast ADC using external trigger

Post by heliosh » Sat Aug 20, 2016 1:25 pm

Hi,

I was looking for a code example:
http://redpitaya.com/examples-new/on-gi ... log-input/

But the example for C is missing.


Thank you

Edit: Ok, i found the API description. Just one question:
How long does it take after the trigger until the adc data is read into the buffer?

Nils Roos
Posts: 1441
Joined: Sat Jun 07, 2014 12:49 pm
Location: Königswinter

Re: Signal acquiring on fast ADC using external trigger

Post by Nils Roos » Sat Aug 20, 2016 11:06 pm

Hi,

there's also some C examples on github in the RedPitaya/Examples/C directory.
How long does it take after the trigger until the adc data is read into the buffer?
While the scope is waiting for a trigger, all incoming samples are recorded into the buffer immediately. When the trigger happens, the scope will continue recording samples in that fashion until the trigger delay is over, then stop.
The delay between "sample available" and "sample in buffer" is about 20ns.

DrBeauWebber
Posts: 7
Joined: Sun Jan 29, 2017 8:32 am

Re: Signal acquiring on fast ADC using external trigger

Post by DrBeauWebber » Wed Apr 19, 2017 12:32 pm

I am trying to do the same thing, capture fast ADC data, on receipt of a digital trigger :

I have two quadrature channels of baseband signal from the output of my NMR receiver connected to CH1 & CH2 inputs of the Red Pitaya.
And the digital trigger from the NMR pulse programmer connected to PL_DIO0_P (E1 pin 3)

Using the Web Oscilloscope Pro this triggers, captures and displays fine :

Image

Turning that off, and using the example
In :
/opt/redpitaya/examples
Where there is a C/API example for triggered fast ADC capture (single channel)
acquire_trigger_posedge.c
I have modified it to look for an external logic level negative edge trigger :
rp_AcqSetTriggerLevel(1.0);
rp_AcqSetTriggerSrc(RP_TRIG_SRC_EXT_NE);

It captures fine, and returns data,
But it never waits for the trigger - it always returns randomly captured data, after the default 1 s delay,
even if I turn the trigger off, or say set it to one pulse every 10 s.
Does anyone know where the problem may lie ? Is it looking at the correct trigger source ?
cheers, Beau

User avatar
redpitaya
Site Admin
Posts: 907
Joined: Wed Mar 26, 2014 7:04 pm

Re: Signal acquiring on fast ADC using external trigger

Post by redpitaya » Wed Apr 19, 2017 4:20 pm

Hi,

First check if you are using latest OS version.
How to prepare SD card version with latest OS is described here.
http://redpitaya.readthedocs.io/en/late ... Dcard.html
use stable release.

Second, make sure you are following this instructions for building and running C examples.
http://redpitaya.readthedocs.io/en/late ... /comC.html

Here is the example which is working for me. Acquisition on external DIGITAL trigger.

Code: Select all

/* Red Pitaya C API example Acquiring a signal from a buffer  
 * This application acquires a signal on a specific channel */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "redpitaya/rp.h"

int main(int argc, char **argv){

        /* Print error, if rp_Init() function failed */
        if(rp_Init() != RP_OK){
                fprintf(stderr, "Rp api init failed!\n");
        }

        /*LOOB BACK FROM OUTPUT 2 - ONLY FOR TESTING*/
        rp_GenReset();
        rp_GenFreq(RP_CH_1, 20000.0);
        rp_GenAmp(RP_CH_1, 1.0);
        rp_GenWaveform(RP_CH_1, RP_WAVEFORM_SINE);
        rp_GenOutEnable(RP_CH_1);


        uint32_t buff_size = 16384;
        float *buff = (float *)malloc(buff_size * sizeof(float));

        rp_AcqReset();
        rp_AcqSetDecimation(RP_DEC_1);
        //rp_AcqSetTriggerLevel(RP_CH_1, 0.3);
        rp_AcqSetTriggerDelay(0);

        rp_AcqStart();

        /* After acquisition is started some time delay is needed in order to acquire fresh samples in to buffer*/
        /* Here we have used time delay of one second but you can calculate exact value taking in to account buffer*/
        /*length and smaling rate*/

        sleep(1);
        rp_AcqSetTriggerSrc(RP_TRIG_SRC_EXT_PE);
        rp_acq_trig_state_t state = RP_TRIG_STATE_TRIGGERED;

        while(1){
                rp_AcqGetTriggerState(&state);
                if(state == RP_TRIG_STATE_TRIGGERED){
                break;
                }
        }
       
        rp_AcqGetOldestDataV(RP_CH_1, &buff_size, buff);
        int i;
        for(i = 0; i < buff_size; i++){
                printf("%f\n", buff[i]);
        }
        /* Releasing resources */
        free(buff);
        rp_Release();
        return 0;

}


Notice that trigger level line is commented since external trigger is a digital one so only trigger edge can be defined.
Also note that max. voltage on external trigger pin is +3.3V. Direct 5V digital signals may damaged the board.

Kind Regards, Zumy

DrBeauWebber
Posts: 7
Joined: Sun Jan 29, 2017 8:32 am

Re: Signal acquiring on fast ADC using external trigger

Post by DrBeauWebber » Wed Apr 19, 2017 5:17 pm

Much appreciated Zumy,
I will work through what you say.
cheers, Beau

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 35 guests