I'm trying to implement the Signal Acquiring at 125 Msps > Synchronized one pulse generating and acquiring example in C.
I basically translated the SCPI commands from the Matlab example to API functions in C.
Here's the relevant code: (I define a function Initialize to set up the measurement and run it in the main function as follows)
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "redpitaya/rp.h"
void Initialize()
// Initialize acquisition and signal generation for VNA
{
rp_AcqReset();
rp_GenReset();
rp_GenWaveform(RP_CH_1,RP_WAVEFORM_SINE);
rp_GenMode(RP_CH_1,RP_GEN_MODE_BURST);
rp_GenBurstRepetitions(RP_CH_1,200);
//rp_AcqSetTriggerSrc(RP_TRIG_SRC_AWG_PE);
rp_GenOutEnable(RP_CH_1);
rp_AcqSetDecimation(RP_DEC_1024);
rp_AcqSetTriggerLevel(0.0);
rp_AcqSetTriggerDelay(8192);
}
void InOut(float Freq, float Amp)
{
rp_acq_trig_state_t trig_state;
Initialize();
rp_GenAmp(RP_CH_1,Amp);
rp_GenFreq(RP_CH_1,Freq);
rp_AcqStart();
usleep(10);
rp_AcqSetTriggerSrc(RP_TRIG_SRC_AWG_PE);
// Trigger measurement
//usleep(100);
int n=0;
//usleep(1000);
printf("%d\n",RP_TRIG_STATE_TRIGGERED);
printf("%d\n",RP_TRIG_STATE_WAITING);
rp_GenTrigger(1); // Send a trigger to generator on Channel 1
while (1) { // Wait for trigger
rp_AcqGetTriggerState(&trig_state);
if (trig_state == RP_TRIG_STATE_TRIGGERED) break;
usleep(10); // Sleep for 100 usecs.
n++;
if (!(n%100)) printf("%f %d %d\n",Freq,n,trig_state);
}
rp_AcqGetOldestDataV(RP_CH_1, &buff_size, buff);
}