Professional Documents
Culture Documents
November 2011
Super Arduino
Getting started with
the chipKIT Max32
OnCE/JTAG Interface
Program and debug Freescale DSPs
Subscribe to audioXpress at
www.cc-webshop.com
today!
Great Expectations
Some call it disappointing, others prob-
lematic to adapt to active marketing strate-
gies but I find it fascinating and a constant
source of inspiration and amusement: proj-
ects and articles that start out insignificant,
then taking off in a grand way and eventu-
ally reaching blockbuster status, appar-
ently self-propelled. Elektors Hexadoku, 6 Colophon
the Audio DSP Course, E-Weekly, The Chaos
Machine, Pico C, Retronics and the ElektorBus Whos who at Elektor.
are fine examples of Elektor readers deter-
mining the rate of success rather than us 8 News & New Products
editors and publishers. A monthly roundup of all the latest in
Eight installments ago, the ElektorBus was electronics land.
no more than a vague idea loosely men-
tioned in an E-Labs Inside installment. Since 14 Super Arduino
then it has gained momentum and thanks
to many active thinking caps out there This article should put you in pole
were now at the stage of describing an position for the DesignSpark chipKIT TM
ElektorBus control center running on a Challenge organized by RS Components,
Smartphone. Likewise Retronics, kind of my Elektor and Circuit Cellar.
own section in the magazine, started as a
joke, but six years on its gathered a large 18 Improved Radiation Meter
group of loyal followers and contributors! Gamma, beta and alpha radiation levels
Ive several sensors available to gauge get measured with this instrument based
the success of published projects. Maga- on a cheap and cheerful PIN photodiode.
zine and board sales reports are the obvi-
ous monitors that come to mind, but as an 24 Simple Bat Detector
editor I find my weekly website statistics
quicker and more up to date, as well as Build this circuit over the winter period
telephone calls and just plain enthusiastic and next spring youll be able to listen to
emails. In good engineering spirit I find all bats flying to and fro.
manner of feedback useful and rewarding.
28 Audioguide
We kick off a global Challenge again, this The first application of the Elektor Platino
time brought to you jointly by RS Compo- board is an RFID triggered rMP3 (no
nents, Elektor and Circuit Cellar. Its all about typo) player for use as a personal guide in
designing a project around the Digilent museums
chipKITTM Max32 hardware and software
using RS DesignSpark PCB design tools, 32 Audio DSP Course (5)
where ideally the three culminate in an add-
on board that helps save or reduce energy This month we take a look at the
any way you can think of. After the official important matter of structuring your DSP
launch of the Challenge on November 26 programs.
at the Elektor Live! event, a limited number
of chipKITTM boards will be given away to 40 OnCE/JTAG Interface
participants. Starting on page 16, Clemens This adapter was originally designed for
Valens reports his initial findings with the the Elektor DSP courseware board but is
chipKITTM hardware and software compo- compatible with other Freescale DSPs too.
nents and you might find his story useful to
be in pole position by the time the Challenge 44 E-Labs Inside: Working with Stencils
starts. I do expect your entry too!
A step by step guide to making perfect
Enjoy reading this edition, SMD boards as far as applying solder
Jan Buiting, Editor paste is concerned.
4 11-2011 elektor
Volume 3
CONTENTS November 2011
no. 35
14 Super Arduino
46 Here comes the Bus! (9)
The chipKIT TM Max32 board offers 32-bit computing power and some 80 I/O
pins while remaining compatible with the Arduino environment. It is the hard- This month HTML and Javascript are used
ware component of the exciting design challenge brought to you by RS Com- to make a control station running on a
ponents, Circuit Cellar and Elektor. In this article youll find a number of tips Smartphone.
that should give you a head start in working with the hardware and software
that go into making your entry for the challenge. 56 Economical Voltage Monitor
This circuit monitors the voltage output
of a solar cell while consuming preciously
little power itself.
Many species of bat produce sounds at frequencies in the 40 kHz range, which 70 Resistive Bolometer
happens to be the operating range of most standard ultrasonic transducers. If
An innovative use of two electric bulbs
you amplify the signals picked up by one of these transducers and feed them into you were about to trash.
a frequency divider, the output will be within your normal range of hearing.
72 Retronics: Exotic Tubes Facebook
Old friends hail from this months
Retronics pages. Series Editor: Jan Buiting
74 Gerards Columns:
Speaking Out Loud
66 Temperature Gradient Meter From our monthly columnist Gerard Fonte.
Measuring temperature is a fairly simple task, but doing so precisely takes
76 Hexadoku
rather more skill, particularly when it is desired to obtain readings to a resolu-
tion of better than one tenth of a degree. The circuit presented here measures Elektors monthly puzzle with an
temperature to a resolution of one ten-thousandth of a degree, using just four electronics touch.
active components and an optional display.
84 Coming Attractions
Next month in Elektor magazine.
elektor 11-2011 5
Elektor International Media provides a multimedia and interactive platform for everyone interested
in electronics. From professionals passionate about their work to enthusiasts with professional
ambitions. From beginner to diehard, from student to lecturer. Information, education, inspiration
and entertainment. Analog and digital; practical and theoretical; software and hardware.
analog digital
microcontrollers & embedded
audio test & measurement
No. 35, NOVEMBER 2011 ISSN 1947-3753 Elektor is also published in French, Spanish, German and Graphic design / DTP: Giel Dols, Mart Schroijen
Dutch. Together with franchised editions the magazine is on
Elektor aims at inspiring people to master electronics circulation in more than 50 countries. Publisher: Hugo Van haecke
at any personal level by presenting construction projects (h.vanhaecke@elektor.com)
and spotting developments in electronics International Editor:
and information technology. Wisse Hettinga (w.hettinga@elektor.com) Marketing: Carlo van Nistelrooy
Editor: Jan Buiting (editor@elektor.com)
Customer Services: sales@elektor.com
Elektor (ISSN 1947-3753) is published monthly (except
International editorial staff: Harry Baggen,
for one issue in July/August) at $39.95 per year, Canada
Thijs Beckers, Eduardo Corral, Ernst Krempelsauer, Subscriptions:
add $11.00 per year;
Jens Nickel, Clemens Valens Elektor US, 4 Park Street, Vernon, CT 06066, USA.
by Elektor International Media LLC,
4 Park Street, Vernon, CT 06066, USA. Design staff: Christian Vossen (Head), Phone: 860-875-2199, Fax: 860-871-0411
Phone: 860-875-2199, Fax: 860-871-0411. Thijs Beckers, Ton Giesberts, Luc Lemmens, Internet: www.elektor.com
www.elektor.com Raymond Vermeulen, Jan Visser E-mail: subscriptionsus@elektor.com
6 11-2011 elektor
Elektor PCB Prototyper
A professional PCB router W !
N E
with optional extensions!
This compact, professional PCB router can produce
complete PCBs quickly and very accurately. This makes
the PCB Prototyper an ideal tool for independent
developers, electronics labs and educational institutions
that need to produce prototype circuits quickly. Specications
Dimensions: 440 x 350 x 350 mm (W x D x H)
The PCB Prototyper puts an end to waiting for boards from Workspace: 220 x 150 x 40 mm (X x Y x Z)
Weight: approx. 35 kg (78 lbs)
a PCB fabricator you can make your own PCB the same Supply voltage: 110240 V AC, 50/60 Hz
Integrated high-speed spindle motor;
day and get on with the job. In addition, the PCB Proto-
maximum 40,000 rpm (adjustable)
typer is able to do much more than just making PCBs. Integrated dust extraction (vacuum system
not included)
A variety of extension options are available for other USB port for connection to PC
Includes user-friendly Windows-based
tasks, and a range of accessories is already available. software with integrated PCB software
module
Ordering
The complete machine (including software)
is priced at US $4,900 plus VAT and shipping
charges (please enquire at sales@elektor.com).
Head Office: Copyright Notice not accept responsibility for failing to identify such patent(s)
Elektor International Media b.v. The circuits described in this magazine are for domestic or other protection. The submission of designs or articles
use only. All drawings, photographs, printed circuit board implies permission to the Publisher to alter the text and design,
PO Box 11 NL-6114-ZG Susteren The Netherlands
layouts, programmed integrated circuits, disks, CD-ROMs, and to use the contents in other Elektor International Media
Telephone: (+31) 46 4389444, Fax: (+31) 46 4370161 DVDs, software carriers and article texts published in our publications and activities. The Publisher cannot guarantee to
books and magazines (other than third-party advertisements) return any material submitted.
are copyright Elektor International Media b.v. and may not
US Advertising: be reproduced or transmitted in any form or by any means,
Disclaimer
Strategic Media Marketing, Peter Wostrel, including photocopying, scanning an recording, in whole or in
part without prior written permission from the Publisher. Such Prices and descriptions of publication-related items subject to
1187 Washington St., Gloucester MA 01930 USA.
written permission must also be obtained before any part of change. Errors and omissions excluded.
Phone: 978-281-7708, Fax: 978-281-7706 this publication is stored in a retrieval system of any nature.
E-mail: peter@smmarketing.us Patent protection may exist in respect of circuits, devices,
Advertising rates and terms available on request. components etc. described in this magazine. The Publisher does Elektor International Media b.v. 2011 Printed in the USA
elektor 11-2011 7
NEWS & NEW PRODUCTS
New multi-function easy desktop, rail, or wall mounting. Addi- Power controllers for
tionally, a lockable USB cable secures con-
ASB DAQ modules nectivity. The USB DAQ modules also pro- next-generation server,
ADLINK Technology, Inc. announces the vide device ID setting by a rotary control for desktop and computing
release of its USB-1900 Series and USB-2401 convenient identification of the active mod-
USB DAQ modules. Equipped with built-in ule in multiple-connection configurations.
applications
signal conditioning, the USB-powered Plug ADLINKs USB DAQ collection offers the International Rectifier has introduced a
and Play USB DAQ modules deliver easy USB-1900 series, consisting of USB-1901 new digital power platform that dramati-
connection and accurate results for both and USB-1902 models of 16-bit 250 kS/s cally improves energy efficiency in a wide
portable measurement and machine auto- DAQ modules. Also in the series is the USB- variety of applications, including high per-
mation applications. Featuring built-in sig- 1903, with additional built-in precision cur- formance server, desktop and computing
nal conditioning, ADLINK USB DAQ mod- rent-to-voltage resistors allowing direct applications.
ules enable direct measurement of most measurement of current signals from 0 to The new family of digital controllers is based
frequently applied signal sources, which 20 mA. Rounding out the USB DAQ cate- on CHiLs proven digital platform offering
reduces manpower requirements and asso- gory is the USB-2401, a 24-bit four-channel full telemetry and programmability, provid-
ciated development costs while increasing simultaneous-sampling universal DAQ mod- ing system designers a chance to differenti-
overall accuracy. ule supporting sampling rates up to 1.6 kS/s ate their products with custom features. The
and a more flexible signal conditioning cir- family offers a fully compliant high speed
cuit such as voltage, current, strain, load serial bus to meet new industrial require-
cell, thermocouple, and RTD measurement. ments. These 5, 6 and 8-phase dual output
The USB DAQ line is ideally suited for eas- PWM controllers, in which phases are flex-
ily accomplished deployment and superior ibly assigned between loops 1 and 2, can be
accuracy when measuring temperature, easily configured for Intel VR12, AMD SVI/
stress, strain, and other factors in diverse PVI/G34, and feature switching frequency
applications. between 200 kHz to 1.2 MHz per phase.
The USB DAQ modules include ADLINKs The family of digital controllers offers effi-
free U-Test utility, allowing direct operation ciency improvements with features such as
and testing of all functions with no require- variable gate drive and dynamic phase con-
ment for coding or programming. Driver trol for best-in-class efficiency and program-
support is provided for Windows 7/Vista/ mable 1-phase or 2-phases for light loads.
All of ADLINKs USB DAQ modules feature XP, in both 32-bit and 64-bit versions, and When used in conjunction with IRs Pow-
USB power and removable screw-down ter- 3rd party software support accommodates IRstage devices this family offers an opti-
minals for simplified device connectivity, LabVIEW & MATLAB. mized end-to-end solution delivering high-
and a multi-functional stand for fast and www.adlinktech.com/USBDAQ (110675-II) est efficiency for next-generation servers.
8 11-2011 elektor
Advertisement
elektor 11-2011 9
NEWS & NEW PRODUCTS
10 11-2011 elektor
Advertisement
Smart TVs and other connected products.
RF eliminates the need for IRs line-of-sight
access, allowing devices to be controlled
in the presence of obstacles and even
interior walls (up to a range of 15m and
assuming wall construction materials do
not excessively attenuate the RF signals).
DUAL remote control also incorporates IR
remote control functionality so that users
can operate legacy entertainment devices.
In operation, the DUAL remote handset
utilizes a Nordic nRF24LE1 System-on-
Chip (SoC) 2.4 GHz ULP transceiver run-
ning a modified version of Nordic Gazell RF
protocol software. An nRF24LU1+ System-
on-Chip (SoC) 2.4 GHz ULP transceiver
and USB 2.0 compliant device controller,
incorporated into a compact USB dongle,
plugs into the host device (the product to
be controlled) to form the other node of
the wireless link. The Nordic RF technology
enables a bidirectional communication
link with sufficient bandwidth for rapid
screen refresh and seamless navigation.
The nRF24LE1 integrates a proven
nRF24L01+ transceiver core, enhanced
8051 microcontroller, 16 Kbytes of on-chip
flash and 1 Kbytes of SRAM into a single-
chip solution. The chip boasts a 2 Mbps
on-air data rate combined with ultra low
power (ULP) operation and advanced
power management. The nRF24LU1+ inte-
grates a USB 2.0 compliant device control-
ler, 8-bit application microcontroller, and
nRF24L01+ compatible 2.4 GHz RF trans-
ceiver. Gazell RF protocol software pro-
due to limited bandwidth and one-button- vides features for advanced navigation,
one-operation interfaces. RF provides suf- remote data transfers, and advanced pair-
ficient bandwidth for advanced navigation ing schemes while handling up to five
interfaces such as scroll wheels, touch remote devices at the same time. In addi-
screens, and track balls and bidirectional tion, Gazell is a frequency agile protocol
communication required when negotiating that is highly immune to interference from
the complex user interfaces and menus typ- other 2.4 GHz radio sources.
ical of modern media devices. In addition, DUAL from Philips Home Control is now
the QWERTY keypad is useful for brows- ready for commercialization.
ing the Internet on the latest generation of www.nordicsemi.no (110675-VI)
elektor 11-2011 11
The industrys brightest minds
come here to shine.
Every year one place brings together the innovators on technologys cutting edge.
And for those four days, Vegas glows brighter.
idea into a
cool
solution.
DesignSpark chipKIT Challenge
Visit www.chipkitchallenge.com
for complete rules and to see if you qualify for a
FREE ChipKIT Max32 development kit.*
*Subject to availability.
IN ASSOCIATION WITH:
chipKIT is a registered trademark of Microchip Technology Inc. Max32 is a registered trademark of Digilent, Inc.
MICROCONTROLLERS
Super Arduino
Getting started with the
chipKIT Max32
If you are interested in microcontrollers you probably have heard of Arduino, maybe you even worked
with it. If you did, you may have run into the limits of this charming 8-bit platform and wished it had more
computing power, memory or even I/O pins. With microcontroller boards galore thats within easy reach
but at the cost of learning new tools all the time. Until recently, when Digilent introduced their solution for
those wanting more power without changing tools. Their chipKIT Max32 board offers 32-bit computing
power and some 80 I/O pins while remaining compatible with the Arduino environment.
For sure there have been previous attempts into the real Arduino 0022 integrated chipKIT PCB is a 4-layer board, so few peo-
at making 32-bit Arduino compatible development environment (IDE from now ple will be tempted to roll their own.
boards, however as far as I know these on). From an Arduino IDE point of view the There are two flavors of chipKIT: the Uno32
attempts only achieve Arduino form fac- chipKITs are just targets, cheerfully listed and the Max32. Mechanically the Uno32 is
tor compatibility, not compatibility at alongside the classic 8-bit Arduino boards. compatible with the classic Arduino Uno
the tools level. Some of these boards are Digilent even went so far as to create a and the Max32 is compatible with the Ardu-
supported by software libraries that offer website with a URL ending in .cc [1], just ino Mega, which is the longer version of the
Arduino-like functionality and syntax, but like Arduino. standard Arduino. Note that Digilent made
each one requires a different compiler and Also in the spirit of Arduino, the chipKIT the boards rectangular by straightening the
employs specific firmware loading meth- comprises completely open source and curiously shaped short edge of the Arduinos
ods. Digilent has taken Arduino compati- hardware, meaning the hardware design so they are slightly larger. I dont think this
bility a step further by integrating the com- files (Eagle schematic and PCB files) are will be a problem for anyone.
piler, linker and programmer for the PIC32 available for downloading and the soft- The rest of this article will concentrate on
processor used on their chipKIT boards ware is all open source. Unlike Arduino the the Max32, so here we go!
14 11-2011 elektor
MICROCONTROLLERS
The board jack indicating that the 3V3 rail supplies a place on a convenient disk on your com-
The Max32 comes as a red 4-layer PCB in a voltage while a green LED (LD4) flashes at puter. Unpacked it takes up some 480 MB
tiny mainly red and white box without much about 3 Hz. of disk space. To start the IDE launch the
else, i.e. no USB cable, no documentation, executable called mpide.exe found in the
just a URL [2]. For those who do not know The Max32 is hardly more than a breakout root of the IDE folder. The IDE is cross-plat-
the Arduino Mega dimensions by heart: the board (BoB) for the 100-pin PIC32 processor form and will work happily on Windows,
board measures 10.2 x 5.4 cm. Like on the mounted close to the centre of the board Linux and MacOS although you may have
Arduino Mega, three edges of the board are with a power supply and a USB serial port to install Java first.
lined with connectors, except that the con- on the side. This PIC32 is a 32-bit micro- By basing the Max32 on the Arduino IDE,
nectors for the digital pins 0 to 13 (in Ardu- controller from Microchip that compares the people at Digilent saved themselves a
ino-speak) are double-row types on the pretty well to ARMs Cortex-M3 (see inset). lot of documentation writing. Indeed, all
Max32. You will find digital pins 70 to 85 on The board sports the largest PIC32 device you need to know to install and get started
the extra contacts. On the USB and power currently available, the PIC32MX795F512L. with Arduino is explained in detail on the
connector side there is room for a Microchip This chip sits in a 100-pin package and fea- Arduino website [3]. Also go there with
ICSP programming connector. This connec- tures 512 KB of flash memory with 128 KB your questions about the programming
tor has the special Sparkfun out-of-line of RAM and runs from an 80 MHz clock. It language syntax.
(staggered) placement of the pins allowing has USB-OTG (on-the-go), an Ethernet MAC At the time of writing this article the ver-
a pinheader to make proper contact even and two CAN controllers. sion of the IDE is 0022 (mpide-0022-chip-
without being soldered. After this short introduction of the hard- kit-win-20110619 to be precise), the same
Powering the board can be done through ware, lets take a look at the software. as the current official Arduino IDE. Accord-
the USB connector or using the power bar- ing to Digilent this IDE is identical to the
rel jack which will allow input voltages up to The IDE official Arduino IDE except that it has been
15 VDC. Jumper JP1 lets you bypass the 5 V As already mentioned, programming the extended with a PIC32 compiler/linker
regulator so be careful what you do here or board is done using a modified Arduino IDE and libraries, hence can be used to pro-
you may blow up the odd chip. When you you can download as a free archive from gram 8-bit Arduino boards too. Of course
power a virgin board you will notice an [2]. Installing the 128 MB file is very simple; I tried this only to discover that my Ardu-
annoyingly bright red LED next to the power you only have to unpack it to a convenient ino clone, a Seeeduino v1.1, was not rec-
elektor 11-2011 15
MICROCONTROLLERS
Figure 1. The Max32 IDE showing a Figure 2. A close-up of the SPI connection between
#define to remove AVR specific code. the etherShield and the Max32.
ognized: Invalid device signature. This My old Ethernet shield I will call it ether- have expected something like _BOARD_
board works perfectly fine with the official Shield from now on to distinguish it from MAX32_). Do the same for any AVR-specific
Arduino 0022 IDE. the new official Arduino W5100-based #include directives.
After installing the IDE and hooking up the Ethernet shield is supported by a library
Max32 to the computer you can try out the and some examples. This shield and code This may not be sufficient (in my case it
tools by compiling one of the simple exam- works just fine on my Seeeduino. The first wasnt) because the library may also refer
ples included with the IDE and uploading step was therefore to install this library in to AVR registers that the PIC32 doesnt
it to the board. Do not forget to select the the Max32 IDE (in the folder libraries\) and have. The SPI driver for the ENC28J60 Eth-
Max32 board from the Tools -> Board menu see if it would compile. The answer was, as ernet chip did this, probably because it is
and to set the serial port properly (Tools -> you may have expected: No(pe). The reason relatively old and the SPI library thats now
Serial Port). Once done the BlinkWithout- was not so much the code itself, but the fact part of the Arduino IDE simply did not exist
Delay example (File -> Examples -> Digital) that the compiler apparently was unable to when at the time it was written (it did not
should work without modification, just click find anything to compile. According to the appear before version 0019 from Septem-
the Upload button to see the green LED LD4 Digilent website, where a few things about ber 2010). I therefore modified the old
start to flash at a rate of 0.5 Hz. porting Arduino code are explained, librar- etherShield library to use the new Arduino
ies are supposed to be handled in the same SPI library instead and tested this first in
If you got this far without problems youre all way as Arduino does, but clearly not in my the real Arduino IDE before trying it in the
set to develop real applications for the Max32. case. When I put the library in the folder Max32 IDE.
So read on, because there will be some hur- hardware\pic32\libraries\ (where you find
dles that you may want to know of the same items as in the folder libraries\) the This introduced new problems because the
compiler did find the code, but produced SPI library references pin functions that the
Porting a shield many errors and a warning saying that the Max32 compiler did not like. As it turned
Flashing an LED is nice, but not very satisfy- code contained AVR specific code (Arduino out, the hitch was caused by my library
ing, thats why I ventured on to try out my boards are based on Atmels AVR proces- being written in C and compiled as such,
Arduino Ethernet shield on the Max32 (a sors). Great! Now I had clue. whereas the pin functions and the SPI library
shield is an extension card for an Arduino are written in C++. Files with the extension
board). This shield is based on Microchips The first thing you have to do when port- .c are compiled as C, files with the exten-
ENC28J60 stand-alone Ethernet control- ing Arduino libraries is to get rid of the ref- sion .cpp are compiled as C++. So, back to
ler with SPI interface. I know, the PIC32 has erences to program memory. With an AVR the Arduino IDE it was for porting the com-
an Ethernet MAC inside, but I didnt have some special compiler directives are needed plete etherShield library to C++ and testing
a shield handy with an Ethernet PHY and for accessing constants (strings, tables) it. This was not particularly difficult to do,
RJ45 connector. Digilent proposes such a located in program space. This is unneces- but you may have to watch out for com-
shield (that offers other things besides), sary for the PIC32 and these directives have piler directives like #externC{}
but I didnt have time to order one and wait to be removed. To keep your code Arduino hidden in unexpected places. After this last
for it to arrive. Besides, now I had a good compatible it may be better to #define modification my etherShield library com-
opportunity to see just how Arduino com- them away, you can use the macro _ piled without errors in the Max32 IDE and
patible the Max32 is. As you will see below, BOARD_MEGA_ (see Figure 1) defined by for the Max32 board. But did it work?
not entirely the Max32 IDE to do this (confusing; youd No of course not! This did not really come
16 11-2011 elektor
MICROCONTROLLERS
Figure 3. The modifications I made to the Figure 4. The result of a successful port:
etherShield. I can now connect to a tiny web server running on the Max32.
as a surprise as I had already spotted SPI- right, because where the Arduino managed edge. To keep your life easy, try to use the
problem posts on Digilents website, but to reach a clock speed of about 610 kHz, the functions available in Arduino libraries as
the optimist in me kept hoping. PIC32 was blasting away at 20 MHz. Accord- much as possible, and let Digilent do the
The main problem is incompatibility of ing to the datasheet of the ENC28J60 this hard work for you.
Max32 I/O pins with AVR I/O pins. Arduino should be OK, but experimenting later
digital pins 10 through 13 have SPI capabil- when all was finally working showed me Digilent has started keeping a list of known-
ity and pins 10 and 11 can do PWM also. The that 2.5 MHz was a more realistic value. For to-work shields, so first look there before
reason for this combination is simply the now I just reduced the PIC32s clock speed starting a project yourself. Updates to the
way the AVR I/O pins were laid out by Atmel. to an Arduino-like value: 625 kHz. With this Max32 IDE correcting some of the issues
The PIC32 combines functions in a different change the shield still didnt work, but I felt mentioned in this article may be expected,
way on its I/O pins and there are no exact I was getting close. so make sure you always use the latest
equivalents for these AVR pins. Digilent has version.
chosen to give priority to the PWM func- Nowadays even the lowest budget digital
tions as they are used by Arduinos analog- oscilloscopes can record traces, including The only thing that I havent completely
Write functions, meaning that they could my 240-euros (shipping included) 25 MHz cleared up yet is the issue of where to put
only connect part of SPI port 2 to these pins. Atten ADS1022C, and this very useful func- your own libraries. After thinking hard and
However they did find a way to connect SPI tion showed me that there was a polar- experimenting a bit I settled on the assump-
port 1 in an Arduino compatible manner by ity/phase issue between the SPI clock and tion that all files that contain PIC32 spe-
using the Arduino ICSP connector (Figure 2) data lines. By carefully comparing transi- cific code, like low-level drivers, must be
thats connected to the same signals as pins tions I discovered that the shield needed placed in the folder hardware\pic32\librar-
10 through 13. I had never considered this SPI mode 1 on the Max32 whereas it used ies\ including the files that need these files.
connector as part of a compatible shield, mode 0 on the Arduino. Did that mean that All other files including the examples that
and I am in good company, but Seeedstu- the shield was now finally working? use the library must be placed in the folder
dio, the maker of my etherShield, had put It did (Figure 4). Phew. libraries\ to ensure they are recognized by
an ICSP pin header on the shield in the right the IDE as examples.
place. Replacing it with a female (socket Final remarks
style) connector on the solder side only Digilent have made a decent job of port- The source code files for the tests and
took a few minutes and restored SPI com- ing the PIC32 to the Arduino IDE. Although experiments described in this article can
patibility with the Max32. To prevent con- they did not achieve 100% compatibility, be downloaded from [4].
flicts on pins 11, 12 and 13 (MOSI, MISO & they definitely tried hard and managed to (110661)
SCK) I simply removed these pins from my get pretty close. Its safe to assume that
shield (Figure 3). Now it should work, right? simple Arduino shields with simple libraries Internet Links and Resources
Wrong. At this point I fired up the oscillo- respecting Arduino coding rules and style
scope because I suspected compatibility will be easily portable, although you may [1] http://chipkit.cc
issues between the SPI protocol as pro- run into some of the problems I encoun- [2] www.digilentinc.com
duced by the PIC32 and the one accepted by tered. The more complex shields exploit-
[3] http://arduino.cc
the ENC28J60. Notably the clock speed was ing AVR subtleties will definitely be more
worrying me slightly. The scope proved me difficult and may require solid PIC32 knowl- [4] www.elektor.com/110661
elektor 11-2011 17
TesT & MeasureMenT
The device we describe can be used with a more detailed investigation of the charac- a comparator, and which generates output
different sensors to measure gamma and teristics of a sample. The optional PC-based pulses that can be heard directly or pro-
alpha radiation. It is particularly suitable for software displays the energy spectrum, per- cessed further. The amplifier uses a BF245B
long-term measurements and for examin- mitting a very detailed analysis to be car- JFeT at its input followed by an opamp cir-
ing weakly radioactive samples. The pho- ried out. cuit, providing an overall voltage gain of
todiode has a smaller sensitive area than a 1 000. at the output it delivers pulses with
Geiger-Mller tube and so has a lower back- Preamplifier an amplitude of up to 200 mV with a pulse
ground count rate, which in turn means that In the June 2011 issue of elektor we width of around 0.5 ms, which can be ren-
the radiation from a small sample is easier described experiments using a BPW34 dered audible without further processing or
to detect against the background. photodiode as a detector for gamma radia- which can be used to drive a counter.
tion [1]. Only simple experiments could be The circuit (see Figure 1) can use several
a further advantage of a semiconductor carried out as the pulses from the detector photodiodes in parallel at its input. On
sensor is that is offers the possibility of mea- are very short. Here we look at an improved the one hand, this increases the pulse
suring the energy of each particle, allowing preamplifier design, which avoids the use of rate; unfortunately, this advantage is on
18 11-2011 elektor
TesT & MeasureMenT
Features
Measures alpha, beta and gamma radiation Threshold configurable in software from the PC
Simple construction using standard components Two different types of sensor can be used
PC connection using Elektor FT232R USB/Serial bridge
the other hand offset by BF245Bs source resistor, more or less inde- the gate of the JFeT being pulled to ground
the reduced amplitude pendent of the supply voltage. If a BF245C through a 20 M resistance.
of the sensors output is used, this voltage will be higher; in the
due to its increased total case of a BF245a, lower. This voltage level The counter
capacitance. is a suitable operating point for the opamp. The pulse counter is constructed using an
The JFeT input offers good signal-to-noise The capacitance of the photodiode drops aTmega88 and a two-line LCD. The power
ratio and a high input impedance. a DC as the voltage across it increases, and so it supply voltage of 9 V to 12 V is taken via D1
level of about 2 V or 3 V appears across the is operated at the full supply voltage, with (for reverse polarity protection) to voltage
R1 R2 R11
C1 1M 1k 100R
C6 C7
100n
D1
T1 100u 100u
BF245 3 8
3 K2
1 5
IC1.A
2 R6 7 COUNTER 2
C4 IC1.B
6 R8
C5
R14 4
47p 1
330k
47p GND
10M 330k
R3 R4 R5 R7
C2 C3
100n 100n
+5V
IC2
LCD1
D2 7805
K8 1N4004
2 C9
7 20
1
21 VCC AVCC
100n AREF
9V
IC4
VCC
VSS
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
R/W
VO
RS
1
A
C
E
PC6(RESET/PCINT14)
K1 28 1 2 3 4 5 6 7 8 9 10 11 12 13 14 L+ L-
3 PC5(ADC5/SCL/PCINT13)
27
2 COUNTER PC4(ADC4/SDA/PCINT12)
26
1 GND PC3(ADC3/PCINT11)
C8 25 2
PC2(ADC2/PCINT10) PD0(RXD/PCINT16)
24 3
PC1(ADC1/PCINT9) PD1(TXD/PCINT17)
10u ATMEGA88 R13
23 4
K4 PC0(ADC0/PCINT8) PD2(INT0/PCINT18) 5R6
2 5
PD3(INT1/OC2B/PCINT19)
1 19 6
PB5(SCK/PCINT5) PD4(T0/XCK/PCINT20)
K6 18 11
OUT PB4(MISO/PCINT4) PD5(T1/OC0B/PCINT21)
1 3 5 17 12
PB3(MOSI/OC2A/PCINT3) PD6(AIN0/OC0A/PCINT22)
S1 16 13
PB2(SS/OC1B/PCINT2) PD7(AIN1/PCINT23)
15
PB1(OC1A/PCINT1)
2 4 6 14
PB0(ICP1/CLKO/PCINT0)
ZERO ISP R10 R9 R12
K7
GND XTAL1 XTAL2 AGND K3 1
RXD
8 9 10 22
+5V K5 470R 470R TXD 100R
LED1 GND
Backlight 2
Elektor BOB
SPK
110538 - 11
elektor 11-2011 19
TesT & MeasureMenT
COMPONENT LIST
Resistors Semiconductors
r1 = 1M D1 = BPW34
r2 = 1k D2 = 1n4001
r3,r14 = 10M D3 = LeD, 5mm, green
r4 = 4.7k IC1 = aTmega88Pa-Pu (atmel), programmed
r5, r7 = 10k IC2 = LM358n
r6,r8 = 330k IC3 = 78L05 sound starts to get annoying.
r9,r10 = 470 T1 = BF245B
The unprocessed signal is also taken to con-
r11,r12 = 100
r13 = 5.6 Miscellaneous nector K4 via C8. This can be wired to a BnC
s1 = pushbutton, 1 make contact socket for to allow, for example, connection
Capacitors K1K8 = pinheader, e.g. Te-Connectivity type of an oscilloscope. alternatively, an audio
C1,C2,C3,C9 = 100nF 3-826926-6 amplifier can be connected, in which case
C4,C5 = 47pF LCD1 = DeM16217, elektor shop # 030451-72
particles of different energies will be distin-
C6,C7 = 100F 16V
C8 = 10F 16V guishable by their sounds.
SPK
R10 cable. This allows the sensor to be mounted
more easily in a light-tight enclosure.
K5
IC1
ATMEGA88
R9
D3 The LCD and pushbutton are mounted on
K8 the reverse of the board; all other compo-
C8
nents are mounted on the top side. sen-
K4
9V
I O
D2
-
R13 R12
OUT sor D1 can be mounted on whichever side
IC3
of the board is more convenient, bearing
in mind how the unit will subsequently be
K1 Backlight mounted in its enclosure.
1 K3
The circuit is best tested first without the
sensor diode fitted. The output of the
1 (c) Elektor C3
opamp circuit should be a mid-level DC
R4
IC2
C2
Sensor
T1 R14 K2
R11
32 1 C5
voltage, and the input should be so sensi-
C4
R2
D1
R1
tive that even moving a finger near it will
R7
R8
R3
C1
C6
R6 trigger the counter.
R5
C7 110538-2 V1.21
The sensor can now be mounted: Figure 3
shows it mounted on the reverse of the
board. The sensitive area of the device is
Figure 2. Printed circuit boards for the radiation meter. then under the lower right side of the board.
It is important to ensure that the BPW34
photodiode is fully shielded from incident
light and that the circuit area around the
regulator IC2, a 78L05, which generates the level and any incoming pulses that exceed diode is carefully screened. During con-
5 V supply for the microcontroller and the this level by at least a preset amount are struction fit a small piece of black insulating
sensor circuit. There is an IsP connector on counted. Button s1 starts a new measure- tape under the photodiode: this will block
the board to make software updates easy ment without resetting the stored quies- light that might otherwise pass through the
and there is a further connector to which cent level: this lets you first set the quies- not-quite-opaque printed circuit board. Fig-
a serial interface can be attached to allow cent level with the sensor not pointing at ure 4 shows the component side of the pop-
transfer of data and settings to and from the the sample of interest, and then start the ulated prototype board.
PC (K7). The rXD and TXD signals on this measurement proper with the sensor in aluminium foil can be used to screen the
connector are at TTL levels and compatible position. area around the photodiode, on both sides
with the FT232r usB serial bridge breakout any pulse that is counted also results in a of the board. The foil should be connected
board (BOB) published in the september visible indication on the LeD and on output to ground. This will give good shielding
2011 issue of Elektor. K5, where a small loudspeaker can be con- against both light and interference that
The sensor amplifier is attached at connec- nected for an audible indication. any loud- could otherwise lead to false counts. Fur-
tor K1. Its output signal, which is super- speaker with an impedance of between 8 ther pieces of insulating tape can be used
imposed on a quiescent DC level, is taken and 32 can be used, although it is a good under the aluminum foil to prevent shorts
directly to the aDC0 analog input of the idea to wire it in series with a volume con- to the rest of the circuit. The foil should be
microcontroller. at start-up the micro- trol (a 1 k potentiometer with a logarith- fitted tightly over the photodiode, as other-
controller determines the quiescent DC mic taper) in case after a while the ticking wise it is possible accidentally to construct
20 11-2011 elektor
TesT & MeasureMenT
a condenser microphone, with the counter active sample. Place a sample, for example through. However, we can replace the
responding to loud noises! The connection of a suitable mineral, directly in front of the BPW34 with a BPX61, with the glass win-
to the foil can be made, for example, using sensor. any gamma radiation emitted by dow removed. The photodiode itself is now
a bolt with two washers. the sample will give rise to pulses clearly vis- completely exposed and alpha particles can
We can now test the operation of the board ible above the background noise level. each now be detected, resulting in signals with
with the photodiode in its light-tight enclo- pulse whose amplitude exceeds a certain an amplitude some ten times greater than
sure. a DC level of about 2 V to 3 V should level will be counted. The threshold level those produced by gamma rays. The same
appear at its output. This serves to check can be adjusted later in the software. If you sensor amplifier can be used, but it must
Figure. Measuring the background count Figure 6. an individual pulse. Figure 7. Background noise and the
rate: 0.33 pulses per minute is normal. desired signal.
elektor 11-2011 21
TesT & MeasureMenT
Listing 1:
Averaging readings and setting M = M + 1
the trigger threshold Count = N
Count = Count / M
Readeeprom L , 1 Locate 2 , 10
If L = 255 Then L = 10 Lcd Count
U = 0 Lcd
For N = 1 To 1000 End If
D = Getadc(0) Locate 1 , 10
U = U + D Lcd N
Next N Locate 2 , 1
U = U / 1000 Lcd M
Um = U Lcd :
U0 = Um + L Lcd S
N = 0 Lcd
Listing 2: Listing 4:
Detecting a pulse Processing the received energy values
Do Private Sub Timer1_Timer()
Max = U0 While INBUFFER() > 0
Do d = READBYTE()
D = Getadc(0) bin(d) = bin(d) + 1
Loop Until D > U0 Wend Figure 8. screening.
Portb.0 = 1 For n = 1 To 255
Portb.1 = 1 x1 = 2 * n
If D > Max Then Max = D x2 = 2 * n + 2 reasonably easy to understand. The output
Do y1 = 200 - bin(n) voltage from the preamplifier in the qui-
D = Getadc(0) y2 = 200 - bin(n + 1) escent state is about 2 V, on top of which
If D > Max Then Max = D If y1 > 255 Then y1 = 255 we see the sensor pulses. In order to count
Loop Until D < U0 If y2 > 255 Then y2 = 255 these pulses we need to use some kind of
N = N + 1 Picture1.Line (x1, y1)- comparator, and the aTmega is fast enough
Max = Max - Um (x2, y2) to do this job in software. at start-up the
If Max > 255 Then Max = Next n unit computes an average background sig-
255 End Sub nal level by averaging 1000 readings (see
Print Chr(max); Listing 1). The averaged value u is then
Portb.0 = 0 increased by a trigger threshold increment
Portb.1 = 0 Listing 5: L to produce a threshold u0 which gives
Loop Setting the trigger threshold adequate margin over background noise
Private Sub Command2_Click() for reliable counting.
l = HScroll1.Value During the measurement itself (Listing 2)
Listing 3: SENDBYTE l the output of the software comparator
Timer processing and LCD output End Sub is also used to drive digital output ports
Tim1_isr: PortB.0 and PortB.1. an LeD is connected to
Timer1 = -7812 Private Sub Command4_Click() pin B.0 to give a brief flash of light for every
S = S + 1 l = 100 + HScroll1.Value pulse detected. an small loudspeaker can
If S = 60 Then SENDBYTE l be connected to B.1 with a resistor or a vol-
S = 0 End Sub ume control potentiometer in series.
The maximum level achieved by each pulse
is also measured and output as a single byte
over the serial interface, to which a PC can
extremely carefully as any damage to the peaks, up to 2 V, corresponding to alpha be connected. This single-byte format is
diode itself or to its bonding wires spells particles. smaller peaks can also be seen: chosen so that no extra time is wasted in
doom for the device. a lidded tin makes a the BPX61 is, like the BPW34, sensitive to data transmission. as a consequence the
good screened enclosure (Figure 8). The gamma rays too. Hence we can discriminate maximum pulse height that can be reported
metal must be connected to signal ground between the two types of radiation on the is 1.25 V, which corresponds to a byte value
so that it provides electrical shielding as well basis of the pulse amplitude. of 255. Pulses of greater amplitude than this
as screening from ambient light. The lid must are clipped to the maximum value.
of course be fitted before any readings can Firmware The display continuously shows the current
be taken. The firmware is available for free download counter value, updated once per second
The oscilloscope shows high-amplitude at [2]. It is written in BasCOM-aVr and is (Listing 3). accompanying this on the lower
22 11-2011 elektor
TesT & MeasureMenT
Figure 9. The alpha spectrum of a sample Figure 10. Gamma radiation: pitchblende Figure 11. Beta particle measurements
of pitchblende. behind a piece of aluminum foil. from a potassium chloride sample.
line of the display is the total time elapsed ure 9). The higher energy values are due readings over a long period using the BPX61
since the beginning of the measurement, to alpha particles: because of the relatively and a small sample of potassium chloride.
shown in minutes and seconds. at the end thick sample used these tend to lose a lot Ordinary potassium chloride contains a
of each full minute the program calculates of their energy on their way to the sensor, small percentage of radioactive potas-
the count rate in pulses per minute. and so no sharp energy lines are seen with sium-40. some 90 % of the disintegrations
The sensitivity of the unit depends chiefly this sample. When looking only at gamma produce beta particles with energies of up
on the threshold setting for the compara- rays using the BPW34 the higher energy to 1.3 MeV; the other 10 % produce gamma
tor. This is initially set at ten a/D conversion levels are empty; when alpha particles quanta with energies of 1.5 MeV. The beta
steps above the quiescent level, but the are detected they usually have an energy spectrum shows a characteristic falling-off
value can be modified if desired using the beyond the range of the display, which in energy up to a clearly-visible maximum
elektor 11-2011 23
HOME & GARDEN
In order to hear the sounds made by bats, lytic capacitor is used for this purpose in reduced to 220 nF, which places the
we have to make use of a few electronic the standard application circuit, but this is corner frequency at approximately
techniques. This is because bats use sounds only necessary if you want to amplify vir- 4 kHz. This means that in theory
in the ultrasonic range to detect objects tually the entire audio band with the same the capacitance could be made
while they are flying, and these sounds gain. That is not necessary for this applica- even smaller, which would reduce
are well outside the range of human hear- tion, so the value of capacitor C1 can be the risk of problems with low-fre-
ing. Many species of bats produce sounds
at frequencies in the 40 kHz range, which
happens to be the operating range of
most standard ultrasonic transducers. If VBAT
you amplify the signals picked up by one C7 C10
of these transducers and feed them into a C1 + C4 C12
100p 470p
frequency divider, the output will be within IC1
220n 220u R3 R5
16V 100p
1
C5 C6 150k 560k
8
5 2
LM386 C8 C9
10k
2 1 6
The circuit 2n2 1n5
3
IC2A
7
C11 P1
9
IC2B
4
R1 1n 470p
A type 400SR160 ultrasonic receiver was REC1 5 8
7
10R R2
R4 100n 22k IC2C
10
selected for the sensor, since most bats in
C2 C3
our part of the world produce sounds in a 1k3 1k
47n 47n
IC2=TL074ACN
range around 40 kHz. The author opted for
the inexpensive plastic version of this trans-
ducer, which can easily be protected with a
piece of aluminum foil or metallized adhe- VBAT VBAT
sive tape. R10 1N4148
LS1
The signal picked up by the transducer is R11 100R D2
R9
IC3 + C14
14
24 11-2011 elektor
HOME & GARDEN
quency noise.
+3
The output signal +0
from the amplifier passes -3
through a fairly steep high-pass -6
filter built around IC2a and IC2b. -9
COMPONENT LIST
Resistors C5 = 2.2nF MKT, lead pitch 5mm Miscellaneous
R1 = 10 C6 = 1.5nF MKT, lead pitch 5mm REC1 = 40kHz ultrasonic sensor (receiver) (e.g.
R2 = 1.3k C7,C12 = 100pF ceramic, lead pitch 5mm Prowave 400SR16P, diam. 16 mm)
R3 = 150k C8 = 1nF MKT, lead pitch 5mm LS1,S1,BT1 = 2-pin pinheader, lead pitch 0.1
R4,R7,R9 = 1k C9,C10 = 470pF ceramic, lead pitch 5mm inch (2.54mm)
R5 = 560k C11 = 100nF MKT, lead pitch 5mm 3 pcs 2-pin connector (for loudspeakers,
R6 = 10k C13 = 33nF MKT, lead pitch 5mm switch and battery)
R8 = 470k C14,C15,C16 = 100F 25V radial, lead pitch LS1 = loudspeaker 8/0.3W, diam. 20mm
R10 = 100 2.5mm (e.g. Kingstate KDMG20008)
R11,R12 = 47k S1 = slide switch, 1 make contact
P1 = 22k preset, vertical mounting Semiconductors BT1 = 9V battery with clipon lead
D1,D2 = 1N4148 PCB # 110550-1 (see www.elektor.
Capacitors T1 = BC337-40 com/110550)
C1 = 220nF MKT, lead pitch 5mm IC1 = LM386N-3
C2,C3 = 47nF MKT, lead pitch 5mm IC2 = TL074CN
C4 = 220F 16V radial, lead pitch 2.5mm IC3 = 4024
Figure 3. The PCB for the circuit is long and thin to enable it to fit in a length of PVC pipe.
elektor 11-2011 25
HOME & GARDEN
clock input of a type 4024 seven-stage speaker and switch can be fitted on an end Simply rubbing your thumb and forefinger
binary counter. The signal on the CT3 out- cap as illustrated in Figure 4. If you fit three together, zipping a plastic bag (such as a
put (pin 16) is the clock input divided by 16. self-adhesive rubber feet on the bottom, sandwich bag) or shaking a bunch of keys
It consists of pulses in the audible range (2 you can stand the pipe upright on a garden will generate enough ultrasonic energy to
to 3 kHz), which are fed via T1 to the loud- table, and whenever any bats fly overhead be detected by the circuit at a distance of
speaker to generate an acoustic output. you will hear them right away. several meters.
Diode D1 is included for protection against
negative voltages on base of the transis- The sensitivity can be adjusted with the Bats are rather loud and can be detected at
tor. Resistor R7 limits the drive current that trimpot. It should be set to minimize or distances of 100 feet (30 meters) or more
IC3 supplies to T1. A free-wheeling diode is eliminate any ticking sounds from the with this circuit. The various sounds pro-
connected in parallel with the loudspeaker speaker. When making the adjustment, take duced by bats can also be clearly recognized
(LS1) to protect transistor T1 from volt- care to avoid undesirable sources of ultra- with this detector.
age spikes generated by the inductance of sonic energy in the immediate vicinity, such (110550)
the speaker coil. You can also use a small as fluorescent lamps, television sets, com-
piezoelectric buzzer for LS1. Resistor R9 is puter monitors, switch-mode power sup-
Internet Link
included to ensure proper operation of a plies and so on. They can be detected at
piezoelectric buzzer, as otherwise the out- distances of 10 to 20 feet ( 3 to 6 meters). [1] www.ti.com/tool/filterpro
put would be mute because piezoelectric
buzzers are highly capacitive. Decoupling
network (R10/C14) in the speaker supply
line suppresses noise on the supply voltage
rail, which is necessary because the input
stage is very sensitive.
Mini PCB
The PCB layout designed for the bat detec-
tor is shown in Figure 3. The 9 V battery can
be fitted on the bottom of the board. The
PCB has a ground plane on the top side to
provide screening, which is necessary due
to the relatively high input sensitivity.
The board is dimensioned to fit in a length
of standard PVC pipe with an inside diame-
ter of 33 to 35 mm, which can be purchased
in any home improvement shop. Matching
end caps are also available, and a small loud- Figure 4. The on/off switch and a speaker are fitted in the end cap.
26 11-2011 elektor
elektor 11-2011 27
Microcontrollers
Audio Guide
First steps with Platino
Audio guides can be borrowed or rented in many museums: devices
containing spoken information about the objects in
the exhibition. In this article we describe such an
audio guide, but this is a very special one:
it detects the object using RFID. The
wearer only needs to
come in the vicinity
of the object and will
then automatically
hear the correct
details and
explanation regarding
the work (of art).
Here, we use two ready-made boards: a Pla- up wirelessly by the RFID reader. Based on documentation provided by the manufac-
tino [3], which forms the brains of this cir- this code the software retrieves the corre- turer [7]. The rMP3 is fitted with a 3.5-mm
cuit, and an rMP3-module [2], which takes sponding audio file from the database and socket for headphones or a set of speakers
care of the sound. With the latter you can automatically plays it back. of at least 16
playback audio files that you have recorded
beforehand on a memory card. An rMP3 Reading MP3s Get cracking! While the rMP3 has been
supports SD-, SDHC- and MMC-cards from The rMP3-module is a so-called Arduino- designed to be plugged straight into an
8 MB to 32 GB. You can see the design of the shield, a board that you select as a shield Arduino (or the Platino, which is compatible
whole unit in the block diagram of Figure 1. in the headers of an Arduino and is there- with that), you nevertheless have to make
The Platino and the rMP3 communicate fore also completely compatible with it. a small modification before you do that.
with each other via the serial TTL-connec- The rMP3 has a holder for an SD-card. You Thats because we are driving the sound
tion. The method has some similarities to can play back MP3s stored on this card, module from USART0, one of the two serial
when sounds are produced from a mobile but a few common WAV-formats are also ports on board of the ATmega1284P on the
phone or a PC: when a certain event occurs supported. The module obeys commands Platino. Thats why RXD0 and TXD0 have to
we play back a certain sound (file). The which are sent to it via an asynchronous be rerouted to TX and RX respectively of the
event, in this case, is when the antenna serial connection. With these commands rMP3. In Figure 2 you can see the two pins
[6] of the RFID-reader [4] inside the Audio you can read MP3-files, queuing the next which have been cut off; the orange wire
Guide comes in the vicinity of a certain file, fast forward, pause playback, adjust connects leg 0/R (RXD0) to pin 6 (TX on the
object a painting, or whatever. Inside the volume, etcetera. You can of course rMP3); the yellow wire connects 1/T (TXD0)
or nearby that object is a transponder [5], also use the memory card as a storage unit. to pin 7 (Rx-MP3).
also known as RFID tag. This tag contains a The possibilities are endless! We also (heart- If necessary, begin by formatting the SD-
unique identification code which is picked ily) recommend that you read the online card as FAT32. In the root directory of the
28 11-2011 elektor
Microcontrollers
elektor 11-2011 29
Microcontrollers
Figure 4. Solder bridges on the copper side of the Platino.. Figure 5. ...and one more on the other side.
serial connection. An external programmer green LED lights up and the buzzer sounds
[9] is connected via K3, a 6-pin HE10 con- the moment the RFID-card has been rec-
nector. The lines MOSI, MISO and SCK that ognized. With the program 110544-I_
arrive at that connector have to routed to audioguide_firmware_v1.2.bas belongs
PB5, PB6 and PB7 respectively via jumpers an ASCII-file called tags.txt. This contains
JP13, JP12 and JP11. the identification number, the title and the
The power supply voltage for the entire Figure 6. ID=0 means that this creator of the object as it will appear on the
assembly is connected with the ground to transponder has not yet been registered. LCD, see Listing 1. These codes are included
K9-1 and the positive to K8-3. The rMP3 during compilation thanks to the instruc-
gets +5 volts, which is configured with a tion $include tags.txt. The corresponding
solder bridge at JP14 for the positive. MP3 sound files on the SD-card have to be
named IDx.mp3, where x is the index num-
ber (the number in brackets) in tags.txt.
Everything working together For example, the file ID4.mp3 belongs with
Every individual object that needs to be the painting The first steps by Vincent van
recognized has to be fitted with a unique Gogh. Note that the file names are not case
transponder. When the Audio Guide comes sensitive.
in the vicinity the transponder, the cor- The sound volume is adjustable from 0 to
responding audio file will be played back Figure 7. A handy little aid: 100 in steps of 5 with the use of the rotary
through the headphones or speakers. The PaMus MP3 Recorder. button. The rotary button does not only
30 11-2011 elektor
Advertisement
operate in the two rotary directions, clockwise (CW) and coun-
ter clockwise (CCW), but you can also push it, which is equivalent
to the closing of S4C. This is used to stop the playback. Pushing it
again will start the playback. The file that will play, is the one that
corresponds to the ID number that is shown on the first line at that
time. As soon as the playback starts, the title and creator appear on
the display. In this way you can also listen to the narration without
having to be in the vicinity of the corresponding object, or you can
repeat certain parts of the text.
The transponder that is stored in the first position (under RFID(1))
starts the file ID1.mp3. You can use this one to adjust the sound
volume with the aid of the rotary button. You can use any music
file of your liking.
We assume that by now you have already loaded the SD-card
with MP3s with ID 1 though 6. When you now load the firmware
(110544-I_audioguide_firmware_v1.2.hex) for the first time then
the Audio Guide only operates under manual control. Even though
the system can pick up the transponder codes, it does not know
which index number belongs with which transponder from the
softwares perspective all transponders still have ID0.
Now it is very handy that, as a preparation step, you give each tran-
sponder a sequence number and arrange them side by side and
in order. Now open the file tags.txt in a text editor, for example
Notepad. Now hold the RFID antenna near the first transponder and
copy the hex ID on the display into tags.txt. Repeat this for all the
transponders. Save tags.txt and then compile and download the
firmware again. The Audio Guide is now ready for use, which you
can check by passing the antenna over each transponder in turn.
The firmware has space for up to 96 transponders, in the code, the
constant maxi has to indicate the correct number. You can see the
const maxi = 6 for the six tags in our example.
MP3 Recorder
The author uses the program PaMus MP3 recorder [10] to record
spoken text directly from a microphone into an MP3-file. This
is very easy to use, just like a tape recorder (Figure 7). You can
choose from three levels of sound quality, files are automatically
generated and you can rename or erase them from within the
program. If you rather not work with French-language software
then you can choose something else yourself from the countless
other options available on the internet. Search for mp3 recorder
open source for free software.
(110544)
Internet Links
[1] www.elektor.com/110544
[2] www.lextronic.fr/
P18805-module-de-restitution-rmp3-pour-arduino.html
[3] www.elektor.com/100892
[4] www.elektor.com/products/kits-modules/modules/
080910-91-rfid-savvy.925192.lynkx
[5] www.lextronic.fr/P1503-carte-transpondeur-rfid-card1.html
[6] www.lextronic.fr/P1478-antenne-rfid-125-khz-ant-rfid2.html
[7] www.roguerobotics.com/wikidocs/rmp3/start
[8] www.elektor.com/080910
[9] www.elektor.com/080083
[10] http://papiermusique.fr/dossier03.php
elektor 11-2011 31
DSP CourSe
By Alexander Potchinkov (Germany) Figure 1 illustrates this array of peripherals protocol used by the SRC. Then the DSP
connected to the central DSP. The solid lines can reset the SRC and send the necessary
show paths where data transfer takes place 54-byte configuration sequence.
The first of the two parts of the software we and the dotted lines show control paths.
shall call the framework, and is the same for The control paths are used by the DSP to The SEEPROM can be used for general-pur-
all applications. The second part, the audio configure the peripherals and to request pose non-volatile storage. If the DSP board
loop, is concerned with the audio signal pro- status information from them. is to be used in a stand-alone application
cessing proper, and has to be developed anew (that is, without the use of the debugger)
for each project within this course and for A clock signal is made available to the with fixed application code then it is pos-
any application you might design. Both these ADC, from which the sample rate and data sible to arrange matters so that the DSP
terms were introduced in the second article in transfer timings are derived. The ADC is boots from the SEEPROM, taking advantage
this series. We will now look at how they are capable of determining the ratio between of the bootloader code stored in the DSPs
applied in the context of the DSP board and the master clock frequency and sample rate on-board ROM.
of the applications developed in this course. by itself and this value therefore does not
need to be configured. In our case the ratio The SPI port can be used to transfer data to
Framework tasks is 512. and from devices external to the DSP board.
The first job of the framework code is to For the digital signal level meter application
initialize the DSP itself. This involves con- The DAC is also provided with a clock in this course we use the SPI port to drive
figuring the processor clock frequency and signal, and, as with the ADC, it is able to an LED bargraph display. We could also
the interrupt system, setting up a software determine the master clock to sample rate use the SPI port to connect to an external
stack and various other tasks. The next job ratio autonomously and configure itself microcontroller with keypad, digital poten-
is to establish connections to the peripheral accordingly. tiometer (rotary encoder) and LCD to allow
devices on the DSP board so that audio and the parameters of a program running on the
control data can be passed to and fro. This The SRC is not capable of such indepen- DSP to be adjusted interactively, for exam-
requires writing to various registers in the dent operation as the ADC or DAC, and ple altering the frequency of the sine wave
DSP to configure the processors interface requires some configuration. We gave the output in our signal generator application.
hardware to suit the peripherals. In effect byte sequence necessary to configure the
the task of the framework is to initialize all I2S and digital audio interfaces in the SRC in Structure of the framework code
the hardware on the board and put it into a the third article in this series. The DSP con- The framework can be divided into four
state where it can be used without further figures the SRC over its SPI port as part of parts.
ado. In our case we have to take account of the framework code, and in order to do this
the needs of five peripheral components: the DSP must first configure its SPI port to 1. General declarations
ADC, DAC, SRC, SEEPROM and SPI port. be compatible with the communications Defining the memory map: fixed areas
32 11-2011 elektor
DSP CourSe
are provided All interrupts are disabled while the pro- uring the PLL multiplier and divider values
for program vari- cessor configuration is changed. This avoids it is important to bear in mind that the VCO
ables and parameters. the possibility of the processor crashing or only operates reliably between 300 MHz
Assigning values to other unexpected operations if an interrupt and 600 MHz; we operate the VCO at a fre-
constants required by the should be generated before the core and quency of 589.824 MHz. The manual pro-
program. peripheral registers are properly initialized. vides tables that give advice on suitable
Setting up the entries in the interrupt settings for common audio sample rates. If
vector table as given in the file ivt.asm. The hardware stack pointer (sp) is reset non-standard frequencies are to be used the
and the software stack is set up in ascend- calculations must be done manually. Based
2. DSP setup ing locations in X-RAM starting at address on the fact that the board is populated with
Setting up the DSP itself, which includes $40. a 24.576 MHz crystal oscillator module the
configuring the processor core and the Setting up the DSP and its peripheral inter- correct PLL configuration is obtained by set-
peripheral interfaces, is done by program- faces is a tedious task, which is a reflection ting PCTL=#$01E006 which results in an
ming the 24-bit registers that lie at the of the flexibility of the device and its range overall clock multiplication factor of 6.
top of the processors address space from
$FFFF80 to $FFFFFF.
This range covers a total of 128 locations
of which we use up to 18. The processor Oscillator
24.576MHz
manufacturer refers to this address range
as internal I/O memory. In the 52-pin
DSP56374 device that we use only the
X-RAM locations are used. The locations Signal Processor DSP56374
are written to using the special instruc-
tion movep (move peripheral data) which Audio- SPI- Timer-
Port Port Port H Port
allows values to be written directly to the ESAI SHI TIO00
register without the overhead incurred by
the normal move instruction of transferring
the value via a CPU register. For example,
the instruction movep #$D17D00,x:RCR SPI-Port
ADC
writes the specified value directly to RCR external
CS5340 DAC SEEPROM Devices
(Receive Control Register), which controls PCM1781 SRC M95M01
SRC4392
the characteristics of the receiver part of the
110005 - 11
audio interface.
Here RCR is a handy and easy-to-remem- Figure 1. An array of peripherals connected to the DSP.
ber abbreviation (much like the mnemon-
ics used for assembler instructions) for
the address $FFFFBF. To make the job of of possible applications. There is no deny- The instruction sequence movec #0,sp,
the programmer easier all our programs ing that setting up the processor properly move #$40,r6 and move #-1,m6 resets
make use of the auxiliary file mioequ. demands extensive study of the manuals the hardware stack pointer and initializes
asm, which contains (among other things) and can be a significant hurdle to the begin- the software stack.
similar abbreviations for all the I/O register ner. Fortunately, however, the processor is
addresses. A suitable include directive to logically designed and Freescales manuals Setting IPRP=#$000003 allows the
the assembler makes the abbreviations in are well written. A complete step-by-step interrupt system to respond to interrupts
the file available to our program. description of what is required would far from the audio interface at priority level 2.
exceed the space we have available, and so We do not use the core interrupts in the
The program starts at address $000000, we discuss below only the most important programs in this course.
which is the value of the DSPs program aspects of the set-up process.
counter immediately after reset. The first The audio interface is configured for
instruction is a branch to program address Processor clock PLL configuration. operation in master mode with a mas-
$000100, thus skipping over the interrupt The processor clock frequency is set to ter clock frequency of 24.576 MHz, in I2S
vector table and other paraphernalia asso- 147.456 MHz, which is six times the audio network mode with two channels car-
ciated with the DSP core. Then the program master clock frequency and 3072 times the rying 24 bit left-aligned data in 32 bit
proper begins. audio sample rate of 48 kHz. When config- frames. Interrupts are set up for recep-
elektor 11-2011 33
DSP CourSe
tion and transmission, error handling and the final part of the framework program. end of the audio loop and then observe it
last slot (right channel). The receive and The code is in the source file esai4R2T. as if we were using a digital audio oscillo-
transmit control registers are set to the asm. scope. This is a great help when it comes
same values: RCCR=TCCR=$FDD302 and to tracking down bugs in the signal pro-
RCR=TCR=$D17D00. The registers RSMA, The audio loop cessing code. To capture the output the
TSMB, RSMA and TSMB allow the network- The audio loop contains the digital signal author uses a simple low-cost USB sound
mode channels (up to 32 of them) to be processing code and is embedded within card (available for considerably less than
individually enabled or disabled for trans- the framework code. We will adopt the prin- 100) in conjunction with a waveform edi-
mission or reception. By setting all these ciple of reflecting the block structure of the tor program. Commercial waveform edi-
registers to the value $00FFFF we enable processing to be done through the use of tors are available, or there are several free
all possible channels, of which we use just subroutines, where each processing block editors and analyzers available for down-
two. Setting PCRC=PRRC=#$000FFF con- is embodied in one subroutine. The repre- load on the internet. The software allows
figures Port C as an audio port. It is also pos- sentation of a processing chain as a series of one or more signals to be inspected in
sible to configure individual pins on port C blocks will be familiar to analog designers. the time domain or converted to the fre-
as GPIOs that can be accessed via the audio quency domain to allow a spectrum to be
connector. Each of our subroutines therefore has viewed, and thus can be used as a pow-
input signals and output signals. In erful replacement for an ordinary oscil-
The SHI interface is configured in mas- the example below we shall deal with loscope. Spectral analysis is particularly
ter SPI mode with a clock frequency of four signals, called SignalInL/R and useful for analyzing distortion, for exam-
0.9216 MHz. Interrupts are not used, CPOL SignalOutL/R. Note that not all subrou- ple in the output of a sine wave generator.
and CPHA are both set to zero, and the nar- tines will have input signals: for example It is also possible to use a waveform editor
row spike filter and the FIFO are disabled. a signal generator will only have outputs. to create sound files and carry out various
For programming the SRC: 8-bit data, with In our projects signals are represented by kinds of processing on them.
HCKR=#$002048 and HCSR=#$000040. samples with 24 bits of precision, each
For controlling the LED bargraph display: occupying one location in memory within These files can then be loaded into a numer-
16-bit data, with HCKR=#$002048 and a dedicated area in the DSPs RAM. A sub- ical computing package such as MATLAB
HCSR=#$000044. routine may also have one or more param- after which the sky is the limit! Such a set-
eters or settings that affect its operation. up could be used to test the characteristics
Port H is used for the SRC and the SEE- An example of such a parameter might of a dynamics processor using signal bursts
PROM and for setting the boot mode. be the time constant of a filter. Figure 2 of varying duration, frequency and ampli-
PH4: GPIO input, lock signal from SRC4392. shows an example of how subroutines can tude. Since the DSP board includes a DAC,
PH3: GPIO output, reset signal to SRC4392. be connected together. we could equally observe the signals using
PH2: used as MODC to select the boot mode an ordinary analog oscilloscope, although
of the DSP. There are four subroutines in the exam- this approach is better suited to giving an
PH1: GPIO output, chip select to the ple, labeled from A to D, each repre- overview of a circuits performance than a
SRC4392. senting a signal processing block. The precise and detailed analysis.
PH0: GPIO output, chip select to the small rectangular boxes in the middle of
M95M01 SEEPROM. the figure are the subroutines, connected The ADC is connected to SDI1 (SDO4) and
This configuration is obtained by setting together via signal paths. The boxes with the SRC to SDI2 (SDO3). The receive buffer,
PCRH=#$000014 and PRRH=#$00000F. rounded corners symbolise parameters which occupies four locations in memory, is
of the subroutines. Some subroutines do laid out as follows.
3. Final set-up not require any parameters: this is the
before entering the audio loop case for subroutine C in the illustration. x:RxBuffBase
Interrupts (and in particular the audio The pointed boxes contain the signals ADC, left channel
interrupts) are enabled so that the audio passed between the subroutines. These x:RxBuffBase+1
buffer is read and written and the flag syn- signals have a dedicated storage area in SRC.RX, left channel
chronization system for received audio data the DSPs memory which makes it possi- x:RxBuffBase+2
is initialized. ble to observe their values at any point in ADC, right channel
time. We have constructed the block dia- x:RxBuffBase+3
The SRC is configured over the SHI in SPI gram so that it is possible to examine the SRC.RX, right channel
mode. function of the system in more detail by
observing the signal at these monitoring The DAC and the AES3 encoder, whose
4. Interrupt service routine points. For example, we can copy any one transmitter circuit is in the SRC, are con-
The interrupt service routine code forms of these signals to the audio buffer at the nected to SDO0. The transmit buffer occu-
34 11-2011 elektor
DSP CourSe
Signals 1
Parameter A Subroutine A
Signals 2
x:TxBuffBase Signals 3
DAC and SRC.TX, left channel
Subroutine C
x:TxBuffBase+1
DAC and SRC.TX, right channel
Signals 4
buffers.
elektor 11-2011 35
DSP CourSe
Subroutines is the routine ZeroState, which sets the is local to the macro itself.
A signal processing subroutine has the fol- memory storing the state of the signal
lowing structure. processing routines to zero. The second is Labels, unlike keywords, are case
called SetDefaultParams and sets up sensitive.
NameOfSubroutine the default values of the signal processing DSP instructions can appear from the sec-
move y:SignalInL, x0 parameters. The values used in this routine ond text column onwards.
move y:SignalInR, y0 can be changed to adapt the system for a
<signal processing code, particular application; alternatively, param- The file mioequ.asm can be included in a
possibly dependent on parameters> eter values can be modified using an input DSP program using an include directive.
move x0, y:SignalOutL device connected to the SPI port. This file defines a large number of abbrevi-
move y0, y:SignalOutR ated names for the interface registers in the
rts Loading and executing the DSP.
program
The subroutine is called using the instruction Once a DSP program has been written it The first usable address for program code
jsr NameOfSubroutine. The jsr (jump must be assembled and checked for errors. is p:$100: below this address are the inter-
to subroutine) instruction tells the DSP to This can be done in the command window rupt vector table and other reserved areas.
push the program counter and processor using the following command.
status register onto the hardware stack and The org directive can be used to specify
branch to the subroutine. The subroutine asm56300 a b l myprogram.asm the use of X, Y, P or L memory.
terminates with an rts (return from subrou-
tine) instruction which causes the processor The l option tells the assembler to gener- The processor has an instruction pipe-
to restore the program counter and status ate a listing file, which is often useful when line which greatly speeds up code execu-
register from the hardware stack, thus allow- trying to locate errors. Assuming there are tion as long as it is not disturbed by pro-
ing execution of the calling code to continue. no errors, the assembled code in the file gram branches or long interrupts. Because
Parameters may be passed to the subroutine myprogram.cld can be loaded into the of this pipeline, the assembler is sometimes
using the software stack. debugger to which the DSP board is con- obliged to introduce additional nop instruc-
nected. From there, using an adapter, the tions into the code. When this happens it
Macros code can be transferred to the DSP itself and reports a warning to the programmer that
The DSP assembler has a text macro facility. executed. there may be an opportunity to improve
The contents of a macro are inserted into the efficiency of the code by reordering it
the program code at each point where it is Handy hints so that the nop instructions can be replaced
called. A macro is declared as follows. by instructions that do useful work.
Using the assembler
NameOfMacro macro param1 param2 The assembler interprets text starting in At the end of the processor manual there
... paramN the first column of a line as a label. A label is a number of so-called programming
... must being with a letter, and reserved sheets which greatly simplify program-
endm words such as move or a0 are not allowed ming the processors registers. We would
as labels. recommend any programmer to take
A macro is called by simply giving its name advantage of these sheets: they can easily
followed by any parameters. The use of The assembler is of the two pass variety. be printed off from the PDF manual, used
macros can make programs easier to read, A two-pass assembler first looks through during the development of a program, and
especially when parameters are used. How- the code building a symbol table, which then finally attached to the other program
ever, they do not result in a reduction in is a list of the locations of all labels used. In documentation.
code size. This is in contrast to subroutines, the second pass it assembles the code itself,
which can help both to make code more using the values stored in the symbol table Programming the DSP
readable and to make it smaller. On the to resolve forward references, where a It is not possible to move immedi-
other hand, subroutines consume processor label is defined after it is first referred to in ate data directly to memory: instruc-
clock cycles in the stack operations involved the assembler source file. Without the sym- tions like move #$123456,x:$000100
in calling them and returning from them. bol table from the first pass it would not be do not exist. Instead, a register must be
possible to resolve these labels as their val- used as a staging-post, for example using
Initialization of the signal ues would not be known. move #$123456,x0 followed by move
processing code x0,x:$000100. There are, however, spe-
Two subroutines are called immediately Labels starting with an underscore (_) cial instructions for moving values directly
before the audio loop is entered. The first are useful when writing macros: their scope to addresses in the peripheral register area
36 11-2011 elektor
Table 1. Memory map used by the software in the course
X-RAM use Y-RAM use Region P-RAM use
Audio RX buffer Signals $00 to $0F
Audio TX buffer Signals $10 to $1F
Audio flags and pointers Pointers, coefficients, status storage $20 to $2F
Program parameters $30 to $3F
Interrupt vector table
Software stack Free for application use $40 to $4F
and
Software stack Free for application use $50 to $5F
reserved areas
Free for application use $60 to $9F
Auxiliary variables $A0 to $BF
SRC boot sequence Free for application use $C0 to $CF
Free for application use $D0 to $FF
Filter and polynomial coefficients $100 to $5FF
Circular buffer, left Circular buffer, right $600 to $7FF
Application program
Sine wave, 1 kHz Sine wave, 2 kHz $800 to $8BF
Free for application use $8C0 to $17FF
at the top of the memory map, such as used. This is because there are only three them into a processor register (in this case
movep #$123456,x:$FFFFE0. bits available in the instruction encod- the operand register x0) shortly before they
ing to specify them rather than the four are required: this can often be done using a
A register must again be used for interme- that would be required. So for example parallel move instruction.
diate storage when moving data from one mpy x0,x0,a and mac x0,y1,b both
memory location to another, for example exist, but neither mpy x1,x1,a nor mpy Looking at a program for the DSP it is
move x:$000010,x0 followed by move y1,x0,b is possible. clear that a very large number of move
x0,y:$000010. However, memory-to- instructions are used. One of the reasons
memory transfers within the peripheral Fast interrupts should not be terminated for this is that the CPU is register-based.
register area are possible. by an rti instruction. This in turn means that it is important to
take full advantage of the DSPs capabil-
The instruction move #$F,x0 does not We have reserved address register R6 for ity to do parallel moves. In general this
result in the perhaps expected outcome use as a pointer to the software stack, which means that a value is loaded into a regis-
x0=$00000F, but rather in x0=$0F0000. starts at address X:$40. The software stack ter in advance of (sometimes considerably
The instruction move #>$F,x0 gives the is particularly useful when manipulating the in advance of) its use, whenever there is a
right-aligned result. The DSP is designed to AGU registers in a subroutine. It is a com- suitable arithmetic operation available to
work with fractional values, which means mon schoolboy error to set up an address which the move can be attached. Unfortu-
that numbers are in general left-aligned. register for modulo addressing inside a sub- nately this kind of optimization makes pro-
routine and forget to reset its mode before gram code rather hard to follow, since dif-
Nested do loops must use distinct labels. leaving the routine, giving rise to unex- ferent parts of what might be considered
Furthermore, there must be at least a nop pected operation elsewhere in the code. a single operation are separated from one
instruction between the two labels if other- another in the source file.
wise no code would appear there. The hardware stack pointer sp should be
reset to zero during initialization. A few years of experience of programming
P-RAM should not normally be used for DSPs has taught us that the commonest pro-
data storage as accessing it incurs an extra In particularly time-critical applications gramming error is inadvertently using the
penalty in processor cycles. it is best to try to avoid the use of instruc- same memory location for more than one pur-
tion extensions. An instruction extension pose. We therefore recommend that program-
When integer values are multiplied, for is an second word added to an instruc- mers draw up a detailed and exhaustive mem-
example in address calculations, it is neces- tion, for example containing an address or ory map for each program they write. Also, our
sary to halve the result by arithmetic-shift- an immediate value. The instruction mpyi preferred approach of allocating dedicated
ing it right one place using an asr instruc- #0.3,x1,a requires an extension word to memory areas to groups of variables, while not
tion. This again is because the DSPs multi- store the immediate value 0.3 and so the exactly economical in memory use, neverthe-
plier is designed for left-aligned fractions, instruction occupies a total of two words in less can help avoid many simple errors.
not right-aligned integer values. program memory. In contrast, the instruc- For later programs it will prove useful to write
tion mpy x0,x1,a only occupies one two routines to push and pop the ten datapath
The three-operand instructions mac and word of program memory. It is normally registers (x0, y0, x1, y1, a0, b0,
mpy do not allow all sixteen possible com- preferable to store constants in the DSPs a1, b1, a2, and b2) to and from the soft-
binations of source operand registers to be RAM during program initialization and load ware stack. These routines can then be used in
elektor 11-2011 37
DSP CourSe
subroutines to avoid unwanted side effects on bits to the left (if it is positive) or one bits to gle precision on the DSP. But what hap-
these registers should they be used by the call- the left (if it is negative); we can extend a pens when we multiply together two signal
ing program. fraction without changing its value by add- sample values or if we want to implement
ing zero bits to the right, whether the value a simple 20 dB attenuator? In both cases
How samples are represented is positive or negative. Observant readers the multiplication produces a result in dou-
in the DSP will have noticed that the extreme positive ble precision with a word length of 48 bits.
Signal samples in the DSP are represented and negative representable values have dif- Compare with multiplying two numbers on
using a special numeric format. The binary ferent magnitudes. This sometimes causes the four-bit DSP:
point is immediately after the top bit, which difficulties as the clipping level depends
is used as the sign bit. The only difference on the sign of the signal. In the case of our 0.010 * 0.001 representing
between this format and the usual represen- 24-bit DSP the difference in magnitude is 0.25*0.125= 0.03125
tation of integers is that with normal integers just 223= 1.192110-7, which is in many 0.000 0100 representing 0.03125
there is no binary point (or you can imag- cases small enough to be ignored.
ine a binary point immediately to the right Now let us look at how the fractional repre- The result has eight digits.
of the integer value). The DSPs format is sentation is used. We will imagine a DSP-lite With this in mind we can revisit one of the
called twos complement fractional, or just working with four-bit values (single preci- hints given earlier. If we want to multiply
fractional, representation. The difference sion) and eight-bit values (double preci- two integer values together, for example
between twos complement representation sion). We will interpret the values in exactly in a memory address calculation, the result
of integers and the fractional format can be the same way as the full-fat 24-bit DSP: the from the DSPs multiplier has to be shifted
illustrated simply using four-bit values. There only difference will be in the resolution (that to obtain the correct answer. Looking again
are sixteen different four-bit values, of which is, the difference between consecutive rep- at the example above, thinking of the values
seven represent positive numbers and eight resentable values). One common job the as integers:
represent negative numbers, leaving one DSP has to do is requantization. In our
representation of zero: see Table 2. example this means converting an eight-bit 0010 * 0001 representing 2*1= 2
value to a four-bit value. Suppose the eight- 0000 0100 representing 4,
For clarity we have marked the sign bit in bit value is 0.100 0100, representing a value the result produced by the
the table and included the binary point in of 1/2+1/32 = 0.53125. One way to requan- fractional multiplier
the fractional representations. The values tize this value is simply to drop the last four 0000 0010 representing 2,
represented differ only in the significance digits, leaving the value 0.100, which rep- the correct result obtained
of each bit. From left to right, the bits after resents 1/2 = 0.5. That might not seem too by arithmetic-shifting the
the sign bit in the integer representation impressive, but readers are invited to con- multipliers output right by
have significances of 4, 2 and 1 while in the sider how a similar task would be done with one place
fractional representation the bits after the integer values.
binary point have significances of 1/2, 1/4 Coming soon...
and 1/8. In the integer format values are Back to the real DSP: in single precision it Now that we have described the structure
naturally right-aligned while in the frac- calculates to 24 bits of accuracy and in dou- of DSP programs, we will move on in the
tional format they are naturally left-aligned. ble precision to 48 bits. We know that the next installment to make the DSP board into
This means that we can extend an integer preferred basic word length for digital audio an audio signal generator.
without changing its value by adding zero processing is 24 bits, corresponding to sin- (110005)
38 11-2011 elektor
- you can do it yourself!
NEW! Build this Sure Electronics 30 watt Class-D power
amplier for pristine, accurate audio reproduction!
Uses the TPA3122D2 15 watt per channel Class-D audio amplier chip.
#320-322
Includes board and all components. Assembly is required.
elektor 11-2011 39
MiCroControllerS
OnCE/JTAG Interface
Program and debug
Freescale DSPs
20
31
42
56
11 9
Chip Emulation). To keep the DSP board
4
+1V8 16 8 12 K2
VPLL
VCCIO
VCCIO
VCCIO
VCCIO
VPHY
VCORE
VCORE
VCORE
ADBUS0
17 6 14 TDI 1 2
as compact as possible, no direct interface 14
RESET
ADBUS1
ADBUS2
18 4 16 TDO 3 4
19 2 18 TCK 5 6
for connection to a PC was added to the C4 C5 C6 C3
50
VREG N
ADBUS3
ADBUS4
21
+3V3
1D1
7 8
22 JTAG/OnCE RESET 9 10
board. Freescale does have several pro- 100n 100n 100n 3u3
49
VREGOUT
ADBUS5
ADBUS6
23 19
EN2
11 12
24 1 13 14
gramming adapters for sale, but they tend K1
R1
ADBUS7
R11
EN1
OnCE
1 7 26 74AC244 TMS
to be rather expensive. Those of you who 2
10R DM ACBUS0
ACBUS1
27
3 28 270R
have already used an evaluation kit from 4
R2
10R
8
DP
ACBUS2
ACBUS3
29
+3V3
D1 D2 30 R10 R9
Freescale will probably have a suitable pro- ACBUS4
32
D3
5
6
USB B 2x ACBUS5
33
gramming adapter as well. Furthermore, PGB1010603 ACBUS6
ACBUS7
34 4k7 4k7
BDBUS5
45
VCC
1 63 BDBUS6
arent that many (new) computers that CS
CLK
2 62
EECS
EECLK
BDBUS7
46
4 3 61
still come provided with such a port. The DO DI EEDATA
BCBUS0
48
VSS
52
60 BCBUS1
OnCE/JTAG interface described here is an 93LC46B PWREN 53
5
36 BCBUS2
SUSPEND 54
R8 BCBUS3
addition to the DSP board, and provides a 6
BCBUS4
55
57
2k2 REF BCBUS5
fast and modern USB connection between 13
BCBUS6
58
59
TEST BCBUS7
the DSP board and a PC.
OSCO
AGND
OSCI
+3V3
GND
GND
GND
GND
GND
GND
GND
GND
D4
10
1
5
11
15
25
35
47
51
X1
The circuit R4
R12
20
IC3
C16
40 11-2011 elektor
MiCroControllerS
state outputs) is suit- DSP board. Apart from the bare PCB, Elektor
able for use with also supplies a fully populated and tested
supply voltages version of this adapter [2].
between 1.5 Vto
5.5 V and will therefore Software for Symphony Studio
work perfectly well at 3.3 V. When the circuit was designed we assumed
As a precaution, weve added a pull- that the adaptor would be used in combi-
up resistor (R9) to the reset output, which nation with the development environment
means that the interface should be able to from Freescale, Symphony Studio. With
the be used with other projects without any the help of a template from Freescale the
PC at the problems. The DSP board already has this FT2232H can be programmed such that it
high data rate of pull-up resistor on-board. If the adapter is will be recognized as a Symphony Sound-
USB2.0. The supply for going to be used exclusively with the DSP Bite. This will have been done for you in the
the circuit comes from the DSP board itself, board then R9 may be left out. fully populated board supplied by Elektor
which makes the interface Self Powered. so that you can plug the adapter into the
This makes the circuit a bit simpler, since In Figure 2 you can see the PCB that was DSP board straight away. For those of you
the supply voltage for the I/O interface is designed for the adapter. Its size has been who want to program the FT2232H them-
3.3 V and this is already present on the DSP kept small by using SMD components. The selves, FTDI provides a utility called Mprog
board. The core of the FT2232H operates at 2x7 pin header is mounted on the under- that will let you do this. The template from
an even lower voltage, which is 1.8 V. This is side of the board, which makes it easy to Freescale is meant to be used with this pro-
obtained from an on-chip voltage regulator, plug the adapter into connector K8 of the gram. (There is a more recent program from
which is a welcome feature. The connection
to the USB bus requires nothing more than
two resistors and a USB Type B connector
(K1). Two ESD suppressors (D1 en D2) have COMPONENT LIST
been added next to the USB connector, Resistors (SMD 0805, 0.1W) IC3 = CD74AC244M (Texas Instruments,
which protect against static charges. The R1,R2 = 10 5% SMD SO-20)
reaction speed of these diodes is less than R3 = 1k 5%
R4 = 12.0k 1% Miscellaneous
1 ns. Because of their extremely low capac-
R5,R6,R7 = 10k 5% K1 = USB-B connector, right angled,
itance (just 0.055 pF) they dont affect the R8 = 2.2k 5% PCB mount
USB signals. The active-low reset line of R9,R10 = 4.7k 5% K2 = 14-pin (2x7) IDC socket, lead pitch 0.1 in.
the IC isnt used and is pulled up via R3 to R11 = 270 5% X1 = 12MHz, Cload 18pF 30 ppm, HC-49S
the supply voltage. The external EEPROM R12 = 560 5% PCB # 110534-1
(IC2) is connected according to the stan- Assembled, programmed and tested board:
Capacitors (SMD 0805) # 110534-91
dard application note (R5 to R8) to the
C1,C2 = 27pF 50V 5%, NP0
FT2232H. The EEPROM should be one with C3 = 3.3F 10V 10%, X5R
a word size of 16 bits and which operates C4,C5,C6,C8,C10C16 = 100nF 50V
from a supply voltage of 3.3 V. There is no 10%, X7R
need for it to have a selectable memory C7,C9 = 4.7F 6.3V 10%, X5R
configuration input (usually called ORG).
Spoelen (SMD 0805)
The 93LC46B made by Microchip is a suit-
L1,L2 = 600 @ 100MHz,
able candidate for this application. The 200mA/0.35 (e.g. Murata
supply voltage for the FT2232H has been BLM21BD601SN1D)
decoupled extremely well, as can be seen
from the 12 capacitors and two inductors Semiconductors
used (C3C14 & L1/L2). D1,D2 = PGB1010603, Vclamping = 150V
(Littelfuse, SMD 0603)
D3 = LED, green (Kingbright KPHCM-
We decided to buffer all the output signals, 2012CGCK, SMD 0805)
with the exception of the reset signal. When D4 = LED, red (Kingbright KPHCM-
the adapter hasnt yet been activated in the 2012SURCK, SMD 0805)
development environment the buffered IC1 = FT2232HL-R (FTDI, SMD 64-pin
LQFP) Figure 2. The PCB for the circuit has been
outputs will be in the off state and will have designed such that it can be plugged in directly
IC2 = 93LC46B/SN (Microchip,
high-impedance outputs. The fast 74AC244 SMD SO-8) into connector K8 on the DSP board.
(IC3, an octal buffer/line-driver with tri-
elektor 11-2011 41
MiCroControllerS
Figure 4. Here you can see how the adapter is selected in Symphony Studio.
42 11-2011 elektor
Advertisement
Robots and Robot Kits:
Pololu 3pi and m3pi
way the green LED (D3) is driven better. The current through the Hobby/RC Servo Controllers:
LED is typically 4.7 mA. The current through the red LED (D4) is less, Micro and Mini Maestros
about 2.7 mA, which makes the brightness of both LEDs appear #1053: Sub-Micro
equal to the eye. If you want to program a modified template you #1354: Mini Maestro Servo 3.7g
should first save it. Its best if you never overwrite the original tem- 18-Channel USB Servo
Controller with native USB
plate, so choose a new name for it (select Save As under File). After interface and internal
opening a template it can be programmed immediately. scripting control
elektor 11-2011 43
1 2 3
Figure 5
Figure 1 Now we can fit the PCB on the holder board. Its important to
These are the components that you receive in a stencil kit: the PCB ensure that the board is nice and clean. Fingerprints or other
(front), the stencil (right) and the holder with the clamps (left). dirt on the pads are taboo.
7 8 9
E-LABs INSIDE
44 11-2011 elektor
4 5 6
Figure 6 Figure 10
We must ensure that the stencil can be laid on the PCB properly, The next step is to use a squeegee to spread the solder paste
without any curled corners. To achieve this, we tape the top over the stencil in a single motion. Pulling the squeegee towards
edge of the stencil to a piece of board material with the same you yields the best results.
thickness as the PCB.
Figure 11
Figure 7 If everything went right, we now have a board with perfectly
Now we lay the stencil on top of the PCB. applied solder paste after the stencil is removed.
Figure 8 Figure 12
The cone-shaped pins hold the stencil exactly in place. As you In this close-up you can see that even on the small pads for the
can see, the solder pads are exposed. IC, exactly the right amount of solder paste has been applied
in the right place (note that the IC pin spacing here is only
0.5 mm).
Figure 9
Now we can apply the solder paste. Here we only intend to Now the board is ready for the components. After they have
apply paste to the first row of PCBs, so we dont want to put been placed, we can put the assembly in the reflow oven but
too much paste on the stencil. thats a different story.
(110514)
10 11 12
elektor 11-2011 45
Microcontrollers
By Jens Nickel (Elektor Germany Editorial) Of course, if you are already familiar with implements the ElektorBus protocol,
Java, the Android framework and the vari- freeing the developer to concentrate on
Home automation and similar measure- ous development tools, there is nothing to the application proper;
ment and control applications need a cen- stop you using them to implement the Ele- provides a clear separation between the
tral control unit with a display, allowing the ktorBus protocol and your own application. application code and protocol code;
user to view readings and adjust settings. If the code for the protocol and the applica- makes it easy for an electronics engineer
The unit might take the form of a PC, pro- tion proper are mixed within the program to design and program a user interface;
grammed, for example, in Visual Basic. (as is the case in the demonstration soft- and
Alternatively a smartphone or tablet com- ware that we have given previously), then is platform-independent, so that the
puter, running the Android open-source modifications and extensions can be hard to same application can run equally well on
operating system, makes an ideal control- implement. And if you switch from one plat- a PC and on a smartphone.
ler. In this case the application code has to form to another, the code must be rewritten Sounds like a tall order? Lets see...
be developed in the Java programming lan- from scratch.
guage within the powerful Android frame- HTML spoken here
work, which presents a steep learning curve Hence we would ideally like to have a library Before we look at how the library is used
to the beginner. which we will take a step back and describe how
Elektor Products and Support Free software download (microcontroller firmware plus PC
Experimental nodes: printed circuit board 110258-1 or set of three software)
boards # 110258-1C3 All products and downloads are available via the web pages accom-
USB-to-RS485 converter (ready built and tested): # 110258-91 panying this article: http://www.elektor.com/110517
46 11-2011 elektor
the whole set-up works. At first the concept The screenshot in Figure 1 shows the first
might seem overcomplicated and elabo- version of the ElektorBus browser. As in a
rate. However, the advantages of our cho- normal browser, the window that displays
sen approach over more conventional pro- the applications HTML occupies the major-
gramming methods turn out in practice to ity of the display. The HTML and Javascript
be significant, and the ideas can be used code form the core of the application,
in other Elektor projects that require con- wrapped within the browser which itself is
trol from a PC. Also, a similar approach is written in a more conventional program-
adopted with success in modern software ming language such as Visual Basic .NET or
development, for example of mobile apps. Java (see Figure 2). We can think of the Ele-
And so we recommend even beginners to ktorBus browser the host in our system.
work through the following description.
Protocol library
First, platform-independence: we achieve The host receives an ElektorBus message
this by writing the application code itself, over the serial port of the device on which
including the user interface, in HTML and it is running. The message is then pro-
Javascript. This combination is astonishingly cessed according to the protocol we have
versatile, allowing our user interfaces to run described previously, and the payload is
within a browser on Windows PCs, Macs, passed on to the application program (the Figure 1. Screenshot of the first version
of the ElektorBus browser with example
Linux machines and all kinds of mobile part written in HTML and Javascript). When
application running.
device. A further benefit is that HTML pages the user presses a button in the HTML user
can be transmitted over the internet, which interface, the Javascript code generates a
opens up a world of remote control possibil- corresponding payload for the message
ities. HTMLs star is decidedly in the ascen- to be sent: an example of this is the set- HOST:
dant: the new HTML5 standard brings in ting of a threshold value in a sensor node as ELEKTOR BUS BROWSER
new features such as local database stor- described in the previous installment. The HTML/JS:
BUS-APPLICATION
age, 3D graphics and much more. message is then passed out to the Elektor- 101
IN
Bus browser, which is responsible for actu- 233
run in a normal browser such as Firefox or In principle it would be possible to imple- PC, Smartphone ....... 110517 11
Internet Explorer, but for security reasons ment all three bus protocols (the Elektor
these browsers are very limited (compared Message Protocol, Hybrid Mode (which
to fully-fledged applications) in what they is optional) and the Application Protocol) Figure 2. The platform-dependent host
is only responsible for the lowest-level
allow an HTML page to do. For example, a within the host. On the other hand, it would
functions such as driving the serial port
normal browser cannot receive or send data be possible to make the host transparent,
and synchronization. The application
over the serial port of the PC on which it is passing the 16 raw bytes in a received mes-
proper is written in HTML and Javascript.
running. We therefore need a dedicated sage packet directly through to the Javas-
browser, still capable of displaying HTML cript code, where the details of the protocol
pages, but with the extra features we need could be implemented. We choose a mid-
for ElektorBus applications. Since the Ele- dle road: the simple Elektor Message Pro- data structure that contains (among other
ktorBus browser accesses USB and other tocol and the rather timing-sensitive Hybrid things) the transmitter address, the receiver
device functions, it must be specially built Mode and scheduler are implemented address and the eight payload bytes. These
for each platform. Fortunately this does not within the host, while the Application Pro- parts are then encoded into a string (called
present any great obstacle, as normally the tocol, which requires rather more code and InCommand) and passed in to the Javas-
source code does not need to be changed which some readers will perhaps want to cript code (see Figure 4). The InCom-
for each new application. For simplicity we extend, is implemented with the help of a mand string is formatted as plain ASCII
make the ElektorBus browser available as an small Javascript library: see Figure 3. (see the text box) which ensures that it
executable file for various platforms: in the will be treated compatibly across different
case of a PC, as an exe file. When switch- In more detail, the process runs as follows. platforms.
ing to a different machine, you simply need The host receives the sixteen bytes of the
to install the appropriate version of the Ele- message sent over the bus using the start The Javascript code accepts the InCom-
ktorBus browser, put the HTML/Javascript byte synchronization system described mand string and converts it to a simple
files in the right directory, and off you go! in [1]. The message is unpacked into a data structure called Message, which can
elektor 11-2011 47
Microcontrollers
BIT
USER APPLICATION BYTE 7 6 5 4 3 2 1 0
USER APPLICATION 0 1 0 1 0 1 0 1 0
1 0 0 0 0 0 0 0 0 MODE
REC SEND PART REC SEND PART
2
APPLICATION PROTOCOL APPLICATION PROTOCOL
3 ADDRESS RECEIVER
4 ID
JSBUS JSBUS
REC SEND PART PART PART REC SEND PART PART PART 5 ADDRESS SENDER
6
PART
OUT 7
HYBRID MODE/ IN REC SEND DATA
SCHEDULER 8
9
HYBRID MODE/ PART
HOST A
SCHEDULER
ELEKTOR MESSAGE PROTOCOL B
HOST C
AA MODE REC SEND DATA CRC PART
ELEKTOR MESSAGE PROTOCOL D
E
AA MODE REC SEND DATA CRC CRC
110517 - 12A F
110517 - 12B 110517 - 13
Figure 3. The standard ElektorBus protocol Figure 4. The host and JSBus library Figure 5. The Application Protocol allows
stack (Hybrid Mode and the Scheduler communicate with one another by several numeric values or other items of
are optional). The host is responsible for exchanging, in plain text form, the information such as alarm thresholds to
the Message Protocol layer, the JSBus contents of messages that are received or be conveyed in one message. The diagram
Javascript library for the Application that are to be transmitted. shows an example of three of these so-
Protocol layer. called parts: two consisting of two bytes
and one consisting of four bytes.
then be further decoded. In accordance ing below threshold on sensor 2. Just as one tion code could copy a numerical value con-
with the Application Protocol the message message can convey several such morsels of tained within a part into an HTML text box.
is divided into so-called Parts, which cor- information (see Figure 5), so the Javascript
respond to individual units of information: library can create an array of several parts Command types
see the text box Messages and Parts. One from a message. The received parts are then When the application wants to transmit
unit might for example comprise a single passed to a Javascript function into which data, the process operates in reverse. A click
transmitted two-byte value (from 1023 the developer can put code particular to on an HTML button calls a Javascript func-
to +1023), or be a message such as read- the application. For example, this applica- tion specially written for the application,
48 11-2011 elektor
Microcontrollers
Example application
The easiest way to see how the Javascript
library and the ElektorBus browser fit
together is through an example. We will
use exactly the same hardware as we did in ELEKTOR BUS
the previous installment in this series, with
just minor changes to the firmware run-
ning on the two nodes: the BASCOM file is
available at [2]. Figure 6 shows once more USB
the hardware involved: node 2, equipped RS485 NODE 1 NODE 2
CONVERTER
with a light-dependent resistor, continu-
ously sends readings to the master node.
The master can instruct the sensor node to
change its units of measurement and to set 8 8
elektor 11-2011 49
Microcontrollers
each part received. Inside the function you the text box) can be used to add further
can specify how received readings, alarm parts to the array.
messages and so on should be handled. The
properties of the part, such as the transmit- The mode byte comes in useful when
ting node, the channel and the data value, we want to send a flagged acknowledge
can be accessed using the syntax part. message (see the text box A new bit) to
property . Even readers not familiar with a node that transmits in the unregulated
the C-like syntax of Javascript will be able free bus phase. In this example node 1
to recognize from the listing that the code reports the status of its own test LED
checks from which transmitter node each when the test button is pressed. However,
part originates. Channel 1 carries the cur- the code we have seen does not include
rent LED status (0 for off and 1 for on). If a the transmission of the corresponding
received part belongs to channel 1, the code acknowledge message back from the
will set the status of a radio button in the master. In fact, this job is carried out auto-
HTML form accordingly. This is done using matically by the Javascript library: see the
the function RadioButtonSetvalue() function ProcessReceivedParts(parts)
which is included in the JSBus library. The in JSBus.txt.
most important functions in the library
Figure 7. Threshold monitoring: are described in the text box. This function Outward bound
everything is implemented in a platform-
expects as parameters the ID of the HTML The function SendParts(parts, over-
independent way in HTML and Javascript.
radio button whose status is to be set and rideQueue); causes the assembled parts
a numeric value of 0 or 1, corresponding to (in our case there is just one of them) to be
off and on respectively. Since in this case encoded into a message and then trans-
and the example application, consisting of the value of part.Numvalue will itself be 0 mitted. The library function can automati-
two files called Index.htm and Limit.htm. or 1, we can include it directly in the argu- cally assemble up to four parts stored in the
You should drag the UIBus directory, which ments to the function. We have chosen to part array with the same transmitter and
contains these last three files, onto your use the names LED1 and LED2 as IDs for receiver addresses into a single message.
desktop. the two radio buttons on the page. This has Parts that cannot be sent in a single mes-
the lucky consequence that we can con- sage are encoded into a series of messages
On running the program ElektorBus- struct the first parameter to the function by that are sent one after the other. All of this,
Browser.exe the first HTML page (which simply concatenating the string LED and however, is transparent to the application
must be called Index.htm) will be dis- the transmitter node address. developer. The library stores the messages
played. Connect up the serial port and start in a queue. When the Javascript code is
the scheduler, as described for the PC dem- The next function, informed by the host that the first message
onstration software in the previous install- SetSensorScale(quantity) is called has been sent, then next one in sequence
ment, and readings from the light-depen- when one of the HTML buttons is clicked is brought to the head of the queue. Now
dent resistor should appear in the text box. on. In this case a part needs to be sent to we can see the point of the second param-
The buttons below the text box can be used the light sensor node to tell it to send sub- eter overrideQueue: a second call to Send-
to change the units between raw ADC value sequent readings either as raw ADC results Parts can either overwrite any messages
(from 0 to 1023) and ohms. The alarm part or in ohms. The code has a standard layout: still awaiting transmission or can fail if it dis-
of the application is displayed separately to first the line var parts = InitParts(); covers that the queue is not empty. In the
demonstrate the use of the Url command: initializes an empty array of parts. The next example file Limit.htm we use both of these
see Figure 7. line is the critical one: it is where a new part alternatives when setting and resetting the
is added to the end of an existing parts threshold alarm, as in each case the master
Inward bound array. The job is simplified by the library must send two messages.
Having completed this first test, we can now function SetScale() , which expects as
open the file Index.htm in a text editor parameters the current parts array to which The next two lines of the Javascript code
and take a look at its source code (see the the new part is to be appended, the trans- change the text in our HTML form. For this
Listing). At the top is the reference to the mitter and receiver addresses, the channel to be possible the text must be given an ID,
JSBus Javascript library. Below that, enclosed and mode byte, and finally the new val- in this case unit. Depending on the value
between a second pair of script tags, comes ues to be used for the quantity, units, and of the variable quantity the text is modi-
the application-specific Javascript code. The power-of-ten scaling. The return value is the fied to read either Ohm or ADC value.
function ProcessPart(part){ ...} extended parts array. Multiple calls to this The library includes constant definitions
is mandatory: it is called by JSBus once for and other Javascript library functions (see for the commonest quantities: for example,
50 11-2011 elektor
Microcontrollers
function ProcessPart(part)
{
if (((part.Sender == 1)||(part.Sender == 2)) && (part.Parttype == PARTTYPE_VALUE2))
{
if (part.Channel == 1) {RadioButtonSetvalue('LED' + part.Sender, part.Numvalue);};
}
function SetSensorScale(quantity)
{
var parts = InitParts();
parts = SetScale(parts, 10, 2, 0, 0, quantity, 0, 0);
SendParts(parts, true);
if (quantity==RESISTANCE) {TextSetvalue('unit','Ohm');};
if (quantity==RAWVALUE) {TextSetvalue('unit','ADC-Value');};
}
</SCRIPT>
<FORM Name='Bus'>
Scheduler
<BUTTON Type='button' onclick='javascript:SetScheduler(SCHEDULER_ON,2,10,0,0,0,0,0,0)' >on</BUTTON>
<BUTTON Type='button' onclick='javascript:SetScheduler(SCHEDULER_OFF,2,10,0,0,0,0,0,0)' >off</BUTTON>
<br/><br/><br/>
LED Node 1
<INPUT Type='radio' ID='LED1' Name='LED1' Value='LED1' />
LED Node 2
<INPUT Type='radio' ID='LED2' Name='LED2' Value='LED2' /> <br/><br/>
</FORM>
elektor 11-2011 51
Microcontrollers
function PartText(part)
Returns a textual representation of a part, for example for debugging purposes.
function GotoUrl(url)
Causes the host to load a new HTML page (url= file name without trailing .htm extension).
function SetScheduler(status, schedulednode1, , schedulednode8)
Switches the scheduler in the host on or off (status= SCHEDULER_ON or SCHEDULER_OFF) and provides the scheduler with a new list of
nodes that should be regularly requested to send a message. A zero value terminates the list.
RESISTANCE is defined as the constant 18. The extra distinguishing name attributes GotoUrl(). The parameter to this function
BASIC aficionados should beware of the in the radio button element (LED1 and is the name of the destination page, with-
doubled equals sign in comparison opera- LED2) allow us to control the buttons out the trailing .htm extension. Note that
tions and pay particular attention to consis- independently of one another. If we had in this case the name has to be given in dou-
tency in the use of upper and lower case in used the same value for the two name ble quotation marks, since single quotation
Javascript code. attributes we would only be able to acti- marks have already been used to delimit the
vate one of the buttons at a time, like the value of the onclick attribute. The HTML
Now we turn to the HTML section. This interlocking channel selector buttons on files should be stored in the directory UIBus
consists of a series of elements, each an old-style radio. on the desktop. Later versions of the Elektor-
introduced by a tag such as <DIV> or Bus browser will allow alternative locations
<INPUT>. The tags of particular inter- The onclick attribute of the button links a to be used.
est to us are those enclosing <INPUT> click on the button to a call to a Javascript
and <BUTTON> elements. In the case of function. Clicking on the first of the two Outlook
INPUT elements we specify the type (as buttons switches the scheduler on or off via If you have already had a little experience
radio[button] or text[box] and an ID the function SetScheduler() in JSBus.txt. with HTML and Javascript, the information
string. The ID string allows the element The two additional buttons defined towards in this article and in the text box describing
to be identified and addressed subse- the bottom of the listing call the applica- the most important functions provided by
quently in Javascript code. Text that is to tion-specific function SetSensorScale() the JSBus library will be enough to let you
be changed dynamically is best enclosed with the appropriate parameter (RESIS- produce some impressive applications.
within <DIV> or <SPAN> tags. The TANCE or RAWVALUE ); and finally the last Beginners should look first at the HTML
first of these also puts the text in its own button causes the browser to load the page and Javascript basics download [2] and
paragraph. Limit.htm, using the JSBus library function then try experimenting to see the effects of
52 11-2011 elektor
Microcontrollers
simple changes to the example HTML code. a future installment in this series, we use What do you think?
A simple text editor can be used to create the same idea to control our system from Feel free to write to us with your
HTML files, and they can be opened in your an Android smartphone (see introductory opinions and ideas.
favorite browser by simply double-clicking photograph). The bridge to the bus is based
on them. This will let you see immediately on a neat little board containing an FTDI
what your applications user interface will Vinculum II chip, which we will describe in Internet Links
look like. And since we will be using this sys- the January 2011 issue.
tem for the subsequent installments in this The board can be used for a wide range of [1] www.elektor.com/110258
series, you will soon also have more exam- applications beyond the ElektorBus, but in [2] www.elektor.com/110517
ple code that you can adapt for your own each case HTML and Javascript still provide [3] www.elektor.com/110428
applications. an easy way to make a platform-indepen-
Getting to grips with the HTML/Javascript dent user interface. [4] www.elektor.com/110382
combination will come in handy when, in (110517) [5] www.w3schools.com
A new bit
While working on this article I received plenty of advice from Elektor readers who have already embarked upon their own applications and
extensions. For example, Jan Dalheimer from Sweden, who at 15 must be one of our youngest fans, has already started on an AVR micro-
controller version of an ElektorBus library. As of our copy deadline Jans code already handles the Message Protocol and Hybrid Mode, but
does not yet include he Application Protocol described in the last couple of installments. Jan found the following annoyance in the acknowl-
edge mechanism: it is possible under the Message Protocol to flag a message so that an acknowledgement message is expected by the
transmitter (using bit 0 of the mode byte: see [1]). However, at this level an acknowledgement message (which for good reasons contains a
copy of the original data payload) cannot be distinguished from the original message, as we only introduced this flag as part of the Applica-
tion Protocol. This means that this function of the bus system creates an interaction between the two layers of the protocol which makes it
harder to implement cleanly in a library.
Jans proposal was to use bit 1 of the mode byte to distinguish between an acknowledge message and the original message. Flagging ac-
knowledge messages at the message level is a good idea that we are happy to adopt: unfortunately, bit 1 of the mode byte has already been
appropriated for other purposes, and so we have to rearrange things slightly.
Bit 1 0
7 no ID bytes, data from byte 2 ID bytes from byte 2
6 bytes 2 and 3 are ID bytes bytes 2 to 5 are ID bytes
5 no CRC bytes E and F form a 16-bit CRC
4 last ID byte is a fragment number all ID bytes are used for addressing
3 next fragment follows immediately no fragment follows immediately
2 top six address bits give bus segment no segment address
1 acknowledge message original message
0 acknowledge message expected acknowledge message not expected
In Figure 5 we have indicated bits 1 and 0 in red. We have already implemented the new system in the Javascript library: an acknowledgement mes-
sage is automatically sent out with the mode byte set to 2 if the original message was received with its mode byte set to 1.
We should clearly distinguish the above from the acknowledge mechanism that is used at the level of the Application Protocol: an example of this
is alarm reporting by the light sensor (see [3]). Since the node is regularly interrogated the mode byte in the messages it sends is normally zero: no
acknowledgement of them is required since collisions cannot occur. Any acknowledgement message must therefore be implemented by the applica-
tion developer. To distinguish it from the original message we use the Ack flag in the data payload, first introduced in [4]. An important part within
a message, such as an alarm report, should have its Ackflag set to true and re-encoded into a message to be sent back to the sensor. To this end the
Javascript library includes the function AddAckPart(). An example of how to use this function can be found in the file Limit.htm.
elektor 11-2011 53
The Must Have reference for
loudspeaker engineering professionals.
Webinar programme:
E-Blocks, Twitter and the Sailing Club
Date: Thursday November 17, 2011
Time: 15:00 GMT (16:00 CET)
Presenters: Ben Rowland and John Dobson (Matrix Multimedia) FREE PARTICIPATION
E-blocks are small circuit boards containing a block of electronics that you would typically Register now!
find in an electronic or embedded system. In this webinar Ben and John demonstrate rapid
prototyping of an E-Blocks configuration capable of automatically sending Twitter messages
to members of a sailing club.
Powering stand-alone circuits from solar cells is perfectly possible as long as continuous operation is not
required. You can also accumulate the relatively low energy output of solar cells until you have enough to
power a circuit for a short while. How do you know when you have enough? You use a voltage monitor.
The hitch is that the monitor itself consumes power, but it shouldnt drain the accumulated energy or at
least it should use as little as possible. Even a few microamperes make a difference.
We discussed the principle of energy har- Design tor conducting for a while after the compar-
vesting in the January 2011 edition. The Figure 1 shows the block diagram. The out- ator output changes back to the low level.
idea is to operate a circuit entirely from a put of the solar cell is connected to a volt- As a result the load continues to operate as
small source of energy, without using an age multiplier, which charges the storage long as energy is available in Cs. This design
external power supply or batteries. capacitor Cs. A number of voltage multi- is called a solar engine. You can find infor-
plier designs were discussed in detail in this mation on solar engines on the Web (e.g.
In the present case the energy source is a years January issue of Elektor, so here the [1]).
small solar cell (costing 5 pounds or so) with multiplier is shown as a functional block.
a maximum output of 1 V at 100 mA. This The opamp in the block diagram is a com- On a cloudy morning the charging cur-
level is only possible on a cloudless day with parator that is powered from the storage rent is only some 20 to 30 A, so the stor-
the cell facing directly towards the sun. On capacitor. In practice there are also a few age capacitor charges very slowly. Nev-
a cloudy day the cell products only a few resistors around the comparator. When ertheless, we need to continuously check
hundred millivolts at a few dozen microam- the plus input reaches the threshold volt- whether enough energy has been stored.
peres. Nevertheless, you can do something age, the output of the comparator goes We cant use a timer because we dont
useful with this small amount of energy high (to the level of supply voltage Vs) and have a battery. Experiments using a Maxi-
not continuously, but for brief periods a few the transistor is driven into conduction. Cur- mum MAX8282 voltage monitor [2, 3] as
times a day. rent supplied by Ct and Rt keeps the transis- a comparator yielded results that were
VC VS
R3 10M LOAD
VCC = VS VS
TC54VC27
MAX931
LOAD VS VC R1
T1
220R 5M9 D
Vhyst
1%
COMP Vref
Charge VS 1N5817 ZVN4424A
T
Pump D *
C*t
Cs R2 Rt
Vref
2u2
Tant.
5M9
Rt 1%
Cs Ct
110662 - 12
Vth+
110662 - 11
VS
Vth
0V
Figure 1. Basic block diagram Figure 2. Schematic diagram of the energy-efficient voltage
of the energy harvesting circuit. monitor. All semiconductor components are available as SMD and
through-hole types.
56 11-2011 elektor
POWER SUPPLIES
Practical solution
Figure 2 shows a better solution. The
TC54VC27 is a voltage detector. This little
three-terminal IC consumes less than 1 A
as long as the supply voltage is below the
built-in threshold voltage (2.7 V), which is
the situation during the vast majority of the
charging cycle.
elektor 11-2011 57
test & measurement
By Peter A. Stark (USA) Transients and steady-state So how can we know (or better yet, how
The circuit in Figure 1 is simple with the can the battery know) that its supposed to
TDR stands for two things the process of switch open, theres no current. But close send exactly one-tenth of an ampere down
Time Domain Reflectometry, or the device the switch, and Ohms Law says that a cur- the line to the resistor when you close the
that does it, called a Time Domain Reflec- rent of 0.1 ampere (10 volts divided by 100 switch?
tometer. There is also OTDR, which is Opti- ohms) flows in the circuit. The answer is that it doesnt. The cur-
cal TDR for optical fibers. The basic idea is rent that starts down the wire depends on
to send a signal, usually a pulse, into the But lets make the circuit a bit more inter- the wire, not the load. Even though were
cable or optical fiber, and then see whether esting: lets make the wires from the switch assuming that the wire has no resistance,
a problem in the cable reflects some or all to the resistor very long for instance it does still have some inductance (even
of that pulse back to the input. The nature 186,000 miles long. To keep things simple, though it isnt wound into a coil) and some
of that reflection gives us an idea of what assume the wire is perfect and has zero capacitance between the two wires. This
the problem is, and the time it takes for the resistance. Now what? Ohms Law doesnt inductance and capacitance limits the
reflection to get back to the input tells us care how long the wire is it says that I = inrush current to some value. In our case, it
how far away the problem is located. V/R, so the current is still 0.1 A. But there is will take that current somewhere over one
more to the story! second to get to the resistor (because cur-
TDR test instruments are generally quite rent in wires travels slower than the speed
expensive, and not found in the typical The reason we picked 186,000 miles for the of light), but if the cable happened to be
enthusiasts workshop. Even many com- wire is that light travels 186,000 miles per infinitely long, that current would continue
mercial labs cant afford one. But if youre second. If were at the switch with a tele- going in forever.
willing to make do, you can make useful scope, looking at the resistor, it takes the Knowing the voltage and current, we could
TDR measurements with just a pulse gen- light 1 second to reach us. What we see is calculate an equivalent resistance which
erator and an oscilloscope. A useful pulse not whats there right now, but what was would cause the same current to flow.
generator can be easily built with little there 1 second ago. When we close the That value is what we call the characteristic
effort, and the oscilloscope need not be switch, we cant even be sure that that resis- impedance of the cable. The symbol for that
expensive. Obviously the better it is, the tor is still there! Suppose there was some is Z0. (We call it an impedance, even though
better your results will be, but even a practical joker out there who swapped out it behaves like a resistance, just to be more
15-year-old 10 MHz scope is good enough that resistor for some other value, or even general.)
thats what we used for the photos in disconnected it, just before we closed the For instance, the coaxial cable used for
this article. switch? We wont know until a second later. many antennas has a characteristic imped-
58 11-2011 elektor
test & measurement
S Z0
Pulse
ZL
Generator
BT
R
100R
10V Oscilloscope
110235 - 11 110235 - 12
Figure 1. A simple DC circuit ... or is it? Figure 2. Circuit for sending pulses into a cable.
ance Z0 of 50 , so if we connected an infi- (3.3 V) is being reflected back from right compromise by? They used the following
nitely long length of that cable to our 10-V to left. About a second later, it gets back to equation:
battery, the current going into the cable the battery, but now the battery says, No
(still using Ohms Law) would be way, $%&**&@! I want 10 V! So it forces Reflection coefficient = (ZL Z0) / (ZL + Z0)
the voltage back to 10 V, which also hap-
I = V / Z0 = 10 / 50 = 0.2 A or 200 mA. pens to reduce the current. Another second where ZL is the resistance of the load, and
or so later, the resistor ... Zo is the characteristic impedance of the
OK, lets assume were using something like Well, you see whats happening. The bat- cable. (As before, they are usually resistive,
that coax (but made of perfect wire with tery keeps dropping the voltage, the resis- but engineers use Z for impedance ... just
zero resistance) between the battery and tor keeps trying to raise it, and all this time in case.) With our numbers, we have the
our 100- resistor in Figure 1. The battery the current is slowly dropping. Eventually reflection coefficient
has no way of knowing how long the cable things will settle down to 10 V and 0.1 A you
really is, so it starts pumping in 200 mA just would expect, but it takes a while. That ini- = (100 50) / (100 + 50) = 50 / 150
in case. In a bit over one second, that 10 volts tial set of compromises is called a transient; = 0.333 = 1/3.
and 200 milliamperes hits the resistor. At this the eventual settling down to a steady value
point, the 100- resistor raises an objection: is called steady state. This is called the reflection coefficient
Youve got either too much current or too This interplay between voltage and current because it tells us what fraction of the
little voltage! If you insist on 10 V, then I want happens no matter how long the cable is, outgoing signal gets reflected back to the
0.1 A or 100 mA. But if you give me 200 mA, but if the cable is very short, it happens very beginning.
then the correct voltage is 20 V (V equals I fast. As a rough value, electric signals in a The reflection coefficient can be positive, as
times R). Fix it! The cable then comes back cable travel about eight inches per nanosec- here, or negative (if Z0 ZL is negative) or
with, Lets compromise. Lets raise the volt- ond (which is a billionth of a second), so if even zero (if ZL equals Zo), so the reflection
age a bit and drop the current by the same the wire from the battery to the resistor is can be positive, negative, or zero.
percentage. So they do a quick calculation only a foot or two, then the whole thing is
and decide to change by 1/3: they will raise over in a few nanoseconds. Pulses are better
the voltage by 1/3 to 13.3 V, and drop the Before you blink an eye, the voltage and Suppose that, instead of closing the switch
current by the same 1/3 to 133 mA. Now the current have settled down to their steady- and leaving it closed, we close it for just an
resistor is happy because state values, and nobody ever realizes that instant and then immediately open it again.
a transient ever occurred. Youd need an The 10 V will be just a short pulse traveling
I = V / R = 13.3 A / 100 = 0.133 A. extremely fast storage oscilloscope to even right; the reflection of 3.3 V will also be just
see it happen. On the other hand, if you a short pulse coming back a while later.
which for sure is 133 mA. have a long enough cable, then even a mod-
But now theres a new problem the volt- erately decent scope can see the transient. Since there is just one pulse going down and
age and current at the right end of the cable Thats what TDR or Time Domain Reflectom- one back, wed need a storage scope to cap-
is different from the left end. So the new etry is all about. ture it, so lets repeat the pulses at a high
voltage and current start traveling back rate with a pulse generator, connected as
toward the battery. The Reflection Coefficient in Figure 2. (If possible, use a 10:1 probe on
Lets just consider the voltage: 10 V is trav- How did the cable and resistor decide the scope.) Although the diagram shows a
eling left-to-right, but one-third of that that 1/3 or 33% would be a good value to coaxial cable, any kind of cable would do.
elektor 11-2011 59
test & measurement
so the pulses are about 0.1 s wide, and the delay more accurately on the scope,
about 0.9 s apart. we could use this method to measure the
length of the cable quite accurately without
Lets now connect 100 feet of RG-58U 50- ever unrolling it off its spool.
coax cable, with the 100- resistor at the Theres a catch, of course we need a good
far end, which gives us Figure 4. We see calibrated scope, and we also need to know
two things: our original pulses have gotten the exact value of the velocity factor. But a
smaller because the cables characteristic commercial TDR instrument can still do a
impedance is loading down the generator, fairly accurate job at it.
and there is now a small third pulse in the
photo. What about other loads?
Besides the 100-ohm resistor, there are
Figure 3. Pulse generator output. That new pulse (second from the left in the another three values that are of interest
photo) is the reflection of the first pulse a short (0 ohms), an open (infinity ohms)
from the open end of the cable. It took the and a resistor exactly equal to the cables
pulse about 150 ns to travel to the far end characteristic impedance (i.e., ZL = Z0). Lets
of the cable, and another 150 ns to return to take a look at those three cases:
the scope, so the total delay is about 300 ns
or 0.3 s. So the reflected pulse shows up A. If the end of the cable is shorted, ZL is 0,
about 3 divisions to the right of the outgo- and so the reflection coefficient is
ing pulse. (If the scope screen was wider,
we could see a reflected pulse to the right (ZL Z0) / (ZL + Z0) = (0 50) / (0 + 50)
of every outgoing pulse.) Since we calcu- = 0 / 50 = 1
lated the reflection coefficient as 1/3, the
reflected pulse is about 1/3 the height of This means that 100% of the outgoing pulse
the outgoing pulse. There is some loss in the is reflected, but the voltage is negative so
cable, so the returning pulse will generally the polarity is reversed. This is shown in
be a bit smaller than youd expect. Figure 5.
Figure 4. Pulses reflecting from
a 100- resistor. Lets look at the delay a bit closer. The scope B. If the end is open, ZL is infinite, and so Z0 is
was set to 0.1 s per division, and the dis- so tiny in comparison with the huge ZL that
tance between the two pulses is about 3 we might as well forget it:
divisions, so the round-trip time was about
0.3 s, which translates to 300 ns. To know (ZL 50) / (ZL + 50) ZL / ZL = +1
whether this is right, we need to know how
fast electric signals travel in that particular The reflection coefficient is plus 1, which
cable (the speed depends on the cable). means that the entire pulse is again
Looking up the specs for normal RG-58U reflected, but this time the polarity is the
coaxial cable, we see a parameter called same. This is shown in Figure 6.
the velocity factor of 0.66. This means that
signals in this particular cable travel at C. Finally, suppose the resistor at the end
0.66 times the speed of light. Since the of the cable is equal to the characteristic
speed of light in a vacuum is 186,000 miles impedance. Now we have
per second, this translates to 186,000 times
0.66, or about 123,000 miles per second. (ZL Z0) / (ZL + Z0) = (50 50) / (50 + 50)
Figure 5. Reflection from a short circuit. We multiply by 5280 to convert miles to = 0 / 100 = 0
feet, which gives us about 648,000,000
feet per second. This works out to about This time the reflection coefficient is 0,
648 feet per s, or 0.648 foot (about 7.8 so there is no reflection at all. This case is
Figure 3 shows the generators output inches) per ns. Therefore the 300 ns delay in shown in Figure 7, where I put a 51-ohm
when fed directly into a scope and no Figure 4 works out to 300 times 0.648 feet, resistor at the end of the 50-ohm cable.
cable. The scope was set to a vertical sen- or about 194.4 feet. Remember thats (There is a slight bump after the outgoing
sitivity of 5 volts per division, and a hori- the round-trip length, which is about right pulse, caused by my 100-foot cable actually
zontal sweep speed of 0.1 s per division, for a 100-foot cable. If we could measure consisting of two 50-foot lengths coupled
60 11-2011 elektor
test & measurement
Homework 4 U
Once you get your pulse generator work-
ing, here are some simple experiments
you can try. You may need to play with
the scope sweep settings to get a steady
display:
digital inverters in parallel invert the pulse CLR VCC 7. Using a resistor equal to Zo of the
6
THR 5 IC2.C 6
to make it positive, and also provide suf- IC1 1 R2
cable, connect it to the end of the
7 3
DIS Q
ficient output power. The 33- resistor at 555
33R
cable with very short leads. You should
2 9 IC2.D 8
the output increases the output resistance TRIG
1 see no reflection. Now connect it to
CTL
to prevent returning pulses from bouncing 5 1 the same cable but with 1- or 2-foot
11 IC2.E 10
off the inverters and going back into the 1 clipleads. You will probably see some
C1 C2
cable a second time. small but clear reflections whats
1n 100n 13 IC2.F 12
1 happening? Do the clipleads make a
Despite the apparent simplicity of the cir- 8
difference?
cuit you need to select our parts carefully.
Normal 555 timer ICs dont like to oper- 110235 - 13 8. Spend some time thinking about this:
ate at the fast speeds needed, so the best Suppose that the signal going into
choice is a TLC555 CMOS timer from Texas the cable was a sine wave rather than
Instruments. Fortunately, Radio Shack car- Figure 8. Pulse generator schematic
diagram. pulses. What would happen?
ries it as their part number 276-1718. For
elektor 11-2011 61
INFO & MARKET
SPICE It Up!
Circuit simulation with LTspice
By Raymond Vermeulen (Elektor Labs)
Circuit simulation is useful for everyone who works with electronics from students and enthusiasts
to professionals. It lets you quickly verify and modify designs without making a lot of calculations,
and it is helpful for dealing with non-ideal component properties that are ignored in formulas, among
other things. In this article we provide a concise introduction to the subject for readers who are not
already familiar with SPICE-based simulators.
We selected LTspice for this introductory description. LTspice is bilities were expanded to include the simulation of more complex
a SPICE-based simulation program from Linear Technology. It is components and additional simulation functions. In the course of
available free of charge (and without registration) and is easy to time commercial versions appeared, many of them based on the
use. However, it has the drawback that it comes as standard with original SPICE program surrounded by a vendor-specific user inter-
component libraries containing Linear Technology components, as face called a shell.
might be expected. Components from other manufacturers are not
included, but they can be added by the user. The program is highly Getting started with LTspice
suitable for simulating circuits built with Linear Technology prod- Go to the website http://www.linear.com, click Design support
ucts, and a large number of simulation examples for this purpose at the top of he page, and then click the link under the Design Sim-
are available on the Linear Technology website. For increased func- ulation heading. This takes you to the download page for LTspice.
tionality and more libraries, you can of course choose a commercial Launch the downloaded file and install the program in the desired
program such as Micro-Cap or Orcad Pspice, but these programs are location. For Linux users, the program can be run under Wine. This
not cheap. In any case, getting familiar with LTspice definitely has has been tested with Ubuntu 11.04 Natty Narwhale.
one advantage: once you know how to use one version of SPICE, you Launch the program after it has been installed.
also know how to use the other ones.
Create a new schematic sheet by clicking the icon at the far left:
Origin
SPICE was originally developed by the University of Berkeley in the
1970s for the US Department of Defense, for the purpose of analyz-
ing the radiation hardness of circuits. In subsequent years its capa-
62 11-2011 elektor
INFO & MARKET
Now you can start drawing your first schematic. You can
select component symbols from a dialog (Figure 1) that
appears after you press the Component button:
Figure 3. Advanced voltage source settings. Figure 4. Configuration options for the simulation.
elektor 11-2011 63
INFO & MARKET
behavior of the circuit. For this we use a sine-wave test signal with a variety of signal waveforms. Here we selected the radio button next
frequency of 1 kHz, an amplitude of 1 V and an offset of 0 V, which to SINE and entered the desired values.
you can configure by clicking Advanced. The next task is to simulate the circuit behavior in the time domain.
This requires modifying the simulation settings, which we do with
This opens the dialog shown in Figure 3, where you can configure a Edit Simulation Cmd:
Tips
Standard components then right-click it. Select Pick new transistor, and a list of common-
When youre drawing a schematic diagram, youll notice that when ly used types from various manufacturers will be displayed. This also
you select some components a whole list of type numbers is dis- works with other standard components.
played in the selection window shown in Figure 1, while with other
components no type numbers at all are displayed. For example, if - More components
you select Opamps you see a long list of type numbers (primar-
Of course, only a limited number of components are provided with
ily Linear Technology devices). However, a type number list is not
LTspice. Many more components can be found in the Yahoo user
displayed if you select an NPN transistor. Nevertheless, this list does
group for LTspice: http://tech.groups.yahoo.com/group/LTspice/
exist. First place a standard NPN transistor on the drawing area and
64 11-2011 elektor
Advertisement
This opens the window shown in Figure 4. We wish to view the output signal in the time
domain, so we select the Transient tab. There we can change the simulation parameters.
In this case we decided to have the simulation last for 10 ms and have the DC sources
start at 0 V. After clicking OK, place the box with the configuration settings that appears
next to the mouse cursor at any desired location on the schematic. For an analysis in the
frequency domain, the next thing we have to do is to select the AC analysis tab and
configure its settings.
Now were ready to run the simulation. Start it by clicking the RUN button.
A new pane opens to display the simulated signal. Now click the points in the schematic
diagram where you want to measure the signal (the schematic is still visible below the
display pane). In this example we chose the output of the test signal source and the
output of the opamp. The signals present at these points then appear in the signal pane
(see Figure 5).
If you right-click the waveform, a pop-up menu appears (Figure 6). You can use it to
modify many of the parameters for displaying the simulated signal. Among other things,
you can select FFT analysis to display the frequency spectrum. To do this, click FFT under
View. This opens a window where you can select a large variety of FFT settings (Fig-
ure 7). At the top, select the desired circuit node for the FFT analysis. In this case we chose
the output of the opamp. The spectrum of the signal at this point is shown in Figure 8.
Now its time for you to try LTspice for yourself in order to learn what the program has
to offer. You should also try out other simulation programs. Many of them are available
in demo or student versions, which you can use to get a bit of hands-on experience.
Although the user interfaces often vary, the most important things that you need to do
are always the same: drawing a schematic diagram, configuring one or more test voltage
sources, configuring the simulation, and viewing the output.
(110543)
elektor 11-2011 65
ReadeRs PRojects
sometimes it is not
absolute temperature
value that is of interest, but rather any
small changes in that value. the circuit
described here does not just measure
these changes: it reports them both
visibly and audibly. Using just a
few active components it achieves a
temperature resolution of just one ten-
thousandth of a degree.
Measuring temperature is a fairly simple is via a digital display and an analog pointer, sensor can be attached to a delicate com-
task, but doing so precisely takes rather as well as being represented in the chang- ponent in a circuit to give an immediate
more skill, particularly when it is desired ing pitch of an acoustic output. Readings audible warning when it suddenly starts to
to obtain readings to a resolution of bet- are also made available on a serial port for dissipate more power.
ter than one tenth of a degree. the circuit transfer to a Pc.
presented here measures temperature to the instrument lends itself to a range of It is important to insulate the sensor well to
a resolution of one ten-thousandth of a interesting applications. Its sensitivity is so keep the display stable. It can, for example,
degree, using just four active components high that its reading shows clear changes be embedded deeply in an insulating foam
and an optional display. the purpose of the in temperature when the sensor is raised such as expanded polystyrene. If the time
circuit is to be able to detect even the small- or lowered, reflecting the fact that in a constant of the temperature gradient is
est change in temperature: the emphasis is room the warm air rises towards the ceil- chosen appropriately, it is still possible to
much more on extreme sensitivity and reso- ing; if the sensor is positioned by a Pcs fan measure slow changes in ambient temper-
lution than on absolute accuracy. exhaust it is possible to see changes in the ature reliably despite the insulation.
load on its cPU or graphics card reflected the author originally used the circuit to ana-
Features and possibilities in the temperature of the expelled air; or lyze the behavior of the thermostatic valve
Without any tedious calibration the circuit alternatively the sensor can be attached in the cooling system of a car.
measures temperatures to a basic absolute to a domestic water pipe to detect when
accuracy of about two degrees. It also indi- water is being used. Construction
cates the temperature gradient, or rate of the acoustic output allows no hands mon- the unit essentially consists of an Ntc
change of temperature with time. output itoring of temperature. For example, the thermistor used as the temperature sen-
Note. Readers Projects are reproduced based on information supplied by the author(s) only.
The use of Elektor style schematics and other illustrations in this article does not imply the project having passed Elektor Labs for replication to verify claimed operation.
66 11-2011 elektor
ReadeRs PRojects
Features
Operating range: 0 C to 40 C
Absolute accuracy: approximately 2 C uncalibrated
Resolution: in theory 4105 C, in practice approximately
3104 C; displayed resolution 104 C Figure 1. the sensor board inside the temperature probe supplies
Range: degrees per 2 seconds to degrees per 100 minutes a serial digital output signal.
Power supply: 6 V (four AA cells)
The circuit
+5V
the circuit diagram for the sensor board is shown in Figure 3. the
5 V supply is provided from the processor board over the four-way +2V5 3mA2
R101 R100
elektor 11-2011 67
ReadeRs PRojects
ADC value
R202
23
PC0(ADC0) are available for free download as PdF files
24
X202
Sensor 25
PC1(ADC1)
PC2(ADC2)
and as Protel files at [1].
26
PC3(ADC3)
10k 27
CLK
SDO
28
PC4(ADC4/SDA)
PC5(ADC5/SCL)
LCD_EN_Z12 LCD_RS Software
1 2 LCD_D4 +5V
PC6(RESET)
IC200
PD0(RXD)
3 LCD_D6
the microcontroller firmware can also be
PD1(TXD)
14 4 downloaded for free from the Elektor web-
D2
D0
P500
* sion results from the sensor board and con-
6 5 RESET LCD_D7
M1 ATMEGA88
21 LCD_D5
AREF
ISP
GND
PB6
XTAL1
PB7
XTAL2 AGND
LCD_EN_Z34 C204 verts them to readings in degrees celsius.
SWITCH_A 10k
+5V
C201
8 9 10 22 10u 16V this is then transmitted as ascII charac-
* X206 V200
100n
CONTRAST ters over the serial interface (for example
as 23,5341c: note the use of a comma
SWITCH_B
X200
1N4148
X208 BZ1
instead of a decimal point, you may want to
P3
rework this to give the decimal point). the
Battery
Pot_Volume Piezo
110151 - 12
characteristic curve of the sensor is stored
4V8...6V0 10k
as a table in increments of five degrees, and
values in between table entries are linearly
interpolated. the resulting overall absolute
Figure 5. circuit diagram of the processor board. accuracy is about two degrees over the
68 11-2011 elektor
ReadeRs PRojects
elektor 11-2011 69
TEST & MEASUREMENT
Resistive Bolometer
Dont throw out those traditional lamp bulbs yet!
By Matthieu Denoual, Julien Gasnier and Sylvain Lebargy (France)
bulbs are just junk now. You could put as xenon or argon, provides the thermal insu-
them to new use if you build our radiation lation required and with this a high value of
VS
meter project that works on the principle Rth. The bulb holder, whose temperature will
of the resistive bolometer. Bolometer is an approximate to the ambient temperature,
odd-sounding word but the bol element takes on the function of the radiation source. Rm1 Rm2
comes from the Greek root word , which Our bolometer uses two lamps. One light instrumentation
amplifier
means to cast or throw. In the same way that bulb measures the radiation whilst the other
objects can cast a shadow they can also emit bulb provides a reference. This twin-bulb
100659 - 13
radiation, which is what a bolometer detects. solution has the advantage that ambient
The sensor is sensitive to the infrared range temperature does not influence the result-
and is used particular in thermal imaging sys- ing measurement. As Figure 2 shows, the Figure 3. The diverging resistance paths
tems and in systems used for space observa- bulbs are mounted in a cylindrical housing must be symmetrical.
tion. In the latter case the sensor is cooled to that is open on one side. In the associated
very low temperatures in order to increase circuitry (Figure 3) Rp1 and Rp2 are two preci-
sensitivity and reduce thermal noise. Super- sion sensing resistors whilst Rm1 and Rm2 are
conducting materials are also used. the two bulbs. It is vital that the two diverg-
A resistive bolometer consists of two ele- ing resistance paths are electrically symmet-
ments: an absorption body (a body of con- rical. If the bulbs differ in resistance from one
stant temperature or thermal reservoir) another, the two branches can be brought
that soaks up radiation plus a tempera- back into balance by adjusting the current
ture-sensitive precision resistor. The sys- sensing resistors (Rp1 or Rp2). The voltages
tem must be isolated thermally from its sur- at the test points can drive an instrument
roundings. In Figure 1 radiation absorbed amplifier such as an AD620 op-amp. RG sets
heats up the body, raising the temperature the gain, which must be at least 1,000. The
in the vicinity of the sensing resistor. In a sensitivity can be adjusted by varying the cur-
state of thermal equilibrium the tempera- rent in the range of about 1 to 10 mA. Using
tures of the absorption body and the sens- an AC power supply is not recommended as Figure 4. The output signal varies as the
ing resistor match, at around a few degrees external signals might affect the operation of radiation source is brought closer and
above ambient temperature. Any change the bolometer; a battery is much better. removed.
70 11-2011 elektor
retronics
After the XXL installments with ditto texts and theory published the previous two months, Retronics
relaxes for a bit with a tube (British: valve) sightseeing tour or, if you like, a trip down Tube Memory Lane.
Which of the tubes pictured here do you remember, vaguely or acutely? Which ones are gathering dust in
your attic? And for tube haters: which ones are you in denial about?
Retronics contributor Reginald Neale writes from Farmington, NY: When I started my engineering career in the early 1950s, everything was
done with vacuum (and gas-filled) tubes. Transistors were still a laboratory curiosity. Here are a few of the more exotic and elegant types.
(110387)
DuMont twin-gun
cathode-ray tube
Face of tube is ab from WWII radar
out 5 diameter. On display.
information, the e gun writes the sc
other writes the ra ale/text
dar echo image.
or 7 base
e left, had 4, 5, 6,
s fro m th e 30 s, like the one on th ta l base, th e 9 and
Tube
. Th en ca m e the keyed oc s.
pins of different sizes subminiatur type
e
ur e, th e 12 -pin compactron, and
7-pin miniat
Thyratrons are
the tube equiva
(SCRs). Conduc lent of Silicon
tion is initiated Controlled Re
by a control gr ctifiers
until the anod id, and contin
An acorn tube. With e-cathode curr ues
its planar constructi ent drops to ze
it was designed for th on and radial termina ro.
e Ultra High Frequen ls,
UHF was the high fre cy band. In the late 40
quency frontier. s,
72 11-2011 elektor
in
ar system. Mounted
be from a WWII rad
Transmit/Receive tu ag e pu lse, it shor ted
ggered by a high-volt
Plenty of big
names in the a waveguide and tri , effec tively switching between
the
vanished. Who radio/televisi de in th e wave gu ide ee d.
out a no h sp
remembers C on/tube indu eiving modes at a hig
Carlson, Cap
ehar t, Nationa BS -Hytron, Ph stry have
ilco, Strombe transmitting and rec
Sylvania, Mun l Union, Adm rg-
tz, Dumont, iral, Emerson,
Wells-Gardn Tung-Sol,
Motorola, Ze er, Crosley, Ra
nith? ytheon,
of the innovations
Miniature phototubes were one
d mov ies poss ible in the 30s. Optical
that made soun
rmation on the
sound tracks recorded the audio info
d syst ems used magnetic
edge of the film. Later soun The 832-A twin tetrode tran
rove d soun d quality.
tube is about a stripes, which resu lted in imp smitting
This 1950s X-Ray tube. An old time favorite am
fixed anode and ong radio
foot long. It has a hams. No neutrodynization
as opposed
tubes increase
cathode. Modern to the European QQE06/40
a large anode that (see also
power by using eed.
Retronics December 2008).
rotates at a high sp
Retronics is a monthly column covering vintage electronics including legendary Elektor designs. Contributions, suggestions and
requests are welcomed; please send an email to editor@elektor.com
elektor 11-2011 73
gerards columns
74 11-2011 elektor
INFOTAINMENT
Hexadoku
Puzzle with an electronics touch
With the autumn leaves drifting by your window and not too many electronics projects on the workbench,
why not relax for a bit and stimulate the gray matter at the same time! It sure is possible start entering
the right numbers in the puzzle below. Next, send the ones in the gray boxes to us and you automatically
enter the prize draw for one of four Elektor Shop vouchers. Have fun!
The instructions for this puzzle are straightforward. Fully geared to in each column and in each of the 44 boxes (marked by the thicker
electronics fans and programmers, the Hexadoku puzzle employs black lines). A number of clues are given in the puzzle and these
the hexadecimal range 0 through F. In the diagram composed of determine the start situation. Correct entries received enter a draw
16 16 boxes, enter numbers such that all hexadecimal numbers for a main prize and three lesser prizes. All you need to do is send us
0 through F (thats 0-9 and A-F) occur once only in each row, once the numbers in the gray boxes.
Prize winners
The solution of the September 2011 Hexadoku is: 4D0F6.
The Elektor $140.00 voucher has been awarded to Alf Eriksson (Sweden).
The Elektor $70.00 vouchers have been awarded to M.F. Vidaud (France),
Parisi Vincenzo (Switzerland) and Monika Hfner (Germany).
Congratulations everyone!
1 9 5 3 8 7 E A 4 C F B D 2 6 0
C A F 6 3 D 9 4 8 0 1 2 E B 7 5
7 4 D 0 F 6 B 2 5 9 E A 3 1 C 8
B 8 2 E 5 0 C 1 3 D 6 7 F 4 9 A
E F B 9 2 5 D 8 6 3 A 4 1 7 0 C
0 5 A D 4 3 F C 1 7 9 E 6 8 B 2
4 1 C 2 6 9 7 E B 8 0 F 5 A D 3
6 3 7 8 A 1 0 B C 2 D 5 9 E F 4
8 6 E A 7 F 3 5 D 1 4 C 0 9 2 B
2 B 0 4 9 A 1 D 7 5 3 6 8 C E F
9 7 1 5 B C 8 6 F E 2 0 4 3 A D
D C 3 F E 4 2 0 9 A B 8 7 5 1 6
3 D 4 B C E A 7 0 6 5 9 2 F 8 1
5 E 6 7 D 8 4 F 2 B C 1 A 0 3 9
A 2 9 1 0 B 5 3 E F 8 D C 6 4 7
F 0 8 C 1 2 6 9 A 4 7 3 B D 5 E
The competition is not open to employees of Elektor International Media, its business partners and/or associated publishing houses.
76 11-2011 elektor
Save
Subscribe to
Circuit Cellar NOW!
www.circuitcellar.com
THE WORLDS SOURCE FOR EMBEDDED ELECTRONICS ENGINEERING INFORMATION
ELEKTORSHOWCASE
To book your showcase space contact Strategic Media Marketing Inc.
Tel. 1-978-281-7708 Fax 1-978-281-7706 Email ElektorUSA@smmarketing.us
www.hameg.com
From
Great Value in $129
TEST & MEASUREMENT
- Built-in Ethernet
- MODBUS TCP/IP
- Digital and Analog I/Os
- PWM/PID/Stepper Control
TRIANGLE
RESEARCH
INTERNATIONAL
on m Save 1
0
wit tor con %
o
ELEh coupon trollers
KTO
RMCcode
94
78 11-2011 elektor
products and services directory
SHOWCASE YOUR COMPANY HERE
Elektor provides you with more ways to For just $1100 ($100 per issue for eleven i.e., product shot, screen shot from your
promote your business with our Showcase issues), Elektor will publish your company website, company logo, catalog cover or
section -- a permanent feature of the name, website address and a 30-word whatever you choose to showcase.
magazine where you will be able to further description.
highlight your products and services. For $1650 ($150 per issue for eleven Places are limited and spaces will go on a
issues), we will publish the above plus strictly first come, first served basis.
run a 2-inch square, full-color image So please fax back your order today!
elektor 11-2011 79
SHOP BOOKS, CD-ROMs, DVDs, KITS & MODULES
Going Strong
A world of electronics
from a single shop! LabWorX: Straight from the Lab to your Brain
NE
applications and designing a solid system.
The most common IC compatible chip
classes are covered in detail. Two experi-
mentation boards are available that allow
for rapid prototype development. These
are completed by a USB to IC probe and a
software framework to control IC devices
from your computer.
Offer
Limited Period ers!
crib
for Elektor Subs
13% DISCOUNTrcuits A highly-practical guide
Linux PC -based
m/311ci
www.elektor.co Measurement Electronics
If you want to learn how to quickly build
Books
420 pages ISBN 978-1-907920-08-0 $47.60 264 pages ISBN 978-1-907920-03-5 $47.60
80 Prices and item descriptions subject to change. E. & O.E 11-2011 elektor
Bestseller!
Circuits, ideas, tips and tricks from Elektor
CD 1001 Circuits
Bestseller!
This CD-ROM contains more than 1000 cir-
Free mikroC compiler CD-ROM included Enhanced second edition cuits, ideas, tips and tricks from the Sum-
mer Circuits issues 2001-2010 of Elektor,
Controller Area Design your own supplemented with various other small
Network Projects Embedded Linux projects, including all circuit diagrams,
descriptions, component lists and full-
The aim of the book is to teach you the Control Centre on a PC sized layouts. The articles are grouped
basic principles of CAN networks and in
The main system described in this book alphabetically in nine different sections:
addition the development of microcon-
reuses an old PC, a wireless mains outlet audio & video, computer & microcontrol-
troller based projects using the CAN bus.
with three switches and one controller, ler, hobby & modelling, home & garden,
You will learn how to design microcon-
and a USB webcam. All this is linked to- high frequency, power supply, robotics,
troller based CAN bus nodes, build a CAN
gether by Linux. This book will serve up the test & measurement and of course a sec-
bus, develop high-level programs, and
basics of setting up a Linux environment tion miscellaneous for everything that
then exchange data in real-time over the
including a software development envi- didnt t in one of the other sections. Texts
bus. You will also learn how to build mi-
ronment so it can be used as a control and component lists may be searched with
crocontroller hardware and interface it to
centre. The book will also guide you the search function of Adobe Reader.
LEDs, LCDs, and A/D converters.
through the necessary setup and congu-
ISBN 978-1-907920-06-6 $55.70
260 pages ISBN 978-1-907920-04-2 $47.60 ration of a webserver, which will be the in-
terface to your very own home control
centre. New edition enhancements in-
clude details of extending the capabilities
of your control center with ports for a
mobile phone (for SMS messaging) and
the Elektor thermo snake for low-cost
networked real-time thermal monitoring
of your house and outbuildings. Now you
can additionally also send all kinds of use- More than 70,000 components
ful temperature and sensor warnings to a
mobile phone. All software needed will be CD Elektors Components
available at the Elektor website.
Database 6
416 pages ISBN 978-1-907920-02-8 $55.70
This CD-ROM gives you easy access to
Talk with your computer design data for over 7,800 ICs, more than
Design your own PC 35,600 transistors, FETs, thyristors and tri-
acs, just under 25,000 diodes and 1,800
Voice Control System More information on the optocouplers. The program package con-
This book guides you through practical Elektor Website: sists of eight databanks covering ICs, tran-
CD/DVD-ROMs
elektor 11-2011 81
SHOP BOOKS, CD-ROMs, DVDs, KITS & MODULES
CD/DVD-ROMs
Bestseller!
Audio DSP Course
(September 2011) USB Long-Term
This DSP board is the platform for the Weather Logger
More than 25 projects based on the Elektor applications described in our Audio DSP (September 2011)
ATM18 board Course. It is also intended to enable you to
develop your own initial digital audio This stand-alone data logger displays
CD ATM18 Collection signal processing applications. The DSP pressure, temperature and humidity
This CD-ROM contains all articles from the board can be used stand-alone as is, and readings generated by I2C bus sensors on
popular ATM18-CC2 series published in even though it is an ideal learning an LCD panel, and can run for six to eight
Elektor magazine. From RFID Reader and platform, with its 24-bit signal processing weeks on three AA batteries. The stored
Bluetooth linking right up to a chess com- capability for sampling rates up to readings can be read out over USB and
puter! Project software and PCB layouts in 192 kHz and its high-performance inter- plotted on a PC using gnuplot. Digital
PDF format are included. Whats more, this faces, it is also suitable for applications sensor modules keep the hardware sim-
CD also contains a Bascom AVR program- with very stringent quality requirements ple and no calibration is required.
ming course and helpful supplementary for both signal to noise ratio and DSP
documentation. computing power. Kit of parts incl. PCB, controller, humidity
sensor and air pressure sensor modules
ISBN 978-0-905705-92-7 $39.60 Populated and tested DSP board
Art.# 100888-73 $50.20
Art.# 110001-91 $186.70
FT232R USB/
Serial Bridge/BOB
All articles in Elektor Volume 2010 (September 2011)
82 Prices and item descriptions subject to change. E. & O.E 11-2011 elektor
$
Bestsellers
Product Shortlist
www.elektor.com/shop
110219-41 .... Programmed controller PIC12F675 DIL8....................................14.30
Morse Clock
110170-41 .... Programmed controller ATTiny4520-PU dip 8 ............................14.30
Return of the Elex Prototyping Board or use the Order Form near the end
ELEX-1 ........... Printed circuit board Universal exp. board ....................................7.90
ELEX-2 ........... Printed circuit board Double version universal
exp. board.................................................................................14.25
of the magazine!
ELEX-4 ........... Printed circuit board Quadruple
version universal exp. board ......................................................25.80
Arc Welding Effect for Model Railway Layouts Elektor US
110085-41 .... Programmed controller PIC10F200-I/P (DIP8) ...........................14.30 PO Box 180
Slave Flash for Underwater Camera Vernon, CT 06066
100584-41 .... Programmed controller PIC12F675i/p DIL8 ...............................14.30 USA
Phone: 860-875-2199
WAV Doorbell
Fax: 860-871-0411
110080-41 .... Programmed controller ATmega328p DIL28 .............................18.60
E-mail: order@elektor.com
elektor 11-2011 83
COMING ATTRACTIONS next month in elektor
Article titles and magazine contents subject to change; please check the magazine tab on www.elektor.com
elektor Uk/european December 2011 edition: on sale november 17, 2011. elektor USA november 2011 edition: published november 14, 2011.
84 11-2011e lektor
Order Form
11-2011
Description
$47.60
METHOD OF PAYMENT
Remit in US $ drawn on a US bank. Please
see next page for ordering information.
Design your own PC Voice
Check or Money Order
Control System NEW $47.60
Mastercard
CD 1001 Circuits NEW $55.70
VISA
Controller Area Network Projects $47.60 Discover
LabWorX Mastering the IC Bus $47.60 American Express
Sub-total
Prices and item descriptions subject to Shipping & Handling $ 5.00 Send order form to:
change. The publishers reserve the right to (Airmail from Europe)
change prices without prior notification. Elektor US
Prices and item descriptions shown here Total paid
supersede those in previous issues. E. & O.E. PO Box 180
Vernon, CT 06066
USA
Name/Company
Phone: 860-875-2199
Street & No.
Fax: 860-871-0411
E-mail: order@elektor.com
www.elektor.com/shop
City/State/Zip Country
E-mail Tel
Phone: 860-875-2199
Fax: 860-871-0411
Mail: Elektor US
PO Box 180
Vernon, CT 06066
USA
E-mail: sales@elektor.com
On-line at www.elektor.com
Customer service hours: 8:00 AM4:30 PM MondayThursday. Voice mail available at other times.
When leaving a message please be sure to leave a daytime telephone number where we can return your call.
PLEASE NOTE: While we strive to provide the best possible information in this issue, pricing and availability are subject to change
without notice. To find out about current pricing and stock, please call or email customer service.
COMPONENTS
Components for projects appearing in Elektor are usually available from certain advertisers in the magazine. If difficulties in obtaining
components are suspected, a source will normally be identified in the article. Please note, however, that the source(s) given is (are)
not exclusive.
PAYMENT
Orders must be prepaid. We accept checks or money orders (in US $ drawn on a US bank only), VISA, Mastercard, Discover, and
American Express credit cards. We do not accept C.O.D. orders.
We also accept wire transfers. Add $20 to cover fees charged for these transfers.
TERMS OF BUSINESS
Shipping Note: All orders will be shipped from Europe. Please allow 34 weeks for delivery. Shipping and handling via airmail:
US $20.00 per order. Returns Damaged or miss-shipped goods may be returned for replacement or refund. All returns must have an
RA #. Call or email customer service to receive an RA# before returning the merchandise and be sure to put the RA# on the outside of
the package. Please save shipping materials for possible carrier inspection. Requests for RA# must be received 30 days from invoice.
Patents Patent protection may exist with respect to circuits, devices, components, and items described in our books and magazines.
Elektor accepts no responsibility or liability for failing to identify such patent or other protection. Copyright All drawing, photo-
graphs, articles, printed circuit boards, programmed integrated circuits, diskettes, and software carriers published in our books and
magazines (other than in third-party advertisements) are copyrighted and may not be reproduced (or stored in any sort of retrieval
system) without written permission from Elektor. Notwithstanding, printed circuit boards may be produced for private and personal
use without prior permission. Limitation of liability Elektor shall not be liable in contract, tort, or otherwise, for any loss or damage
suffered by the purchaser whatsoever or howsoever arising out of, or in connection with, the supply of goods or services by Elektor other
than to supply goods as described or, at the option of Elektor, to refund the purchaser any money paid with respect to the goods.
All subscriptions begin with the current issue. Expect 34 weeks for receipt of
the first issue. Subscriptions, renewals, and change of address should be sent to:
Elektor US
PO Box 180
Vernon, CT 06066
USA
E-mail: sales@elektor.com
For gift subscriptions, please include gift recipients name and address as well
as your own, with remittance. A gift card will be sent on request.
Subscriptions may be cancelled at any time for a refund of all unmailed issues.
Further information at
INDEX OF ADVERTISERS
AP Circuits, Showcase. . . . . . . . . . . . . www.apcircuits.com. . . . . . . . . . . . . . . . . . . . 27, 78 Maxbotix, Showcase . . . . . . . . . . . . . . www.maxbotix.com . . . . . . . . . . . . . . . . . . . . . . . 78
Parallax . . . . . . . . . . . . . . . . . . . . . . . . www.parallax.com . . . . . . . . . . . . . . . . . . . . . . . . 27
2012 International CES. . . . . . . . . . . . . 2012 International CES. . . . . . . . . . . . . . . . . . . . . 12
Pico. . . . . . . . . . . . . . . . . . . . . . . . . . . www.picotech.com/pco462 . . . . . . . . . . . . . . . . . 11
DLP Design . . . . . . . . . . . . . . . . . . . . . www.dlpdesign.com. . . . . . . . . . . . . . . . . . . . . . . 39
Saelig . . . . . . . . . . . . . . . . . . . . . . . . . www.saelig.com. . . . . . . . . . . . . . . . . . . . . . . . . . 65
EzPCB . . . . . . . . . . . . . . . . . . . . . . . . . http://www.stc-51.com . . . . . . . . . . . . . . . . . . . . 27
Showcase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78, 79
Hameg Instruments, Showcase . . . . . . www hameg.us . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Images Scientific, Showcase . . . . . . . . www.imagesco.com. . . . . . . . . . . . . . . . . . . . . . . 78 Advertising space for the issue 8 December 2011
may be reserved not later than 15 November 2011
with Strategic Media Marketing, Inc. - 2 Main Street -
Linx Technologies. . . . . . . . . . . . . . . . . www.linxtechnologies.com. . . . . . . . . . . . . . . . . . 39
Gloucester, MA 01930 - USA Telephone 1.978.281.7708 -
Fax 1.978.281.7706 - e-mail: ElektorUSA@smmarketing.us to whom all
Loudspeaker Design Cookbook . . . . . . www.cc-webshop.com. . . . . . . . . . . . . . . . . . . . . 54 correspondence, copy instructions and artwork should be addressed.
elektor 11-2011 87
Microcontrollers
Development Platforms for Smartphone and Tablet Accessories
Reduce Time to Market with Microchip Solutions
The Microchip name and logo, the Microchip logo and PIC are registered trademarks and chipKIT is a trademark of Microchip Technology Incorporated in the USA and other countries. Android is a trademark of Google. iPad, iPhone and iPod are trademarks of Apple Inc., registered in the United States and other countries.
Controllers
Digital Signal
Analog
Memory
Want to design and develop an accessory for smartphones or tablets? ITS EASY TO GET STARTED!
RF & Wireless
The mobile device marketplace is exploding with ideas and opportunity.
While much of the high-tech world has settled down into evolutionary Visit www.microchip.com/android
improvements, the mobile world offers the promise of entirely new uses Purchase the PIC24F Accessory
for ever smarter devices. Development Starter Kit for Android
All other trademarks mentioned herein are the property of their respective companies. 2011 Microchip Technology Incorporated. All rights reserved.
Microchips new PIC24F Accessory Development Starter Kit for Android consists of Download the royalty-free, no-fee,
a 16-bit PIC24 development board, a PICkit 3 In-Circuit Debugger and a royalty- licensed software library
free, no fee licensed software library (available via download), which enables the
fast and easy development of Android smartphone and tablet accessories based on Contact androidsupport@microchip.com
Microchips large portfolio of 16-bit and 32-bit PIC microcontrollers (MCUs). for additional support
www.microchip.com/smartphone