logo
Most Viewed Last 7 Days
This bit is broken!!! (7)
(7)
(7)
(7)
(7)
(7)

ALL


Cluster Activity

Spots per uW band today:
UK spotter or spotted only.

Solar data:
SFI
67
A-Index
11
K-Index
4
Exp.K
0
Sunspots
15
Activity
qui
GMF
act
Aurora?
no

My Weather

Date:01/01/70 Time:01:00
Temp:C
Wind Speed:0mph
Wind Dir:deg
Pressure:0mB
Humidity:%
Dew Point:-20C
UKHASnet

//Weaver SSB Demod made with my little knowledge of sdr so far.....
//Reads complex samples from standard input at 32KHz and writes demodulated 'real' samples to standard output
//
// to compile: gcc ssbdemod.c -o ssbdemod -lm
//
//rob@m0dts.co.uk
//
//September 2015

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define taps 99

//Coefficients made with http://www.arc.id.au/FilterDesign.html
//LPF 1.4KHz, SR=32k, Atten 60dB, 99 points



float coeff[taps] ={0.000104, 0.000107, 0.000084, 0.000024, -0.000076
, -0.000218, -0.000397, -0.000599, -0.000804, -0.000984, -0.001107, -
0.001139, -0.001046, -0.000803, -0.000394, 0.000180, 0.000898,
0.001720, 0.002582, 0.003402, 0.004084, 0.004525, 0.004625, 0.004295,
0.003474, 0.002136, 0.000300, -0.001964, -0.004530, -0.007218, -
0.009806, -0.012034, -0.013624, -0.014299, -0.013805, -0.011932, -
0.008534, -0.003551, 0.002985, 0.010937, 0.020069, 0.030052, 0.040479
, 0.050888, 0.060791, 0.069702, 0.077169, 0.082804, 0.086310,
0.087500, 0.086310, 0.082804, 0.077169, 0.069702, 0.060791, 0.050888,
0.040479, 0.030052, 0.020069, 0.010937, 0.002985, -0.003551, -
0.008534, -0.011932, -0.013805, -0.014299, -0.013624, -0.012034, -
0.009806, -0.007218, -0.004530, -0.001964, 0.000300, 0.002136,
0.003474, 0.004295, 0.004625, 0.004525, 0.004084, 0.003402, 0.002582,
0.001720, 0.000898, 0.000180, -0.000394, -0.000803, -0.001046, -
0.001139, -0.001107, -0.000984, -0.000804, -0.000599, -0.000397, -
0.000218, -0.000076, 0.000024, 0.000084, 0.000107, 0.000104};


void main(void){


int n,i,ptr,ptr2,sample_rate,oscsamples;
float m1,m2,*osci,*oscq,*bufi,*bufq,osc,outbuf,inbuf[2],If,Qf;

osc = 1500;
sample_rate = 32000;
oscsamples = sample_rate/(int)osc;

//allocate memory for IQ oscillator lookup table
osci= malloc(oscsamples * sizeof(float));
oscq= malloc(oscsamples * sizeof(float));

//Allocate memory for circular input sample buffer, seperate streams
bufi= malloc(taps * sizeof(float));
bufq= malloc(taps * sizeof(float));

//Create lookup samples for one cycle of weaver oscillator.....
for(n=0;n<oscsamples;n++){
osci[n]=sin((2*M_PI)*osc/sample_rate*n);
oscq[n]=cos((2*M_PI)*osc/sample_rate*n);
}


//Loop to read in Complex samples, low pass filter,demodulate SSB,output Real samples
n=0;
ptr=0;
while(1){
//Read pair of samples
fread(&inbuf,sizeof(float),2,stdin);
//Split I and Q samples into two buffer streams
bufi[ptr]= inbuf[0];
bufq[ptr]= inbuf[1];
ptr++;
if(ptr==taps){ptr=0;}


//Multiply input samples with coefficients and sum
If=0;
Qf=0;
ptr2=ptr;
for(i=0;i<taps;i++){
//filter I and Q stream separately with same coefficients
If += bufi[ptr2]* coeff[i];
Qf += bufq[ptr2]* coeff[i];
ptr2++;
if(ptr2==taps){ptr2=0;}
}


//Weaver Mix, Add
m1 = If * osci[n];
m2 = Qf * oscq[n];

outbuf = m1 + m2; // +/- for USB/LSB
outbuf /=10;

n++;
if(n==oscsamples){n=0;} //buffer pointer reset

//Write single sample, real value now
fwrite(&outbuf,sizeof(float),1,stdout);

}

}















Last page added:25/03/00 18:32
M0DTS.co.uk