Merging in most recent (?) version of source cpp

This commit is contained in:
Kumi 2024-02-07 11:47:02 +01:00
parent 1d67383111
commit c2ff68a5bc
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -13,7 +13,6 @@ $(h5c++ -show) limedriver.cpp -std=c++11 $(pkg-config --cflags --libs LimeSuite)
-o limedriver
*/
#include "H5Cpp.h"
#include "lime/LimeSuite.h"
#include <chrono>
@ -21,6 +20,7 @@ $(h5c++ -show) limedriver.cpp -std=c++11 $(pkg-config --cflags --libs LimeSuite)
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <sstream>
#include <stdio.h>
@ -51,6 +51,12 @@ struct LimeConfig_t {
int TX_gain;
int TX_IcorrDC;
int TX_QcorrDC;
int TX_IcorrGain;
int TX_QcorrGain;
int TX_IQcorrPhase;
int RX_IcorrGain;
int RX_QcorrGain;
int RX_IQcorrPhase;
int RX_gain_rback[4];
int TX_gain_rback[3];
@ -64,6 +70,16 @@ struct LimeConfig_t {
double *p_pha;
int *p_phacyc_N;
int *p_phacyc_lev;
double *am_frq;
double *am_pha;
double *am_depth;
int *am_mode;
double *am_frq_smp;
double *fm_frq;
double *fm_pha;
double *fm_width;
int *fm_mode;
double *fm_frq_smp;
int *p_c0_en;
int *p_c1_en;
@ -82,7 +98,7 @@ struct LimeConfig_t {
int averages;
int repetitions;
bool pcyc_bef_avg;
int pcyc_bef_avg;
double reptime_secs;
double rectime_secs;
int reptime_smps;
@ -93,6 +109,7 @@ struct LimeConfig_t {
string file_stamp;
string save_path;
int override_save;
int override_init;
string stamp_start;
string stamp_end;
@ -529,6 +546,40 @@ LimeConfig_t initializeLimeConfig(int Npulses,
return LimeCfg;
}
// Modulation function for AM/FM using different modes, i.e. sinusoidal (mode =
// 0), triangular (mode = 1), square (mode = 2)
double Modfunction(double argument, int mode) {
const double pi = acos(-1);
double P;
double retval;
switch (mode) {
case 0: { // sinusoidal
retval = cos(argument);
break;
}
case 1: { // triangular
// A = 2.0; P = np.pi
// y = (A/P) * (P - abs(np.mod(x+np.pi/2,2*P)-P)) - A/2
P = pi / 2;
retval = (2.0 / P) * (P - fabs(fmod(argument + pi / 2, 2 * P) - P)) - 1.0;
break;
}
case 2: { // square
retval = (fmod(argument, 2 * pi) < pi) ? 1.0 : -1.0;
break;
}
default: {
retval = 1.0;
break;
}
}
return retval;
}
int main(int argc, char **argv) {
const double pi = acos(-1);