Saturday 22 February 2014

Arduino SDR

Here's the latest news from the bench - I have my Arduino DUE running as an SDR receiver...

You will have seen a couple of weeks ago that I had the Arduino DUE running (internally designed) programmable band-pass filters at CD sample rate. Well, I've taken that technology to use as a low-frequency "IF" and added a very computationally-efficient mix down to base-band, all inside the Arduino DUE.

I am currently using an external VFO, running on an Arduino MEGA - but I know there is enough horsepower left in the DUE to control the DDS and the user interface (as well as doing all the DSP for the radio functions), so the MEGA is just a temporary convenience.

Here's the whole shebang labelled for clarity...

RF from the antenna comes into one of my plug-in bandpass filter modules (there's a 40m filter in place in the photo), after which it goes into a rather conventional 602-based mixer. The Arduino-based VFO generates the signal which mixes the signal to the low intermediate frequency band, which is amplified in two-stages by half a quad op-amp. The remaining half of the op-amp is used to implement a 4th-order anti-aliasing filter, which has as close to Butterworth tuning as my available passives allow.

The signal is then passed to my Arduino DUE, which samples the IF at 44.1kHz with one of its internal (12-bit) ADCs. The signal is then filtered and mixed down to audio frequency, where it is output via one of the internal DACs (again 12-bit, 44.1kHz) and onward to an active speaker (actually, into my desktop PC).

Whilst the internal signal processing is conducted at high resolution (32-bit, fixed-point), I had feared that the 12-bit data converters would be such a weak link in the whole process that it wouldn't work - but I shouldn't have worried. Let's just say it is significantly surpassing expectations!

In fact, I discovered a significant flaw in the sampling process in my earlier Arduino DSP experiments which was seriously limiting dynamic range. This fault was generating a whole bunch of "ghost" and "image" signals which made themselves known when I introduced the (software) heterodyne to baseband central to this receiver. It is sorted now. I'm not ready to make any further details of the code public just yet - but will be posting more information as this project progresses (although I'm not yet sure if it will eventually be "open-source").

There is a great deal of exciting DSP potential out there for ham radio applications - I've also been playing with an STM32F407 chip on one of ST Microelectronics' amazingly cheap "Discovery" boards. This has much more "grunt" than the little SAM3X on the Arduino DUE (at under half the price) - but I've got a soft spot for the Arduino family and want to see how far I can take the DUE before succumbing to the temptations of even fancier chunks of silicon.

...-.- de m0xpd


Friday 21 February 2014

Brian's Beacon

I was delighted to receive news of Brian, g3zoh's version of Occam's Beacon yesterday, including these great photos (reproduced with Brian's kind permission).

Brian has built his system into an attractive and practical enclosure - as you can see in the photo above. Makes me almost ashamed of my ramshackle lash-ups! 

Beauty isn't just skin deep in the case of this definitive build - take a look at the craftsmanship inside...

Brian raised some interesting questions about the gain structure of the Kanga / m0xpd Sudden Tx Shield, which I'm going to look into. He also reports that his beacon is getting noticed on air - so we're both pleased.

Occam's Beacon has never looked so good - great job Brian!

...-.- de m0xpd 

Sunday 9 February 2014

Arduino DSP

Having spent much of 2013 keeping it simple with the Arduino, I thought it would be nice to start 2014 by waking up the little grey cells and doing something a little less facile...

I treated myself to an Arduino DUE and decided to investigate what could be done in the way of Digital Signal Processing on that platform...

Unlike the simpler Arduinos, with their ATmega microcontrollers, the DUE features an Atmel SAM3X8E ARM Cortex-M3 CPU, which is an entirely different kettle of fish.

Whilst the DUE's 32-bit processor can blow the simpler 8-bit AVR micros away, the good folks at Arduino have retained all the attractive and familiar features of the simpler platforms in the DUE, including, amazingly, the cheapskate-compatible price tag. In fact, the DUE is actually cheaper than the Arduino MEGA - making it my kind of toy!

I took inspiration from my old adjustable analog CW Filter (SPRAT 146, Spring 2011, p20) and decided to try to make something similar using DSP. Yesterday I got it working...

My system uses only a couple of passives to couple the analog signals, a 10k potentiometer to control the bandwidth and the Arduino DUE...

Adjusting the pot allows you to set up an audio filter which can be varied from a tight CW filter all the way to a quite wide SSB filter - and all points in between. Here are a series of measured frequency responses captured this morning, demonstrating the range of the system...

[Having nothing else to hand, I downloaded a freeware audio analyser to make the measurements above. The analyser is called "Visual Analyser" and can be downloaded from here .I haven't had chance to evaluate it fully as yet - but initial impressions are positive. Certainly the price was right! having said that, the greater part of the "noise" in the measurements above is a mis-representation of the new DSP filter, which sounds "clean".]

As you see, advancing the control makes a wider filter - the lower corner frequency falls from around 500 Hz to 300Hz whilst the upper increases from around 700Hz to beyond 4kHz. All the filter design work is done in the Arduino in close-to-real time (there is presently an audible "glitch" as you change the filter bandwidth - but it isn't a show-stopper).

Although the system needs no visual interface, it does pump out a statement of the current filter design targets after any adjustment of the control. These can be viewed on the "Serial Monitor" in the Arduino development environment (or any "Hyperterminal" equivalent)...

Here's a schematic, explaining how simple the hardware hookup is...

and here's the unit in test, taming down some wideband signals on 40m from my FT817...

For those that know anything about this sort of thing, I'm designing the filters using the "Fourier Transform" method and implementing them using "Fast Convolution". The system is running at a sample rate of 44.1 kHz (CD sample rate) and can run at up to 48 kHz (the next "standard" digital audio sample rate).

I'm not going to be publishing the code as yet (this is the start of a bigger project - watch this space), but I will give some pointers to anybody wishing to learn about audio applications on the DUE...

Analog-to-Digital Conversion
I started off by figuring out how to get the speed of analog throughput from the DUE's 12 bit ADC straight through to the integral twin-channel 12 bit DAC up to a reasonable rate for audio.

Out-of-the-box, the speed isn't there - but if you look at this page you'll learn how to speed things up considerably (to a very respectable 330kHz sample rate, in fact). Search a bit harder and you'll find this page, which explains how to run the ADCs in 'free-run' mode, which will take you up to over 600kHz sample rate (albeit with some inevitable loss of resolution).

Timing Framework
Next, I found this helpful application which, as well as giving a useful audio tool (an audio-frequency DDS generator on the Arduino), provides a nice introduction to the establishment of an interrupt-driven timing framework to get a standard sample rate.

Hardware for Basic Analog Throughput
A shield has been produced for the DUE, which equips it as a skeleton digital guitar effect pedal, as described here. This provided the outline for my hardware layout and also gives some inspiration for the analog throughput - but the signal processing in the pedal is trivial. I wanted to implement something more ambitious, so I needed a DSP library...

DSP Library for the ARM
Whilst there is a great FFT application library for Arduino UNO etc, here (I've used it and can vouch for its quality), it isn't suitable for the DUE. It is too limited in scope and - more importantly - doesn't take advantage of the extra resources on the DUE's ARM processor. Fortunately, ARM themselves produce a library which includes DSP functions - the CMSIS-DSP library, which you can find documented at the websites of the major software providers for ARM development such as Keil.

Unfortunately, the Arduino software isn't set up to use the CMSIS-DSP library - so you need to do a little digging to set it up. Fortunately, that task is well-described in this discussion on the Arduino forum.

With the information in the links above, you'll be able to play with audio on the Arduino DUE - which is a really exciting platform.

Now that I've got the basic framework of some controllable DSP running on the DUE I've got some ideas about what I'm going to be trying next...

...-.- de m0xpd