From 220a3b94f5f45b4f149c677be2a249f7ae55ea27 Mon Sep 17 00:00:00 2001 From: c vw Date: Mon, 26 Oct 2020 20:12:38 +0100 Subject: [PATCH] Added impulse noise for noiseblanker testing --- hpsdrsim.c | 37 ++++++++++++++++++++++++++++++++++--- hpsdrsim.h | 3 ++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/hpsdrsim.c b/hpsdrsim.c index d6b9a37..c41659e 100644 --- a/hpsdrsim.c +++ b/hpsdrsim.c @@ -229,6 +229,7 @@ int main(int argc, char *argv[]) // seed value for random number generator seed = ((uintptr_t) &seed) & 0xffffff; diversity=0; + noiseblank=0; OLDDEVICE=DEVICE_ORION2; NEWDEVICE=NEW_DEVICE_ORION2; @@ -246,6 +247,7 @@ int main(int argc, char *argv[]) if (!strncmp(argv[i],"-audio", 6)) {do_audio=1;} if (!strncmp(argv[i],"-P1", 3)) {oldnew=1;} if (!strncmp(argv[i],"-P2", 3)) {oldnew=2;} + if (!strncmp(argv[i],"-nb", 3)) {noiseblank=1;} } switch (OLDDEVICE) { @@ -282,7 +284,20 @@ int main(int argc, char *argv[]) off += 0.016362461737446839783659600954581; } - if (diversity) { + // + // Use only one buffer, so diversity and + // noise blanker testing are mutually exclusive + // so diversity==0 means "no man-made noise", + // diversity==1 && noiseblank == 0 means "noise for testing diversity" + // diversity==1 && noiseblank == 1 means "noise for testing noise blanker" + // + if (noiseblank) diversity=1; + + if (diversity && !noiseblank) { + // + // The diversity signal is a "comb" with a lot + // of equally spaces cosines + // fprintf(stderr,"DIVERSITY testing activated!\n"); fprintf(stderr,".... producing some man-made noise\n"); memset(divtab, 0, LENDIV*sizeof(double)); @@ -307,6 +322,18 @@ int main(int argc, char *argv[]) divtab[i]=divtab[i]*off; } } + + if (diversity && noiseblank) { + // + // Create impulse noise as a real-time signal + // 5 impulses per second + // + memset(divtab, 0, LENDIV*sizeof(double)); + fprintf(stderr,"NOISE BLANKER test activated\n"); + for (i=0; i<5; i++) { + for (j=9600*i; j< 9600*i+100; j++) divtab[j]=1.0; + } + } // // clear TX fifo @@ -1285,11 +1312,15 @@ void *handler_ep6(void *arg) pointer += 8; memset(pointer, 0, 504); fac1=rxatt_dbl[0]*0.0002239; // Amplitude of 800-Hz-signal to ADC1 - if (diversity) { + if (diversity && !noiseblank) { fac2=0.0001*rxatt_dbl[0]; // Amplitude of broad "man-made" noise to ADC1 fac4=0.0002*rxatt_dbl[1]; // Amplitude of broad "man-made" noise to ADC2 // (phase shifted 90 deg., 6 dB stronger) } + if (diversity && noiseblank) { + fac2=0.001; + fac4=0.0; + } for (j=0; j