Silicon ChipA High-Quality DAB+/FM Tuner, Pt.1 - October 2010 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Letter to the Australian government
  4. Feature: Eye-Fi: Wireless Digital Photography by Ross Tester
  5. Feature: Jamboree On The Air . . . And Now On The Internet by Ross Tester
  6. Project: A High-Quality DAB+/FM Tuner, Pt.1 by Mauro Grassi
  7. Project: Digital Controller For Christmas Light Shows by Nicholas Vinen and Jim Rowe
  8. Project: Two Toslink-S/PDIF Audio Converters To Build by Nicholas Vinen
  9. Feature: Designing & Installing A Hearing Loop For The Deaf, Pt.2 by John Clarke
  10. Project: Build A GPS Boat Computer by Geoff Graham
  11. Vintage Radio: The Astor DL 4-valve mantel receiver by Rodney Champness
  12. Book Store
  13. Advertising Index
  14. Outer Back Cover

This is only a preview of the October 2010 issue of Silicon Chip.

You can view 27 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "A High-Quality DAB+/FM Tuner, Pt.1":
  • Software for the DAB+ Tuner (Free)
Articles in this series:
  • A High-Quality DAB+/FM Tuner, Pt.1 (October 2010)
  • A High-Quality DAB+/FM Tuner, Pt.1 (October 2010)
  • A High-Quality DAB+/FM Tuner, Pt.2 (November 2010)
  • A High-Quality DAB+/FM Tuner, Pt.2 (November 2010)
  • A High-Quality DAB+/FM Tuner, Pt.3 (December 2010)
  • A High-Quality DAB+/FM Tuner, Pt.3 (December 2010)
Items relevant to "Digital Controller For Christmas Light Shows":
  • Digital Lighting Controller LED Slave PCB [16110111] (AUD $20.00)
  • Digital Lighting Controller Slave Unit PCB [16110102] (AUD $25.00)
  • dsPIC33FJ64GP802-I/SP programmed for the Digital Lighting Sequencer/Controller [1611010A.HEX] (Programmed Microcontroller, AUD $25.00)
  • Firmware and PC software for the Digital Lighting Controller [1611010A.HEX] (Free)
  • Digital Lighting Controller LED Slave PCB pattern (PDF download) [16110111] (Free)
  • Digital Lighting Controller Master PCB pattern (PDF download) [16110101] (Free)
  • Digital Lighting Controller Slave PCB pattern (PDF download) [16110102] (Free)
  • Digital Lighting Controller master unit front panel design (PDF download) (Panel Artwork, Free)
  • Digital Lighting Controller mains slave unit front panel design (PDF download) (Panel Artwork, Free)
Articles in this series:
  • Digital Controller For Christmas Light Shows (October 2010)
  • Digital Controller For Christmas Light Shows (October 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.2 (November 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.2 (November 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.3 (December 2010)
  • Digital Lighting Controller For Christmas Light Shows, Pt.3 (December 2010)
Items relevant to "Two Toslink-S/PDIF Audio Converters To Build":
  • Toslink To S/PDIF/Coax Converter PCB [01210102] (AUD $10.00)
  • S/PDIF/Coax To Toslink Converter PCB [01210101] (AUD $10.00)
  • S/PDIF to TOSLINK Converter PCB pattern (PDF download) [01210101] (Free)
  • TOSLINK to S/PDIF Converter PCB pattern (PDF download) [01210102] (Free)
Articles in this series:
  • Designing & Installing A Hearing Loop For The Deaf, Pt.1 (September 2010)
  • Designing & Installing A Hearing Loop For The Deaf, Pt.1 (September 2010)
  • Designing & Installing A Hearing Loop For The Deaf, Pt.2 (October 2010)
  • Designing & Installing A Hearing Loop For The Deaf, Pt.2 (October 2010)
Items relevant to "Build A GPS Boat Computer":
  • GPS Car/Boat Computer PCB [05101101] (AUD $12.50)
  • VK2828U7G5LF TTL GPS/GLONASS/GALILEO module with antenna and cable (Component, AUD $25.00)
  • Software and documentation for the GPS Boat Computer [0410110D.HEX] (Free)

Purchase a printed copy of this issue for $10.00.

A high-quality DAB+ tuner to build We know you’ve been waiting for it and after more than a year in development, we are delighted to present this world-first high performance DAB+/FM stereo tuner design. It has all the bells and whistles of DAB+ in a sleek pro-quality case, with all features accessible by remote control. T HERE ARE LOTS of DAB+ radios out there but most are little mantelstyle sets with limited features and tinny sound – far below the performance that DAB+ is capable of. Make no mistake – this SILICON CHIP design will extract the very best sound quality possible out of every DAB+ broadcast signal, regardless of the sampling rate used. As well, it is also a very fine FM stereo tuner so you can listen to the FM versions of the programs – and often get even better signal quality from the analog broadcast. Our design is based on the renowned Venice 7 DAB+/FM radio module from 24  Silicon Chip leading developer Frontier Silicon Co in the UK. This module is widely used in many, if not most, DAB+ radios but as we should reiterate, those designs don’t do justice to it. By the way, the Venice 7 module is fully assembled so you don’t have to worry about soldering tiny state-ofthe-art surface-mount chips – you just clip it into the main circuit board. This is driven by a dsPIC33FJ256GP506 microcontroller from Microchip Inc and this provides all the fancy display features. Housed in a handsome case, the DAB+/FM Tuner will match in well with other hifi equipment. The front panel controls have been kept to a minimum, since all the features can be accessed using an infrared remote control. A blue ACKnowledge LED flashes to indicate when remote control signals are being received. The main highlight is the large backlit LCD panel which displays white text and graphics on a blue background. The display resolution is 160 x 80 pixels. This LCD shows all the station information from DAB+ stations and also from the FM stations when RDS (Radio Data Service) is being used. siliconchip.com.au Pt.1: By MAURO GRASSI Features & Specifications FEATURES • FM/DAB/DAB+ Radio (VHF Band 2 & 3, UHF     L-Band) • FM RDS (Radio Data Service) and DAB+ DLS     (Dynamic Label Segment) display to show text information • 10 FM station presets • 10 DAB/DAB+ station presets • Time and date display • Infrared remote control • 160 x 80 pixel graphics white-on-blue backlit LCD • RCA stereo output and S/PDIF TOSLINK digital output • Can play WAV files from an MMC/SD/SDHC memory card SPECIFICATIONS THD+N: 0.09% mono, 0.13% stereo Signal-To-Noise Ratio (SNR): 71dB mono, 60dB stereo 30dB Quieting: 23dBf/4µV mono & stereo 50dB Quieting: 31dBf/10µV mono; 41dBf/30µV stereo As well, the SILICON CHIP DAB+/ FM Tuner will allow you to play your favourite music via WAV files stored on a memory card. Just plug it into the front panel slot. So if you don’t like what is on offer from the radio siliconchip.com.au channels at the moment, you can play your own selection. There are six front-panel buttons for station presets and two more for mode and menu selection. Apart from the power switch on the lefthand side and the blue ACKnowledge LED, there is no other clutter on the front panel except for a rotary encoder. This is controlled by a large knob and is used to select stations and menu features. Numerous features, to be described later, are available via the infrared control. For example, there are 10 DAB+ station presets and 10 FM station presets and heaps of menu features which you can set or leave as defaults. The rear panel carries sockets for the antenna input and analog stereo outputs (RCA phono). In addition, there’s a TOSLINK (optical) digital output, a power socket and a DB9 serial socket to allow the firmware to be updated, if required. Power comes from an external 9V AC 500mA plugpack, so there’s no mains wiring to worry about. All the circuitry is carried on two PC boards: a main board and a front-panel display board. The main board carries the Venice 7 DAB+/FM module, the dsPIC33FJ256GP506 microcontroller, the analog output circuitry, the TOSLINK transmitter and the power supply components, while the display board carries the LCD, the pushbutton switches and the rotary encoder. As shown in the photos, the main board mounts in the bottom of the chassis while the display board sits vertically behind the front panel. The two boards are linked together via a multi-way ribbon cable. Circuit description Refer now to Fig.1 for the main board circuit. It can be split into five parts: the Venice 7 DAB+/FM module, the dsPIC33FJ256GP506 microcontroller, a TOSLINK transmitter, a stereo analog output stage and a power supply section. The Venice 7 module from Frontier Silicon contains all the RF and digital circuitry necessary to decode DAB+ and FM stereo multiplex signals. It produces an S/PDIF digital audio signal stream and stereo audio signal outputs when it is tuned to a station. An input is provided for a 75Ω antenna cable and the unit is connected to the main PC board via two pin headers, one 30-way and the other 14-way. The Venice 7 receiver module is manufactured in two versions, either as a slave or master module. Our design uses the slave version and this is controlled by commands from October 2010  25 +3.3V(2) +1.2V 100 µF 2 1 3.3V ANT 1.2V AUDL AGND AUDR 27 25 26 24 S/PDIFO VENICE 7 DAB+ RECEIVER MODULE I2SD 29 28 30 20 I2SFS I2SCK I2SMCLK URx UTx nPOR SDA SCL 15 16 19 13 14 0V 0V 3 4 0V S1 0V S3 0V S4 +3.3V(1) 100nF 10k 10k 4.7k 19 33k 100nF 10 26 57 38 AVdd Vdd Vdd Vdd Vdd 37 36 220Ω 100nF 7 MCLR RB7 SCL1 RC1 SDA1 30 CN12/ RB15 U2Rx 32 U2Tx 49 OC2 62 CSCK 1 COFS 63 CSDI 64 CSDO 17 RB6 5 SDI2 6 SDO2 4 SCK2 RC2 RB5 31 SDS1 SDVdd 4 SD CARD SKT 100nF 1 SDCS 7 SDDO 2 SDDI 5 SDCK 3 6 220Ω SDGND1 LED1 220Ω CON8 λ K SDGND2 23 A LED2 λ K 28 A 33k 33 34 330Ω +3.3V(1) DB9 6 7 8 9 1 Q2 BC327 330Ω 2 33k 3 E 39 C 56k 330Ω 10 µF 4 33k 5 B CON13 C X1 7.3728MHz TANT Q1 BC337 33pF 33pF RG0 RG1 RF1 RF0 RD4 RD3 RD8 40 1 10k IC2a 3 2 18 12 2 3 IC2d 11 13 11 8 61 60 59 58 52 51 42 IC1 dsPIC33FJ256GP506A PGC2/ 48 RC14 RB10 PGD2/ 47 RC13 13 CN5 14 CN4 15 CN3 16 CN2 43 INT2 44 INT3 45 RD1 54 OC7 RB13 U1Tx U1Rx VCAP OSC1 10Ω OC3/ 50 RD2 OSC2 AVss 20 E RG9 46 OC1/ RD0 56 B 33k 1k 4.7k Vss 9 Vss 25 Vss D G Q5 2N7000 S 1k 41 1k 100Ω 510Ω +5V SC  2010 DAB+/FM TUNER 2.2Ω MAIN BOARD CIRCUIT Fig.1 the main board circuit can be split into five parts: the Venice 7 DAB+/FM receiver module, a dsPIC33FJ256GP506 microcontroller (IC1), a TOSLINK transmitter, a stereo analog output circuit (IC3, IC4 & IC5) and a power supply based on 3-terminal regulators REG1-REG5. Power comes from an external 9VAC plugpack supply. 26  Silicon Chip siliconchip.com.au +5V 100nF 220nF 8 5 100nF –5V 7 IC4b 6 3.0k 620Ω 1nF 14 –5V 8 9 6 12 IC3: LM833N ANALOG GROUND IC5: 4066 (MUTING CONTROL) 15nF 2.2nF 13 2 56k +5V CON4 2 3 38 36 34 29 11 31 33 27 25 23 21 19 17 15 13 16 14 12 10 9 7 30 28 26 24 4 6 8 20 39 2 +5V 220nF IC4a 3 +5V 620Ω 1 4 +3.3V +3.3V 1 35 5 37 1 5 3 3 560Ω 4 2 100Ω 1 IC3a RIGHT OUT CON9b 4 1nF 3.0k 7 33k –5V –5V COM CS1 +3.3V(1) +5V EN CS2 nRST Q3 BC327 D7 D6 100nF 510Ω E 2.2k B 4 5 C 510Ω 14 510Ω 6 E B Q4 BC327 C IC2b D5 D4 9 D3 10 D2 2 IC2c 8 TOSLINK TX 3 7 D1 100nF 220Ω 1 D0 KC0 +5V KC1 REG3 LM3940 KC2 KC3 – +3.3V(1) R/W OUT 470 µF RS 100nF D1 REG1 7805 OUT IN GND K IN A GND 9V AC INPUT KR0 REG5 LM3940 KR1 KR2 +3.3V(2) KR3 OUT 470 µF 100nF ENC0 IN 1000 µF 16V 100nF 1 2200 µF 25V 100nF 2 3 GND IRDAT B CON1 D3 +1.2V A K GND 330Ω 470 µF –5V OUT IN ADJ GND D2 REG2 7905 REG4 LM317T LED– 2x 100nF 100nF 100nF 2200 µF 25V 1k Vee BC327, BC337 LEDS LED+ B K (CONNECTS TO CON17 ON FRONT PANEL BOARD) E A D1–D3: 1N4004 K G S OUT GND OUT 7905 OUT IN GND IN C ADJ D 7805, LM3940 LM317T 2N7000 A K A IN GND 1000 µF 16V CONT siliconchip.com.au ~ ~ 4 ENC1 OUT 40 LEFT OUT 2.2nF 15nF IC4: LM833N CON9a 100Ω 7 IC3b 5 11 –5V 8 6 560Ω 10 56k 100nF IN GND IN OUT October 2010  27 2,3 36,38 34 1000 F 29 A LED3 33  K CS 2 100 F 16 RST 15 – LCD MODULE Vdd 100nF 100nF 100 RS 4 R/W 5 330 LED– Vo LED+ Vee 19 17 20 3 Vss 1 11 27 25 6 EN 14 D7 13 D6 12 D5 11 D4 10 D3 9 D2 8 D1 7 D0 23 21 19 17 15 13 35 37 5 39 7 IRD1 9 10 F 3 330 1  20 8 24 26 2 28 30 S1 PS0 1k +5V +3.3V(1) COM CS1 nRST EN D7 D6 D5 D4 D3 D2 D1 D0 Vee LED+ CONT LED– RS – R/W B IRDAT KR3 KR2 KR1 KR0 S5 S2 1k CON17 S7 S4 S3 S8 D7 S6 A PS1 K 10 KC3 D6 B A ROTARY ENCODER 12 K KC2 D5 A A K 14 KC1 D4 GND A K 16 KC0 IRD1 4 LED3 K A SC  2010 6 1 D4–D7: 1N4148 3 2 DAB+/FM TUNER A DISPLAY BOARD CIRCUIT K 40 1 ENC0 ENC1 GND GND (CONNECTS TO CON4 ON MAIN BOARD) Fig.2: the display board circuit uses a backlit LCD module which has a resolution of 160 x 80 pixels. This board also carries an infrared receiver (IRD1), a rotary encoder and eight pushbutton switches for the station presets and menus. the dsPIC33FJ256GP506 micro (IC1) via the serial port. This serial port consists of two lines at pins 15 & 16 of the receiver module (URx & UTx) and these are driven via pins 31 & 32 of the dsPIC microcontroller. The serial port runs at 115,200 bps and uses an 8-bit word with one stop bit and no parity. The microcontroller sends commands to the Venice 7 28  Silicon Chip module and receives data back from it. Error detection is accomplished using a checksum appended to each packet sent. The Venice 7 receiver module is also connected to the microcontroller’s I2C peripheral, ie, the SDA & SCL signals at pins 36 & 37 respectively. This is a low-speed serial bus requiring only two lines that can be used to commu- nicate with many different devices. The two lines are pulled up by two 4.7kΩ resistors. However, while this connection is there, it is not currently used by the firmware. The receiver module is reset by bringing the nPOR line (pin 19) low. This line is driven by the microcontroller using a digital I/O pin configured as an output (RB15 at pin 30) siliconchip.com.au via a 220Ω resistor. Note that the line is normally pulled high via a 10kΩ resistor to the +3.3V rail, so that the receiver module is not also reset when the microcontroller is reset. The 220Ω resistor is used for current limiting. The Venice 7 module also pulls its nPOR pin low on start-up and although the firmware is designed to cater for this, this resistor protects both pins in case the module unexpectedly resets (asynchronously to the microcontroller). I2S interface Another four lines are used to access the I2S (Inter-IC Sound) interface of the Venice 7 module. These are MCLK (Master Clock, pin 24), SCLK (Shift Clock, pin 26), FS (Frame Sync, pin 25) and D (Data, pin 27). When the Venice 7 module is decoding audio from a radio signal, whether it is digital or FM, these lines carry digital, uncompressed, stereo audio data. On the other hand, when the DAB+ Tuner is playing an uncompressed WAV file from the memory card, the lines carry data in the opposite direction, from the dsPIC microcontroller to the Venice 7 module. In a typical I2S application, the MCLK line is the oversampling clock signal and this can be used to drive an external DAC. There are good reasons to use an oversampling clock when it comes to audio quality and cost but we won’t go into all these here. Suffice to say that the main reason for using it is that it allows the use of simpler (and cheaper) audio filters on the output of the DAC. These achieve the same effect as a more expensive multi-pole filter which would be required if oversampling was not used. In this design, the MCLK master clock line is connected to an “Output Compare” pin on IC1 (ie, OC2 at pin 49). The “Output Compare” peripheral on the dsPIC microcontrollers (and other Microchip microcontrollers) is most commonly used to generate a PWM (pulse width modulated) signal but it can also be configured in other modes. Here it is used to generate a square wave from the internal system clock of IC1. This serves as the master clock when the microcontroller is sending data to the Venice 7 module. Alternatively, when the Venice 7 module is decoding audio, it acts as a general I/O pin and is configured as a digital input. In this case, the audio siliconchip.com.au VENICE 7 DAB+/FM RADIO MODULE This view shows the main board assembly, with the Venice 7 DAB+/FM radio module mounted in position. The assembly details are in Pt.2 next month. data is read by the microcontroller and is processed by the firmware to display both the audio level and the frequency spectrum. It also allows the microcontroller to detect silence and static on FM stations and this is processed by the firmware to control the muting. In operation, the microcontroller will mute an FM station if it detects only static. The reading of the digital audio data occurs almost transparently in October 2010  29 The rear panel provides access to the serial port, TOSLINK transmitter and the analog stereo outputs (RCA sockets). It also carries the antenna and power sockets. A standard 40-way IDE cable is used to connect the two PC boards. the dsPIC, using DMA (Direct Memory Access) and its DCI (Data Converter Interface) peripheral. The latter can be used to interface to a number of audio coders and decoders. In particular, it can code and decode an I2S stream. The bit clock (I2SCK, pin 26) allows the serial audio data to be decoded and is connected to the CLK signal of the DCI peripheral of IC1 (CSCK at pin 62). The data signal (I2SD, pin 27 of the Venice 7 module) is connected to both the CSDI (Data In) and CSDO (Data Out) lines of the DCI peripheral of IC1 (at pins 63 & 64 respectively). The other signal used is the frame sync (I2SFS, pin 25), which for I2S goes high or low depending on whether data is being transmitted for the left or right audio channel. Its frequency is equal to the sampling frequency of the digital audio stream. This is connected to the DCI peripheral’s COFS pin (pin 1 of IC1). TOSLINK output The two audio outputs of the Venice 7 module (pins 29 & 30) are fed to the analog output stage, while the S/PDIF output (pin 20) is fed to the pin 10 input of NAND gate IC2c. This gate allows the digital stream to be muted via one of the microcontroller’s digital I/O pins (ie, RB7, pin 18). When the unit is muted, RB7 is high 30  Silicon Chip and the output of NAND gate IC2a (configured as an inverter) is low. This in turn means that pin 9 of IC2c is low (and so no data can pass through IC2c), while IC2b’s output is high. The latter is used as a simple buffer to drive the base of PNP transistor Q4. So Q4 is off whenever RB7 is high and on otherwise. This transistor simply switches power to the TOSLINK transmitter (+3.3V). As a result, when the mute is active, no power is applied to the TOSLINK transmitter (and no data passes through IC2c). The 220Ω resistor is there to provide a minimum load for Q4’s collector, while the 100nF capacitor bypasses the TOSLINK transmitter’s supply rail. Note that the TOSLINK output only operates for radio mode (ie, when using DAB/DAB+ or FM mode). It does not output any data when playing back WAV files from the memory card. This is because it is the microcontroller that controls the WAV playback and no S/PDIF signal is generated. You will have to use the stereo audio outputs if you want to use both radio and WAV playback modes, while using just one amplifier input. dsPIC microcontroller The dsPIC33FJ256GP506(A)-I/PT microcontroller (IC1) comes in a sur- face-mount TQFP-64 (64 pin) package. This will be supplied programmed and soldered in position on the main PC board if the DAB+/FM Tuner is purchased as a kit. This microcontroller has 256KB of program memory and 16KB of SRAM. It can run at up to 40 MIPS (million instructions per second) and in this application it runs at 39.6288 MIPS. This frequency is derived from a 7.3728MHz crystal (X1) using the on-board primary oscillator. The two 33pF ceramic capacitors provide the correct loading for the crystal. In operation, the system frequency of 39.6288MHz is derived using internal divide and multiplication (PLL – phase locked loop) stages as follows: [172(7.3728 x 106)]/32 = 39.6288 x 106 The reason for using this frequency is that it allows the two most common audio sampling frequencies (44.1kHz and 48kHz) to be closely approximated for WAV playback, while also being very close to the maximum operating frequency (to allow the microcontroller to run as fast as possible). Both sampling frequencies can be approximated to within ±0.8%. It is also a good frequency for serial port communication with the Venice 7 module. IC1 is powered from one of two siliconchip.com.au +3.3V supply rails and this has a number of 100nF monolithic decoupling capacitors. The core runs from 2.5V and this is derived using an internal low drop-out regulator. This regulator requires a 10µF decoupling capacitor to GND at the VCAP output (pin 56). Finally, the IC1’s reset line (MCLRbar at pin 7) is pulled high by a 1kΩ resistor to enable the power-on reset logic to function. Memory card The DAB+/FM Tuner has a slot on the front panel that allows an MMC/ SD/SDHC memory card to be inserted into connector CON8. Basically, the memory card can be used to store music in uncompressed WAV format. This type of file is essentially a channel-interleaved file of PCM (Pulse Code Modulation) audio sample data. This means that (usually) a 16-bit sample for the left channel is followed by a 16-bit sample for the right channel. The sampling frequency determines the number of 16-bit sampling pairs per second, eg, a 44.1kHz sampling rate gives 44,100 sample pairs per second. For mono WAV files, there are half as many samples. The memory card also adds a few other functions, such as saving the tuner settings (eg, station presets). siliconchip.com.au We’ll talk about these functions when we explain how to operate the DAB+/ FM Tuner in a future article. Note that it’s necessary to insert the memory card when the power is off, as the memory card detection occurs on start up. MMC/SD/SDHC cards can be accessed either in their native mode or in SPI mode. The advantage of SPI mode is that the interface is simpler and so this is the mode used in this circuit. The penalty is slower transfer speeds. However, SPI speeds are quite adequate for playing back uncompressed stereo WAV files at sampling rates up to 48kHz. The microcontroller communicates with the memory card over one of the SPI (Serial Peripheral Interface) buses (SPI2). SPI1 is reserved for possible future use and is not currently used. SPI communication requires four lines: SDCS (chip select – active low), SDDO (serial data output), SDDI (serial data input) and SDCK (serial clock). In this case, the microcontroller is the SPI master and controls the SDCS line. When it is pulled low, the memory card becomes active and listens for commands. The SDDO and SDDI lines are used to transmit and receive data in conjunction with the clock line (SDCK) which is generated by the microcontroller. The SDCS line is pulled high by a 10kΩ resistor, while the data output line from the memory card is pulled high by a 33kΩ resistor. The memory card socket (CON8) also contains two switches, one of which is NO (normally open) but closes when a memory card is inserted into the socket. This is used to switch power to the memory card, ie, from the +3.3V rail to pin 4 of CON8. In addition, there are two ground connections at pins 3 & 6 of CON8. The four remaining SPI lines are connected to the microcontroller. Note that the data lines are connected transposed to allow full duplex communication. The SPI bus runs at close to 10MHz, which is about the fastest that the microcontroller will allow. Serial port The microcontroller has two serial ports. UART2 (at pins 31 & 32) is used to communicate with the Venice 7 module (to send commands and receive data), while UART1 (pins 33 & 34) connects to the external DB9 socket (CON13). This allows the unit to be connected to a PC, either directly to a native RS232 port or indirectly via a serial-to-USB cable. The main reason for connecting to a PC is to allow the microcontroller’s firmware to be updated, in the case that future upgrades are made available. This can be done using a bootloader application for Windows operating systems (more on this in Pt.3). The serial port can also be used to help diagnose any problems with the radio module in “bridge mode”. In this mode, external data received via the serial port is passed directly to the Venice 7 module and similarly, data received from the Venice 7 module is fed to the serial port. The microcontroller simply acts as a relay, allowing the Venice 7 module to be controlled directly from a PC. We won’t be describing how this is done however, since it won’t be necessary for kit constructors to do this. Only three lines are connected to the DB9 socket: the transmit and receive lines plus the ground connection. As shown, the transmit line at pin 33 (U1TX) is connected via a 330Ω current limiting resistor to pin 2 of CON13 (which is the Rx receive line). By contrast, the receive line at pin 34 (U1RX) is connected via a voltage divider formed from two 33kΩ resistors to pin 3 of CON13 (which is the Tx transmit line). The voltage divider is necessary to step down the voltage on the Tx line to a 5V level before it is fed to pin 34 (a 5V tolerant pin) of the microcontroller (IC1). Analog output circuitry The stereo analog outputs (AUDL & AUDR) of the Venice 7 module appear at pins 29 & 30. The analog ground at pin 28 (AGND) is connected to system ground inside the module but for best audio quality, it should carry only audio return current. The PC board has been designed to carry all the audio return current to this pin. The two audio channels are identical, so we will only describe the operation of the left channel. As shown, the left output (AUDL) is AC-coupled into non-inverting buffer stage IC4b (one half of an LM833N low-noise dual op amp). This buffer and the high-pass filter formed by the 220nF capacitor and the 56kΩ resistor present a minimal October 2010  31 The front panel has six station preset buttons plus buttons to select the mode (DAB/DAB+ or FM) and menus. The knob controls the rotary encoder which is used to step through the menus, change settings, select stations and set the volume. load on the high-impedance output of the radio module. IC4b’s output is in turn fed to analog switch IC5 (4066) via a 620Ω resistor. IC5 contains four switches and two are used in parallel for each audio channel, to lower the switching resistance (ie, the RDS(on) of the Mosfets in IC5) and hence the distortion. The paralleled switch output appears at pins 8 & 11 and is fed to op amp IC3b via a multiple feedback filter network (620Ω, 3kΩ, 560Ω, 15nF & 1nF). The low resistance values in this filter ensure that we are dealing with signal currents (rather than signal voltages) through the analog switches, to take advantage of their improved linearity in this mode. IC3b functions as a second order low-pass filter with a cutoff frequen­ cy of around 31.7kHz and a gain of around -4.8 to provide line level output signals. The 100Ω resistor and 2.2nF capacitor provide further lowpass filtering at its output. This audio filtering is necessary to remove any switching artefacts generated by the DAC (Digital-to-Analog Converter) inside the Venice 7 module. Analog output muting The analog audio outputs are muted by turning the analog switches off. This is done using transistor Q3 which drives a common muting control line for all four switches inside IC5. Q3 is controlled by the RB7 (pin 18) output of IC1 via NAND gate inverters IC2a & IC2b. As described previously, this also controls the muting for the TOSLINK transmitter. 32  Silicon Chip As shown, pin 6 of IC2b drives Q3’s base via a 2.2kΩ resistor. IC2b operates from a 3.3V rail and the divider formed by the 2.2kΩ and 510Ω resistors on Q3’s base provides level translation. When IC2b’s output switches high to +3.3V (ie, when RB7 of IC1 is high), Q3’s base will be at about 4.7V and so Q3 will be off. Conversely, when IC2b’s output goes low, Q3’s base voltage drops to about 4.1V and Q3 turns on. When Q3 is on, the muting control line is pulled high and this closes the analog switches in IC5. As a result, the stereo audio signals are fed through to op amps IC3b and IC3a and finally to the stereo RCA output sockets. Conversely, when Q3 is off, the 33kΩ pull-down resistor on its collector will keep the switches off and the analog outputs are muted (as is the TOSLINK output). Power supply Power for the circuit is derived from a 9V AC 500mA plugpack supply. Its output is fed in via CON1 and applied to two half-wave rectifiers (D1 & D2) to derive ±12V unregulated rails. The advantage of using an AC plugpack is that there is no need for internal mains wiring, which greatly simplifies the construction of the DAB+/FM Tuner. The unregulated ±12V rails from the rectifier are filtered using 2200µF capacitors. They are then fed to positive and negative 3-terminal regulators REG1 & REG2 to derive ±5V DC rails. These rails are in turn filtered using 1000µF capacitors, while the 100nF capacitors on the inputs and outputs of the regulators shunt any high-frequency noise. Note that the 2200µF filter capacitor on the -12V rail has a 1kΩ resistor connected across it to ground. This is included because this rail would otherwise have less loading than the +12V rail and it ensures that the two 2200µF capacitors discharge at about the same rate after switch off. The ±5V rails are used to power the op amps (IC3 & IC4), while the +5V rail is also used to power the LCD and the infrared receiver (IRD1) on the front panel board. While ±5V rails may seem to be on the low side for powering the LM833N op amps, our tests show that the distortion produced by these devices is still low enough to make it irrelevant in this application. That’s because the distortion of the signal from the radio module is higher than in the analog output stage. The advantage of using 5V rails is that both the LCD module and infrared receiver (IRD1) run off 5V, so there’s no need for an additional regulator. REG1’s output is also fed to 3-terminal regulators REG3, REG4 & REG5. REG3 & REG5 are both LM3940 lowdropout types and are used to derive regulated +3.3V rails. REG4, on the other hand, is an LM317T adjustable regulator and is used here to derive a +1.2V rail (more on this shortly). All outputs are filtered using 470µF and 100nF capacitors. The Venice 7 module is powered using two of these voltage rails – the +3.3V rail derived from REG5 and the +1.2V rail from REG4. The +3.3V rail siliconchip.com.au is used to power the module’s RF front end and its audio output circuitry, while the +1.2V rail is used for the digital processing circuits. The microcontroller is powered from the separate +3.3V rail derived from REG3. This prevents any digital switching noise generated by the microcontroller from being injected into the supply rail to the Venice 7 module, as this could degrade the audio quality. As indicated above, the +1.2V (nominal) rail is derived using adjustable regulator REG4. This device maintains a voltage of 1.25V between its OUT and ADJ pins, although in practice this can be anywhere between 1.2V and 1.3V (due to manufacturing tolerances). The Venice 7 module can tolerate an error of ±10% for its 1.2V rail, so this is within specification. Diode D3 is there to protect REG4 if the voltage on its output exceeds its input (eg, if there is a fault elsewhere in the circuit). The 330Ω resistor to ground provides a minimumal load for REG4 if the Venice 7 module is not installed in its socket. Display board circuit Refer now to Fig.2 for the display board circuit. This is based mainly on a backlit white-on-blue LCD module which has a display resolution of 160 x 80 pixels. It’s powered from the +5V rail derived from REG1 on the main board, while its associated decoupling capacitors (1000µF and 100nF) are mounted close to its Vdd supply pin. In addition, the display board carries the IR receiver module (IRD1), a blue ACKnowledge LED (LED3), a rotasiliconchip.com.au ry encoder, eight pushbutton switches and a few minor parts. It connects to the main PC board via a 40-way ribbon cable which runs between CON17 and CON4. This carries all the power supply connections plus the connections from the microcontroller to the LCD module and the other parts. Note that although the LCD module runs from a +5V rail, the microcontroller is powered from a +3.3V rail. Despite this, their logic threshold levels are compatible. This means that the microcontroller’s 0-3.3V outputs can correctly drive the LCD module’s 0-5V inputs. At the same time, a 5V output from the LCD module can be fed directly to one of the microcontroller’s 3.3V inputs, provided it is 5V tolerant. The LCD module’s data lines (D0D7) are bidirectional, depending on whether data is being written to or read from the LCD module. Since the LCD module runs from 5V and the microcontroller from 3.3V, these data lines are connected to the microcontroller’s 5V tolerant pins. The other lines required to drive the LCD module are as follows: R/W-bar (Read/Write), RS (Register Select), Vee (LCD Voltage), Vo (Contrast Adjust), CS-bar (Chip Select) and E (Enable). These are common to many other LCD modules and their meanings are as follows: R/W-bar (Read/Write): when high, the microcontroller reads data from the LCD module; when low, the microcontroller writes data to the LCD module. RS (Register Select): when low, the data register is accessed; when high, the instruction register is accessed. The data register is written with pixel information while the instruction register is written with the cursor position and other settings. Vo (Contrast Control): varying the voltage on this pin controls the display contrast. CS-bar (Chip Select): when low, the control chip inside the LCD module is selected and is ready to receive commands; when high, it ignores all commands. E (Enable): when high, the LCD module’s driver IC is enabled; when low, it ignores all commands; Vee: this negative voltage output pin is generated by the LCD module from its supply voltage. It’s used here to control the contrast via pin Vo. The microcontroller controls these lines as appropriate. The E line is de- rived from two lines via NAND gate IC2d on the main board. Note that although the LCD module we are using only has one CS line, other similar displays use two CS lines and so provision has been made to support these. During the development of the DAB+/FM Tuner, we used a 128 x 64 display with two CS lines, for example, before finally settling on the 160 x 80 display in the final version. Contrast & brightness control The brightness of the white LED backlight used in the LCD can be varied by the microcontroller. This is done via the LED+ (A) and LED- (K) pins of the LCD module (pins 19 & 20, respectively). As shown, LED+ (the anode) is connected via CON17, CON4 and a 2.2Ω current limiting resistor to the +5V rail (see bottom of Fig.1). Similarly, LED- (the cathode) is connected via CON17 & CON4 to the drain of Q5, a 2N7000 field effect transistor (FET). In operation, the backlight is driven using a PWM (pulse width modulated) waveform from pin 50 (OC3) of IC1. Its brightness is proportional to the duty cycle of this PWM signal which operates at a frequency of about 125kHz. This allows the duty cycle to be varied over an 8-bit range (256 levels) to control the display brightness. The PWM signal is applied to Q5’s gate via a 10Ω current-limiting resistor. There is also a 1kΩ pull-down resistor on pin 50 and this ensures that Q5 is turned off when there is no signal from pin 50 of IC1 (OC3). This situation occurs when the microcontroller is reset or is being programmed through ICSP (In Circuit Serial Programming), for example. The display contrast can also be varied by the microcontroller using PWM. This is done using an independent PWM output at pin 46 (OC1) and this varies the contrast in conjunction with the circuit based on transistors Q1 & Q2. It works like this: the PWM signal from pin 46 of the micro is used to pulse PNP transistor Q2 on and off via a 330Ω base resistor. In addition, there is a 56kΩ pull-down resistor and this keeps Q2 turned on whenever there is no driving signal from pin 46. Again, this occurs while the microcontroller is being reset and defines the “default” state for Q2. When Q2 is off, the 330Ω resistor October 2010  33 Parts List For DAB+/FM Tuner Chassis Parts 1 custom 19-inch rack style 1.5U metal instrument case with punched holes & screened lettering 6 right-angle metal brackets (supplied with case) 4 screw-on feet for case (Jaycar HP0830) 1 9V AC plugpack (500mA or higher) (Jaycar MP3027 or equivalent) 1 150mm-length 75Ω coaxial cable (RG59/U MINI with copper or tinned copper shield) (Farnell 1491575) 1 75Ω chassis-mount socket (for antenna) 1 SPST clip-in rocker switch, 20mm diameter (Jaycar SK0960) 10 yellow cable ties 1 M2.5 x 15mm self-tapping black screw (for securing stereo RCA socket to rear panel) 1 2.1mm bulkhead male socket (Jaycar PS0522) 1 0.7 metre length medium-duty yellow hook up wire 1 0.4 metre length black medium-duty hook up wire 1 40-way IDE HDD cable (Jaycar PL0946) Main PC Board 1 PC board, code 01110101, 114.5 x 194mm 1 Venice 7 DAB+/FM radio tuner module 1 TOSLINK transmitter, 3.3V (Jaycar ZL3000) 2 14-pin IC sockets 2 8 pin IC sockets 1 40-pin dual header (Jaycar HM3250) (to be cut – for connecting the Venice 7 module) 4 7-pin 0.1-inch straight female headers (for Venice 7 module socket) 2 8-pin 0.1-inch straight female headers (for Venice 7 module socket) 1 40-way PC-mount vertical IDC header (Jaycar PP1114) 1 DB9 PC-mount right-angle female socket (Jaycar PS0806) 34  Silicon Chip 2 TO-220 mini heatsinks (Jaycar HH8502) 1 RCA PC-mount vertical stereo socket (Jaycar PS0280) 1 7.3728MHz crystal (X1) 1 memory card socket (Jaycar PS0024) 1 2-way screw terminal blocks (5.08mm spacing) Screws & nuts 8 M3 x 10mm tapped metal spacers 4 M3 x 25mm countersink head machine screws 5 M3 x 6mm machine screws (for regulators) 9 M3 metal nuts Semiconductors 1 dsPIC33FJ256GP506(A)-I/PT microcontroller programmed with 0111010A.hex (IC1) 1 74HC00 quad NAND gate (IC2) 2 LM833N dual op amps (IC3 & IC4) 1 CD4066BC quad bilateral switch (IC5) 1 BC337 NPN transistor (Q1) 3 BC327 PNP transistor (Q2-Q4) 1 2N7000 FET (Q5) 1 7805 +5V regulator (REG1) 1 7905 -5V regulator (REG2) 2 LM3940-3.3 low-dropout regulators (REG3, REG5) 1 LM317T regulator (REG4) 3 1N4004 diodes (D1-D3) 1 3mm green LED 3mm (LED1) 1 3mm orange LED (LED2) Capacitors 2 2200µF 25V electrolytic 2 1000µF 16V electrolytic 3 470µF 16V electrolytic 1 100µF 16V electrolytic 1 10µF tantalum 2 220nF MKT 8 100nF monolithic 9 100nF MKT 2 15nF MKT 2 2.2nF MKT 2 1nF MKT 2 33pF ceramic Resistors (0.25W, 1%) 3 56kΩ 2 560Ω 6 33kΩ 3 10kΩ 2 4.7kΩ 2 3kΩ 1 2.2kΩ 4 1kΩ 2 620Ω 4 510Ω 4 330Ω 4 220Ω 3 100Ω 1 10Ω 1 2.2Ω DAB+ Front Panel Board 1 PC board, code 01110102, 277 x 57mm 8 SPST PC-mount tactile switches (square) (Jaycar SP0608) 8 black plastic caps to fit switches 1 graphics LCD module, 160 x 80 pixels 1 rotary encoder with switch (from Jaycar) 1 black anodised aluminium knob, 29mm diameter (Jaycar HK7011) 1 40-way PC-mount vertical IDC header (Jaycar PP1114) 1 28-pin single in-line strip (Jaycar HM3211) – (to be cut to 20 pins for connecting the LCD module) 4 M2 x 15mm machine screws (for mounting LCD) 12 M2 nuts (for mounting LCD) 12 M3 x 10mm machine screws, countersink head (for attaching brackets to front panel and front panel board to brackets) 6 M3 nuts (for attaching front panel board to brackets) 6 M3 flat nylon washers (for attaching front panel board to brackets) Semiconductors 1 IR receiver (IRD1) (Jaycar ZD1952) 1 3mm blue LED (LED3) 4 1N4148 signal diodes (D4-D7) Capacitors 1 1000µF 25V electrolytic 1 100µF 16V electrolytic 1 10µF 16V electrolytic 2 100nF monolithic Resistors (0.25W, 1%) 2 1kΩ 1 100Ω 2 330Ω siliconchip.com.au between its collector and Q1’s base is effectively out of circuit. As a result, Q1’s base voltage is pulled low by the associated 1kΩ resistor and so Q1 is off. When Q1 is off, the voltage at the Vo (contrast) pin of the LCD module is close to the voltage at Vee (a negative voltage). In this state, the contrast is at maximum and it reduces as the Vo voltage approaches ground. When transistor Q2 is on, Q1 is turned on via the 330Ω resistor. The voltage at Vo is now determined by the voltage divider formed by the 510Ω and 100Ω resistors between Q1’s emitter and Vee. Thus, by varying Q2’s duty cycle (and hence Q1’s duty cycle), the voltage at Vo can be controlled to set the contrast. Front panel controls As previously stated, the front panel controls include eight SPST momentary switches, an SPST power switch and a rotary encoder with pushbutton action. The latter is used to vary settings, select stations and adjust the volume. It can also be used to navigate through the menu system. The rotary encoder outputs two signals at A and B, which are out of quadrature. These outputs are pulled up by two 1kΩ resistors and connect to two external interrupt inputs of IC1 (INT2 & INT3 at pins 43 & 44, respectively). These interrupts are triggered on either a high to low or low to high edge and this allows the microcontroller to keep track of the rotary encoder and determine whether it is being turned clockwise or anticlockwise. In addition, the rotary encoder has a switch which is activated by pressing on the shaft (ie, pushbutton action). This switch, together with the eight SPST momentary switches (S1-S8), is part of a 4 x 4 scanning matrix. Four lines (KC0-KC3) are configured as digital outputs, while the other four (KR0-KR3) are configured as digital inputs. Lines KC0-KC3 are connected to the switches via four signal diodes (D4D7), to effectively make them open collector outputs. This is done because these four lines are multiplexed with LCD module lines D0, D1, R/W-bar and RS. In addition, the diodes prevent a short circuit if two switches on the same column are pressed simultaneously. In operation, each of the four outsiliconchip.com.au Where To Buy A Kit Of Parts A complete kit of parts for the DAB+/FM Tuner will be available from Jaycar Electronics – Cat. KC5491. This kit will be complete and will include the Venice 7 radio module, double-sided plated-through PC boards, a pre-punched custom steel case with screened lettering and the remote control. The main board will be supplied with the dsPIC microcontroller soldered in place. Kits will be available by early December and can be pre-ordered at your local Jaycar store. put lines (KC0-KC3) is periodically brought low by the microcontroller (while the rest are high). Meanwhile, the four input lines KR0-KR3 are connected to separate “interrupt on change” lines of IC1 (CN5, CN4, CN3 & CN2 respectively at pins 13-16). These lines have internal weak pull-up resistors enabled and any change on the pin (as happens when a button is pressed) generates an interrupt. The microcontroller can then determine which button was pressed and take the appropriate action. Indicator LEDs There are three indicator LEDs in all, two on the main board (LEDs 1 & 2) and one on the display board (LED3). LED1 indicates that power is connected, while LED2 indicates when there is activity on the memory card. Neither of these LEDs is visible from outside the case and they are used solely for diagnostic purposes. They are not essential to the normal operation of the DAB+/FM Tuner. These two LEDs are driven by I/O pins RB10 & RB13 (pins 23 & 28 respectively) of IC1 via 220Ω current limiting resistors. In addition, pin 28 has a 33kΩ pull-down resistor. LED 3 (blue) protrudes through the front panel (to the left of the LCD) and is used to ACKnowledge infrared activity from the remote control. It is controlled using a PWM (pulse width modulation) signal from output OC7 (pin 54) of IC1. The 330Ω resistor in series with its cathode provides current limiting to set the maximum brightness. In addition, varying the brightness of the LCD module’s backlight also affects the brightness of LED3. Remote control The DAB+/FM Tuner can be cotrolled using the supplied remote control (see lead photo). This uses an NEC 32bit PWM code, meaning that the width of the pulse determines whether the transmitted bit is high or low. Although it uses a 32-bit code, only 16 bits are significant. The rest are the complements of the others. This adds redundancy and makes the code less prone to errors. It also ensures that each word has the same period. Alternatively, you can use a universal remote control that’s RC5 compatible. RC5 is an infrared protocol that was initially developed by Philips and is now quite commonly used. It is a bi-phase encoded code, with the bits represented by high-to-low or low-tohigh transitions (it is self clocking). The DAB+/FM Tuner has been designed to work with both the NEC and Philips codes in case the supplied remote control develops a fault and is no longer available. If that happens, you can still control the tuner using a universal remote that’s capable of transmitting RC5 codes (most do). You can also define the codes that correspond to the button functions using the menu system, as described in a future article. Infrared receiver The infrared receiver (IRD1) is mounted on the display board and receives signals from the remote through a small hole in the front panel. IRD1 amplifies, filters and demodulates these signals before feeding the data to RD1 (pin 45) of IC1 via a 330Ω resistor. Power for IRD1 is derived from the +5V rail and is filtered using a 100Ω resistor and a 10µF electrolytic capacitor. RD1 of IC1 is 5V tolerant and triggers an interrupt on a high to low edge. An edge trigger is used to start the signal decoding. This decoding takes up only a small amount of processor time and times out after a few seconds, making the decoding very efficient. Next month That’s all we have space for this month. Next month, we’ll show you how to assemble the two PC boards and install them in a case. SC October 2010  35