...using LM3S811 microcontroller - abstract DesignStellaris 2006 entry 1. Short description This project is a digital direct conversion receiver for long waves. It proves that a working radio receiver can be built using only a few discrete components, computer speakers with amplifier and EK-LM3S811 evaluation board. Its performance might be worse than of a well designed analog receiver but this device uses no inductors at all in the signal path and there are no tuning capacitors. Instead, tuning and control is done by a USB serial connection with a computer running any terminal emulating software. Although designers of the LM3S811 for sure did not expect that it will be used as a radio receiver, its speed and other features are sufficient to build one. Modern microcontrollers are truly multi-purpose! 2. Principle of operation The idea of digital receiver is not new. It has been around for a few years now. The main idea of it is to perform all the tuning and demodulation by mathematical operations performed in digital domain. Using this technology, in general, it is possible to build a receiver that equally well receives analog AM, SSB and FM signals, digital OOK, FSK and other, using the same hardware. The only changes are done in software. The analog part of this circuit is limited to signal conditioning and filtering. Rest of the processing is done by a digital circuit after converting the signal by analog to digital converter (ADC). In presented here the idea of digital radio is used to receive AM signals at frequencies below 250 khz. The block diagram of the device is shown below on Fig. 1. tuning and control ADC PC running terminal software mixer frequency generator amplifier bias 1st RC filter EK-LM3S811 R-2R DAC 2nd RC filter loudspeaker Fig. 1. Block diagram of longwave radio receiver The device works as follows: signal from antenna (a few meters of wire) is amplified in a two transistor amplifier. After amplification the signal is biased to approximately half of the analog to digital converter input range and filtered by a very simple RC lowpass filter. It also acts as an antialiasing filter for analog to digital converter. Next stage is analog to digital converter itself, working 1
at approximately 500 000 samples per second. After converting the signal to digital domain the samples are fed to the digital mixer. This mixer multiplies consecutive samples by sine wave samples stored in microcontroller's memory. Appropriate samples of sine wave are supplied by frequency generator that uses direct digital synthesis technique to generate signal of desired frequency. After multiplying the samples are converted back to analog domain by simple R-2R resistor ladder. Sound quality is improved by filtering the output by another simple RC filter. Last stage is amplification of the signal in an amplifier of a computer loudspeaker. 3. Reception The reception of broadcast stations with this radio differs a little from reception with an analog tuner. First of all, due to a fixed tuning step, it might be impossible to tune exactly to the station frequency this would result in fadeouts of sound (when frequency of local generator is almost the same as the carrier frequency) or metallic sound (when frequency of local generator differs from the carrier frequency by a few hertz). Next problem is weak filtering of the input signal. As a result aliasing may occur. Additionally, weak filtering on the input means that quite significant amount of noise is amplified. Next difference is the way the radio is tuned. In digital radio the received frequency can be set more accurately and it is stabilized by quartz oscillator, therefore it does not change significantly with time, as it sometimes happens with analog receivers. The radio is controlled via USB connection. Terminal software is configured to use virtual COM port created by the driver supplied with the board. Parameters of connection are: 115200bps, 8 bits, 1 stop bit, no parity bits. All commands need to be followed by Enter key. Control commands are the following: set Increase value: f[new Increase value] example: f7249536 set output scaling value: o[scaling value] (can be regarded as volume control) example: o8 Increase value up by 1: = Increase value down by 1: Increase value up by 100: ] Increase value down by 100: [ get current Increase value: g Due to problems with acquiring exact ADC frequency there is no command to set the receiver to the desired frequency directly. Instead tuning of Increase value has to be done. 4. Photograph of the test setup Photograph of the test setup of receiver is shown on Fig. 3. The loudspeaker used during tests is shown on Fig. 4. Fig. 3. Photograph of the hardware 2
Fig. 4. Loudspeaker 5. Code Two fragments of the code (ADC interrupt routine and unsigned long send via UART routine) are presented on the following listings void ADCIntHandler(void) register long Data; #ifdef filtr static long M0 = 0; static long M1 = 0; long Out; int A2 = 16384 * 0.9760; int A1 = 16384 * -1.9750; int B2 = 16384 * 0.3083; int B1 = 16384 * 0.6167; int B0 = 16384 * 0.3083; #endif //Acknowledge interrupt HWREG(ADC_BASE + ADC_O_ISC) = 1; //Retreive sample Data = (HWREG(ADC_BASE + ADC_O_SEQ + ADC_O_X_SSFIFO)&1023) - 512; //Multiply by sine sample Data = Data * sine[(temp_pointer >> 14) & 0x3ff]; //Increase sine table pointer Temp_Pointer += Increase; //filtering - problems encountered, therefore - turned off by default #ifdef filtr Data>>=scaleIn; Out = ldata * B0 + M0; Out>>=14; M0 = B1 * ldata + M1 - A1 * Out; M1 = B2 * ldata - A2 * Out; //Update output HWREG(GPIO_PORTD_BASE + (GPIO_O_DATA + (0xff << 2))) = (char)(out>>scaleout) + 128; #else //Update output HWREG(GPIO_PORTD_BASE + (GPIO_O_DATA + (0xff << 2))) = (char)(data>>scaleout) + 128; #endif void my_send_ul(unsigned long co, myuart_mode mode) 3
int i; int divider; if(mode == MODE_DEC) divider = 1000000000; for(i=10;i>0;i--) UARTCharPut(UART0_BASE, '0'+(( co / divider ) % 10)); divider /= 10; if(mode == MODE_BIN) for(i=31;i>=0;i--) UARTCharPut(UART0_BASE, '0'+((co >> i) & 1)); UARTCharPut(UART0_BASE, '\r'); UARTCharPut(UART0_BASE, '\n'); 4
Fig. 2. Circuit schematic 5