I have written a small acquisition programm(in c), which should also be able to perform a fft.
My first question concerns the trigger:
Redpitaya is acquiring a signal on input 2. After the trigger condition happened( TRIG_NOW command), the buffer is read out and plotted. But in the plot i have a discontinuity around sample 8000, which i do not understand(see picture withoutsleep). I was able to avoid this problem by using the usleep command after the trigger happened(see picture withsleep). I know that, when the trigger happened, that a standard delay of 8192 samples is implemented. But I cannot explain what happens. The c-code is:
Code: Select all
/* Test program to acquire signals on a specified input */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "redpitaya/rp.h"
int main(int argc, char **argv) {
/* Initialization of API (important. Must be called first, before any other library method)*/
if (rp_Init()!=RP_OK){
printf("RedPitaya API init failed");
return EXIT_FAILURE;
}
/*only for testing*/
FILE *f;
f = fopen("test.txt", "w");
/*Defining variables*/
int32_t trig_delay = 0;
rp_channel_t source = RP_CH_2; /*Channel B*/
rp_acq_decimation_t acq_dec = RP_DEC_1; /*other dec: 8,64,1024,8192,65536*/
rp_acq_trig_src_t trig_state = RP_TRIG_SRC_NOW;
unsigned int acq_sleep = 132;
unsigned int cnt;
unsigned int musleep=1;
/*Defining Buffer, Data reader*/
uint32_t buff_size = 16384;
float *buff = (float *)malloc(buff_size * sizeof(float));
/*Acquisition part*/
rp_AcqReset();
rp_AcqSetDecimation(acq_dec);
rp_AcqSetTriggerDelay(trig_delay);
/*Start acquisition*/
rp_AcqStart();
usleep(acq_sleep);
/*Wait for trigger condition (while loop), here the trigger is set manually*/
rp_AcqSetTriggerSrc(trig_state);
usleep(musleep); % Must be implemented to avoid the discontinuity
rp_AcqGetOldestDataV(source,&buff_size,buff);
/*Write data in a file for testing*/
for(cnt=0; cnt<buff_size; cnt++){
fprintf(f,"%f \n", buff[cnt]);
}
/*Releases the library resources, must be called last*/
free(buff);
rp_Release();
fclose(f);
return EXIT_SUCCESS;
}
Thank you !
memoran