[hpsdr] Software development

David McQuate mcquate at sonic.net
Thu Feb 19 17:45:26 PST 2009


Paul & Alberto, and any others interested in understanding / working on 
PowerSDR--

Here's a bit of info in reply to your questions.
I've been reading the code, and asking occasional questions, hoping, as 
you do,
to be able to contribute to the HPSDR projects.

First, the "official" compiler (etc.) is Microsoft Visual Studio 2003.
PowerSDR is written in C#, with many of the lower-level functions in C.
I've been attempting to use VS 2005.  I'm able to compile & run, but 
there are
some problems with restrictions on inter-thread interactions in 2005 
that cause
"fatal" execptions, whereas it works without problem in the 2003 version.
(As compiled by Bill Tracey)
I've found ugly work-arounds that allowed me to continue.  I'm also 
looking (on ebay)
for a copy of the 2003 version.
The 2005 version also seems to eat up more CPU cycles, and has some "issues"
pertaining to serial ports.

The current source for PowerSDR is found at
svn://206.216.146.154/svn/repos_sdr_windows/PowerSDR/branches/kd5tfd/PennyMerge/Source

Here's a sketch of some of the function calls involved in setting up the 
data flow--
Console calls Audio.Start() in file console/audio.cs,
which calls StartAudio() in file HPSDR / JanusAudio.cs
which calls StartAudioNative(), in the JanusAudio.dll.
One of the arguments in this call is the name of a call-back function.
The function used depends on your hardware.  For HPSDR with Mercury, it is
Callback4Port(), in console/audio.cs

StartAudioNative() calls pthread_create(), starting a thread which 
executes IOThreadMain(),
in JanusAudio/io-thread.c

IOThreadMain() calls IOThreadMainLoop(), which runs repeatedly calls
OzyBulkRead(), which is in file OzyIO.c, and which calls 
usb_bulk_read(), in file libUSB.dll.
A block of 512 bytes is retuned.

IOThreadMainLoop() parses the 512-byte buffer,
and converts the samples to 32-bit integers.
The buffer contains "sync" characters, "command and control" bytes,  
24-bit samples from
Mercury's ADC, filtered, frequency-shifted, and down-converted.  and 
some 16-bit Mic samples.

The structure of these 512-byte "frames" is descibed in
svn://206.216.146.154/svn/repos_sdr_hpsdr/trunk/Documentation

This document also descibes the 512-byte block or frame that is sent to 
Mercury, via Ozy
and usb.  There's a different set of "command and control" bytes, which 
include
switching Mercury's preamp (actually the attenuator), setting the sample 
rate, the frequency, etc.

IOThreadMainLoop() then calls Callback_ProcessBuffer() in file 
callback-thread.c.
This function converts the integers to 32-bit floats & de-interleaves 
the I & Q samples.
It divides the Mic data by 32767 to produce data in the -1 to +1 range, 
placing the data in
the float array CallbackMicLbufp[].  It re-samples this data to 48000 & 
sets the R channel
data to be the same as the L channel.

  It divides the I & Q data by IQConversionDivisor, which is set in 
PowerSDR-Interface.c
to be the float value (2^23  - 1).  Thus I & Q data are also in the 
range -1 to +1.  The scaled
samples are placed in CallbackInLbufp[] and CallbackInRbufp[].  Pointers 
to these float
arrays are placed in callback_in[].  Appropriate pointers are placed in 
a second array of pointers
callback_out[], for the "output"  --

It then calls the callback function mentioned many lines above, 
Callback4Port()
This function calls an entry point in DttSP, which exchanges input & 
output data.
In this way, in a single call, DttSP receives new data, and it returns 
the results of the
processing it did on the previous set of data.  The results include 
de-modulated audio,
which the callback function places in a FIFO so that it can be sent back 
to Mercury , where it is processed
by a pulse-width modulation scheme which acts as a digital to analog 
converter.  The filtered
result appears at Mercury's Line Out and Headphone jacks.

I'm hoping to understand more of how DttSP operates, and how it is 
"told" what kind of demodulation
to perform, what kind of filtering, noise reduction, etc.  DttSP does 
all that.

73,
Dave / wa8ywq

Paul Fletcher wrote:
> Apologies if this has been asked before (I couldn't find an answer) 
> but what software is required to compile the HPSDR code? I tried 
> Visual C# and it compiled OK but wouldn't run - not sure if the code 
> is still using Visual Studio 2003? Also are there any pointers to 
> where the code that supports HPSDR lives - I'm trying to understand 
> how the data gets to / from Mercury & Penelope.
>  
> I want to see if I can get my head around how the code hangs together 
> before I consider if I can help out or if it is beyond me (probably!)
>  
> 73 Paul M1PAF



 1235094326.0


More information about the Hpsdr mailing list