Generating pulses with RP

Applications, development tools, FPGA, C, WEB
Post Reply
Program
Posts: 27
Joined: Thu Apr 14, 2016 3:14 pm

Generating pulses with RP

Post by Program » Fri May 06, 2016 8:19 am

Hi there, how exactly does the generation of signals (in particular pulses of arbitrary shape) work in Red Pitaya and what are its limitations? My aim is to generate a single square pulse that starts at 0 V, rises as rapidly as possible, lasts for about 100ns (not sure whether such a short duration is possible) and then returns to 0 V. What are the limitations of the RP with regards to the rise time of such a square signal? I've been experimenting with the arbitrary waveform functions of the API, but I am not getting the results I want. As a first step, I would like to know how exactly signal generation is implemented in the FPGA and how this relates to the API functions. As I understand it, the digital signal shape is stored in the generate buffer of the FPGA and this buffer is then converted to an analog signal at the chosen frequency (so the whole buffer is read out with a frequency of up to 62.5 MHz). When is the signal generation started, though? As soon as rp_GenOutEnable is called or when rp_GenTriggerSource is set? Also, does the conversion start from the first element of the buffer or from wherever the pointer happened to end up the last time a signal was generated?
I tried to produce a single burst of a square wave (see code below), but instead of producing just one waveform, it generates continuous output. I assumed that whenever the trigger happens, the buffer would be output exactly one time and then the voltage level should return to 0 V. However, it doesn't. I think the online API library is not very clear in its explanations, so if anyone could answer my questions, I would appreciate it very much.

Code: Select all

#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <sys/param.h>

#include "redpitaya/rp.h"
#include "main.h"

int main();
{
	if(rp_Init() != 0){
		fprintf(stderr, "RP API init failed\n");
	}

	rp_GenReset();
        
	rp_GenAmp(RP_CH_1, 1.0);
	rp_GenFreq(RP_CH_1, 10000);
        rp_GenWaveform(RP_CH_1, RP_WAVEFORM_SQUARE);
        rp_GenMode(RP_CH_1, RP_GEN_MODE_BURST);
        rp_GenBurstCount(RP_CH_1, 1);
        rp_GenBurstRepetitions(RP_CH_1, 1);
	rp_GenTriggerSource(RP_CH_1, RP_GEN_TRIG_SRC_INTERNAL);
	rp_GenOutEnable(RP_CH_1);
	
	rp_Release();
	
	return 0;
}

jerzydziewierz
Posts: 31
Joined: Mon Mar 28, 2016 1:10 pm

Re: Generating pulses with RP

Post by jerzydziewierz » Sat May 07, 2016 10:23 am

Hi,
I have not tried this myself yet, but in the http://libdoc.redpitaya.com/rp_8h.html , you can see that rp_trig_src_t defines that it should be possible to trigger the generation once from an external signal,

there is a "rp_acq_trig_src_t" RP_TRIG_SRC_NOW but i guess it only applies to acqusition,

otherwise it looks that you might have to implement a "single trigger" on generation yourself, or get someone to do it . . .

Jurek

lvillasen
Posts: 4
Joined: Thu Nov 26, 2015 9:13 pm

Re: Generating pulses with RP

Post by lvillasen » Wed May 25, 2016 10:34 pm

Hello,

If you comment out the line
rp_GenTriggerSource(RP_CH_1, RP_GEN_TRIG_SRC_INTERNAL);
it generates bursts that start when
rp_GenOutEnable(RP_CH_1);
is executed.

However, the following code produces better results :

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "redpitaya/rp.h"
int main(int argc, char **argv){
/* Burst count */
/* Print error, if rp_Init() function failed */
if(rp_Init() != RP_OK){
fprintf(stderr, "Rp api init failed!\n");
}
int buff_size = 16384;
float *x = (float *)malloc(buff_size * sizeof(float));
// one pulse of width= 980/16384 *1us = 59 ns
for (int i = 0; i < buff_size; ++i){
if (i> 20 && i<1000) x = 1.;
else
x = 0;
}
rp_GenArbWaveform(RP_CH_1, x, buff_size);
rp_GenWaveform(RP_CH_1, RP_WAVEFORM_ARBITRARY);
rp_GenFreq(RP_CH_1, 1000000); // whole buffer corresponds to 1 us
rp_GenAmp(RP_CH_1, 1.0);
rp_GenMode(RP_CH_1, RP_GEN_MODE_BURST);
rp_GenBurstCount(RP_CH_1, 3); // we produce 3 such pulses
rp_GenBurstRepetitions(RP_CH_1, 2); // repeated twice
rp_GenBurstPeriod(RP_CH_1, 20); // within 20 us
rp_GenOutEnable(RP_CH_1);
rp_Release();
}

I hope this helps.
Luis

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 5 guests