Documente Academic
Documente Profesional
Documente Cultură
www.elektormagazine.com
colorful
AVR Playground
Improves the way
7-segment display
to do Arduino
Android on your Rpi part 1 Starter Kits and Development Boards
Swiss Pi Extensions Truly Random-Number Generator Debugging and
Decoding Digital Communication using the SmartScope RFID starter
kit for the Arduino Uno RGBDigit Clock IoT Gateway and Wireless Nodes
Lead-acid Battery Activator 0-30V NEC-style Remote Control Signals
with Elektor Uno R4 OBD2 Handheld using a Raspberry Pi Ethernet on
the Android I/O Board AVR Playground Retronics: made in Belgium
Walabot a 3D Sensor for your Smartphone Dock for BBC micro:bit
Build Your Own Theremin Gnublin 2 Linux Board PWM Motor Control
BBC micro:bit Dock Sensors Make Sense part 3 Review: STEMlab125-10 Q&A Electric
More I/O and easy access Motors Active Differential Probe v2 MicroPython Peculiar Parts
Elektor Magazine
Edition 2/2017
Volume 43, No. 482
March & April 2017
www.elektor.com
www.elektormagazine.com
Order must be
Elektor Magazine, English edition
is published 6 times a year by
www.elektor.com/advertising the back of the magazine always close to Hexadoku, another fireside favorite.
Advertising rates and terms available on Signing off with this edition my valued colleague and former Elektor Netherlands Editor
request.
Harry Baggen is retiring after 38 years with the company. Many of you will know Harry
not only from his magnificent audio projects like high-end amplifiers and loudspeakers,
but also from technical correspondence and advice at which he excelled. The same for his
Copyright Notice writing of hundreds of articles in a manner best described as S/N > 60 dB.
The circuits described in this magazine are for domes-
Happy reading,
tic and educational use only. All drawings, photographs,
printed circuit board layouts, programmed integrated
Jan Buiting, Editor-in-Chief
circuits, disks, CD-ROMs, DVDs, software carriers, and
article texts published in our books and magazines
(other than third-party advertisements) are copyright
Elektor International Media b.v. and may not be repro-
duced or transmitted in any form or by any means,
including photocopying, scanning and recording, in
The Circuit
whole or in part without prior written permission from Editor-in-Chief: Jan Buiting
the Publisher. Such written permission must also be
Deputy Editors: Thijs Beckers, Clemens Valens
obtained before any part of this publication is stored
Translators: David Ashton, Jan Buiting, Martin Cooke,
in a retrieval system of any nature. Patent protection
may exist in respect of circuits, devices, components Ken Cox, Arthur deBeun, Andrew Emmerson,
etc. described in this magazine. The Publisher does Tony Marsden, Mark Owen, Julian Rivers
not accept responsibility for failing to identify such Membership Manager: Raoul Morreau
patent(s) or other protection. The Publisher disclaims
International Editorial Staff: Thijs Beckers, Mariline Thiebaut-Brodier
any responsibility for the safe and proper function
of reader-assembled projects based upon or from Denis Meyer, Jens Nickel
schematics, descriptions or information published in or Laboratory Staff: Ton Giesberts, Luc Lemmens,
in relation with Elektor magazine. Clemens Valens, Jan Visser
Graphic Design & Prepress: Giel Dols
Elektor International Media b.v. 2017
Publisher: Don Akkermans
www.eimworld.com
Printed in the Netherlands
62 HomeLab Helicopter
26
96 Peculiar Parts, the series
Bubble Memory
OBD2 Handheld using a
128 Elektor STORE Raspberry Pi
130 Hexadoku
With new diagnostic software
7-segment display
With added duty cycle boost
118 MicroPython
Python for small systems
Next Editions
Elektor Magazine 3/2017
AVR Playground Studio Mic Preamp Li-Ion charger Spycam detector
Outside Lighting System L-Board a T-Board alter-
Improves the way to do Arduino
50
native nWatch 4-Channel Remote Control with XBee
The board presented in this article is a hybrid of IoT Gateway and Wireless Nodes Part 2: Software
an Arduino Uno and a traditional microcontroller and much more.
development board, intended for doing Arduino Elektor Magazine edition 3/2017 covering May and June is
without bad connections and loose wires (although it published on 13 April 2017. Delivery of printed copies to Elektor
doesnt disallow it). Gold Members is subject to transport.
90
Also sees through walls A Desktop Prototyping Tool for Custom PCBs (Voltera)
and more.
76 Android on your Raspberry Pi (1) Elektor Business Magazine edition 1/2017, special edition for
Using GPIO Pins Embedded World Nrnberg, is published on 1 March 2017.
for measurement and control functions Content and article titles subject to change.
RGBDigit Clock
A colorful 7-segment display
for your data
By Coen de Bruijn (The Netherlands) play contains eight 5050 RGB NeoPixel How the circuit works
LEDs (seven segments plus decimal Figure 1 depicts the full circuit diagram
point) with integrated driver chips, which for this project. The clock is 5-V powered
The clock is controlled by an ESP12 allow the user to control color and bright- via micro-USB connector K1. The power
module, which enables synchronizing ness of every segment/DP individually supply is protected by 2-A PTC resettable
the clock with an Internet time server, via a 3-wire bus (VCC, GND an DATA). fuse F1, with Schottky diode D1 acting
change the clock settings from any Up to 10 displays can be daisy chained as a reverse polarity protection. IC1 is
mobile device or computer in the net- via their DATA IN and DATA OUT pins. the main 3.3-V voltage regulator, and
work, or transmit sensor data via Wi-Fi. IC6 is the 3.3-V supply for the Qtouch
Each primary color LED of a NeoPixel can touch sensors IC4 and IC5 (note sepa-
What are they? be set to 256 levels of brightness, result- rated supply to prevent interference).
RGBDigits are manufactured by a Dutch ing in a whopping 256 x 256 x 256 = The two touch sensors Button0 and
company with the same name. Every dis- 16,777,216 colors for every segment/DP. Button1 are used to control the display
entry level
intermediate level
expert level
3 hours approx.
100 / $105 / 85
approx.
V+ V+ V+ V+
LED1 LED2 LED3 LED4
1 4 1 4 1 4 1 4
VDD_I VDD_O VDD_I VDD_O VDD_I VDD_O VDD_I VDD_O
2 5 2 5 2 5 2 5
DIN DOUT DIN DOUT DIN DOUT DIN DOUT
3 6 3 6 3 6 3 6
VSS_I VSS_O VSS_I VSS_O VSS_I VSS_O VSS_I VSS_O
DIN
VCC VCC V+
C5 C6
R1 R3 R4
100n 100n
IC2
10k
10k
1 6
VCCA VCCB R7
GPIO2 3 4 DIN
NSL-19M51 A B 1k
RESET 1
MOD1 16 ESP-TXD 5 2
RST TXD DIR GND
2 15 ESP-RXD
ADC RXD 74LVC1T45GW
R2 3 14 SCL
EN/CH_PD GPIO5
GPIO16 4 13 SDA VCC
10k
GPIO16 GPIO4
GPIO14 5 12 FLASH
GPIO14 GPIO0 C10
BUTTON0 6 11 GPIO2
GPIO12 GPIO2
BUTTON1 7 10 GPIO15 4
VCC GPIO13 ESP-12E/F GPIO15 100n
8 9 VCC
VCC GND
R5 IC3
GPIO10
SCL 1 3 SDA
GPIO9
SCL
SCLK
SDA
MISO
MOSI
C8 C7
10k
CS0
24LC64T-I/OT
100u 100n 17 18 19 20 21 22
GND
16V
K2 2
6
VCC LD1117S33TR
5 ESP-TXD
FTDI cable
2 ADJ
C2 C1 C3 C4 C11
1
FLASH
S1 10u 100n 1u 10u 100n
10V 10V 5
R11
3 VDD 6
VCC FLASH 10k SNSK SYNC
C12 IC4
K3 K1
5
F1 2A D1 V+ AT42QT1010
1
VBUS X7R 10n 4 -TSHR 1 BUTTON0
4 GPIO14 2 SNS OUT
D MF-SMDF200-2 MBRS540 VSS
3 GPIO15
POWER
3 K5
D+ 2
2 GPIO16 4 1
ID BUTTON0
1 5 2
GND BUTTON1
VCCIO
VCC
C13
USB-MICRO
VCC
R8
MCP1700-33 100n
R9 R10 5
10k
K4 C14 IC5
4 RESET
C15 C16 AT42QT1010
BME280 BoB
3 SDA C9 S2 1
X7R 10n 4 -TSHR 1 BUTTON1
2 SCL SNS OUT
1u 1u VSS
1 10u 10V
RESET
2
160100 - 11
Figure 1. A fair number of connections need to be made. To keep the schematic readable a lot of those connections are bundled in a bus.
Web Links
[1] www.arduinesp.com/getting-started
[2] www.elektormagazine.com/160100
[3] https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md
[4] https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.2.0/ESP8266FS-0.2.0.zip
Elektor breaks the constraints of a magazine. Its a community of active e-engineers from
novices to professionals eager to learn, make, design, and share surprising electronics.
Elektor PCB Service: Order your own PCBs, Elektor Weekly & Paperless:
both one-offs and larger runs. Your digital weekly news update. Free.
www.elektorpcbservice.com www.elektor.com/newsletter
facebook.com/ElektorIM twitter.com/Elektor
Starter Kits & Development Boards
A brief round-up
In these very pages exactly a year ago we took a look at some new microcontrollers and development
boards. Today we bring our (inevitably incomplete) survey up to date, looking at some new starter kits and
some interesting new development platforms.
Matchbox-sized
The XMC 2Go board we looked at last Figure 2. Windows-based software tools are available for both the 2Go sensors, allowing you to try
time, with its well-equipped XMC1100 them out before you embark on the programming proper.
A grand entrance?
Last year Renesas announced a small
demonstration board based on the 16-bit
RL78 family of microcontrollers, and now
the manufacturer is marketing its Syn-
ergy platform, based on 32-bit ARM Cor-
tex-M cores. Normally one would expect
to have to dig deep in ones pockets for
a Renesas starter kit, but the SK-S7G2
[5] www.atmel.com/tools/atti-
ny817-xpro.aspx
Figure 14. What you get for your money: two printed circuit boards, a high-quality cable, a USB
[6] http://start.atmel.com
transceiver with antenna, an expansion kit and even a pair of tweezers.
[7] www.cypress.com/products/
psoc-analog-coprocessor
[8] www.cypress.com/documentati-
Jumpers and switches on the front of the play. A demonstration tool is provided
on/development-kitsboards/cy-
board and resistors fitted to the back of that allows you to examine all the most
8ckit-048-psoc-analog-coproces-
the board allow various configurations to important settings of the regulators, with
sor-pioneer-kit
be tested, and the individual regulators the aim of helping you translate the pro-
[9] www.renesas.com/en-eu/products/
can be connected in series or parallel, or totype into your own energy-harvesting
software-tools/boards-and-kits/re-
taken out of circuit entirely. The combina- design (Figure 15). A blank shield, type
nesas-starter-kits/renesas-syner-
tions are too numerous to explore here, DC2510A, is provided for you to add your
gy-sk-s7g2.html
but the accompanying documentation own circuitry. The whole thing can of
describes the board and all its options course be used wirelessly with the help of [10] www.renesas.com/en-us/products/
in scrupulous detail. the DC2274A-A SmartMesh USB dongle, synergy/book.html
The second board, with part code and a software development kit (SDK) [11] http://synergygallery.renesas.com/
DC2321A [19], can be plugged directly is also provided. Overall the demonstra- [12] www.nxp.com/products/:KW41Z
into the side of the DC2344A. The tion kit is a worthwhile purchase if you
[13] www.nxp.com/
main components on the board are the want to shorten the development time
products/:FRDM-KW41Z
LTP5901 Dust mote module and an for your own energy harvesting or wire-
e-ink display. The LTP5901, which is less product. [14] www.analog.com/en/products/
based around an ARM Cortex-M3 core, is (160287) processors-dsp/microcontrol-
a member of Linear Technologys Smart- lers/arm-cortex-m3-processor/
Mesh IP Wireless family of devices. These aducm3029.html
are designed around the IEEE 802.15.4e Internet Links [15] www.analog.com/en/design-cen-
standard, which also forms the basis of [1] www.elektormagazine.com/150687 ter/processors-and-dsp/evalua-
ZigBee networks. The Dust technol- tion-and-development-software/
[2] www.infineon.com/cms/en/product/
ogy allows a range of different types adswt-cces.html
promopages/sensors-2go/
of structured radio network to be cre- [16] www.analog.com/en/design-center/
ated, for example for IoT applications. [3] www.infineon.com/cms/en/pro-
evaluation-hardware-and-software/
Within the Gleanergy platform the job duct/evaluation-boards/H-BRID-
evaluation-boards-kits/adzs-bf707-
of the LTP5901 module (itself designed GE+KIT+2GO/productType htm-
blip2.html
for low-power operation) is to monitor l?productType=5546d46250cc1fd-
f015124e027823420 [17] www.linear.com/solutions/5744
the energy harvesting process, and then
send the results out over the micro USB [4] www.st.com/en/evaluati- [18] www.linear.com/solutions/7717
port and show them on the e-ink dis- on-tools/32f412gdiscovery.html [19] www.linear.com/solutions/7662
IoT Gateway
and Wireless Nodes
Part 1: The hardware
Sometimes you want to have specific functions in a home automation system that are not available with
any commercial product. Thats why the author decided to develop his own system, which features wireless
communication between the various nodes and the central gateway. The gateway uses MQTT to send
measurement data to an OpenHAB server, which processes and displays the data. His project has now been
copied and extended by other users. In a series of two articles, the author describes the key elements of his
system. More detailed information and the corresponding software are available for free on the Internet.
U3
HT1117-33
+5V
3 2
C1 C2
GND TAB
1 4 100n 47u
U2
1 24
R2 R3 TXO RAW U1
2 23
RXI GND
10k
4k7
3 22 8 2
RST RST 3.3V DIO0
4 21 3
GND VCC DIO1
U4 5 20 4
1
DHT11 2 A3 RESET DIO2
6 19 5
VDD 3 A2 DIO3 ANT1
7 18 6
DATA 4 A1 DIO4
8 17 7
NC 5 A0 DIO5
9 16 12
GND 6 13 SCK
10 15 13 9
7 12 MISO GND
11 14 14 10
8 11 MOSI ANT
12 13 15 11
9 10 NSS GND
R1
ARDUINO_MINI RFM69HCW
1k
S1
LED1
15008 5 - 13
Figure 3. Schematic diagram of an end node. Figure 4. A DIG node in a plug-in timer housing.
nodeID is the node identifier. Each node has a unique ID GND TAB C1 C2
1 4
(address), which is determined when the code is compiled. 100n 47u
1k
1k
The gateway subscribes to all southbound messages for all
nodes in the network by means of the following wildcard topic: LED1 LED2
U4
W5100 Ethernet Module
M Q T T R a d io +5V
lin k lin k
NSS
home/rfm_gw/sb/# MOSI VDD
MISO U5
4
SCK
3
Of course, OpenHAB needs to receive all messages from the 2
RJ45
15008 5 - 15
home/rfm_gw/nb/#
Table 4 shows a number of examples of MQTT messages. Figure 5. Schematic diagram of the gateway.
End nodes
The end nodes are based on Arduino boards. The following DHT is a node with sensors for temperature and humidity.
conditions and constraints are taken into account in the design: This node has a digital output and a pushbutton.
DIG is a simplified version of the DHT node. It only has a
The RFM69 module has an operating voltage of 3.3 V, and pushbutton and a digital output.
the maximum permissible voltage on its inputs is 3.9 V. RFID is a node with an RFID reader. When an RFID
To keep things simple, we use an Arduino that also ope- device is detected, the node sends the RFID identifier to
rates from 3.3 V. We opted for the Arduino Pro Mini, which OpenHAB.
operates from 3.3 V and can be connected to the RFM69 LCD is a node with a liquid crystal display. Text strings can
without level conversion. You can also use the Arduino be sent from OpenHAB to the display.
Buono R3, which can be switched to 3.3 V. RC is a node equipped with a 433 MHz transmitter module.
The RFM69 module briefly draws a significant amount cur- It can be used to operate switches in the Dutch KlikAanKli-
rent (130 mA) when transmitting, so the supply needs to kUit home automation system [4].
have sufficient capacity.
The Arduino and the RFM69 communicate with each other The software can easily be adapted to add or modify functions.
over the SPI bus. The standard Arduino pins are used for The construction of a node is strongly dependent on its func-
that purpose. tion. For example, the case of an inexpensive mechanical timer
The RFM69 may not be operated without an antenna. A switch can be used to house a DIG node. An example of this
piece of wire 8.6 cm long gives excellent results in most is shown in Figure 4.
cases.
The gateway
The schematic diagram of one of the end nodes is shown in The gateway consists of an Arduino, an RFM69 module and
Figure 3. This node is equipped with a DHT11 temperature an W5100 Ethernet module. Figure 5 shows the schematic
and humidity sensor connected to pin 4 of the Arduino. A diagram. The gateway also uses an Arduino operating at 3.3 V.
pushbutton is connected to digital I/O pin 8, and an LED is On the gateway the SPI bus is shared by the RFM69 and W5100
connected to pin 9. modules. The SCK, MOSI and MISO signals are connected to
both devices in parallel. Different Slave Select (SS) signals are
The RFM69 module is connected to the Arduino over the SPI used to select the individual devices on the bus: pin 8 for the
bus (SCK, MOSI, MISO and NSS). The 3.3 V supply voltage RFM69 and pin 10 for the Ethernet module.
is provided by an AMS1117 voltage regulator, with enough An AMS1117 also provides the 3.3 V supply voltage for the
decoupling capacitors to suppress current spikes. gateway. Two LEDs are provided to indicate the status of the
The software loaded into the Arduino determines the function gateway.
of the end node. The following end node devices have been A separate module is used for the Ethernet connection. If you
developed so far: use an Arduino Buono board, you can use a Wiznet Ethernet
There are two things you have to pay attention to when buil-
ding the gateway, as described below.
W5100 bug
The hardware of the W5100 is not directly suitable for sha-
ring an SPI bus with other devices. When an SPI bus device is
not using the bus, it is supposed to release the signal lines so
that they can be used by other devices. The original W5100
is not designed to do this. The author solved this problem by
using an inverter to generate the SEN control signal from the
CS signal (see [5] for more details). The necessary inverter
is integrated in newer versions of the W5100 module. The
module which the author bought on eBay did not include this
feature, so the inverter had to be added externally. As can be
seen in Figure 7, a type 4011 IC was used for this. There you
Figure 6. The authors fully assembled gateway.
can also see that it is easy to connect the SEN signal line via
a pull-up resistor on the circuit board. Remember to connect
the unused inputs of the 4011 to ground.
To be continued
Figure 7. The 4011 is attached to the housing of the Ethernet connector In the following article we will describe the software for the
and generates the SEN signal for the W5100 from the CS signal. gateway and the nodes, as well as the configuration of Mos-
quitto and OpenHAB. If you cant wait, you can already down-
load the software at [6]. You must have Mosquitto available
in order to test the gateway. Its also handy to have an MQTT
client for testing. The MyMQTT app is a good choice for Android,
and on a Windows system you can use Chrome Lens or MQTT.
FX. Figure 8 gives an impression of the messages you can
expect to see.
This project has now been built by several other people. Exten-
sions, issues and experience are discussed and shared on the
forum site [7].
(150085)
Web Links
[1] https://mosquitto.org
[2] www.openhab.org
[3] www.elektormagazine.com/tags/journey-into-the-cloud
[4] www.klikaanklikuit.nl (Dutch!)
[5] http://john.crouchley.com/blog/archives/662
[6] https://github.com/computourist/RFM69-MQTT-client
[7] http://homeautomation.proboards.com/board/2/
Figure 8. This screenshot shows some examples of MQTT messages. openhab-rfm69-based-arduino
PROJECT INFORMATION
Elektor Uno R4
Arduino OCM
Remote Control RC-5
entry level
intermediate level By Clemens Valens (Elektor Labs) are commonly found in infrared remote
expert level controls where they are used to modulate
the current through an IR LED.
The OCM combines the outputs of Timer3 My home, and yours too I reckon, is
1 hour approximately and Timer4 another Elektor Uno R4 littered with remote controls (RCs).
exclusivity and makes the result avail- Some time ago when I needed a Philips
able on PD2, which is Arduino pin 2 and RC-5-compatible RC I had to try them
Elektor Uno R4 MCU pin 32. Here, combining means all only to discover that none of them
computer with Arduino IDE either AND-ing or OR-ing the two sig- used the RC-5 protocol, not even my
nals, as shown in Figure 1. The value of Philips DVD player (using RC-6). Most
register PORTD2 determines which oper- of my RCs appeared to use some variant
25 / $30 / 20 ation is executed. If PORTD2 is set to 1, of the Japanese NEC protocol instead.
approximately then OR-mode is selected; if PORTD2 is This is understandable as most of the
set to 0, AND-mode is what you get. remote-controlled equipment in my
Signals similar to those from Figure 1 house, and yours too I reckon, was made
SHOPPING LIST
150790-91
elektor Uno R4
The Pi-OBD-HAT is an off the shelf add-on board for the Raspberry Pi which converts the tiny computer into
a dedicated OBD2 diagnostic tool. One disadvantage was the need of a terminal program running on a PC for
control. A much more convenient and neater solution is provided by the HHGui OBD2 diagnostic software.
The GUI software HHGui is a variant of published in September 2009 in Elektor little unconventional and shows how firm-
the HHemu program I wrote for the OBD2 Magazine [2]. The OBD2 analyzer NG ware originally written for a microcon-
handheld emulator [1] which is a sort employs the DIAMEX DXM OBD2 mod- troller can be ported to a Raspberry Pi or
of Swiss army knife tool for developers ule [3]. PC, ideally without making any changes
working with the OBD2 analyzer NG/ to the firmware source code.
DIAMEX Handheld Open (HHOpen). This The development process HHEmu was originally conceived as a
unit is a handheld OBD2 diagnostic tool The software development process is a pure development tool to test new ver-
Model B or RPi 3 Model B are preferred owing to their higher of the RPi board. The hat is held in place using the threaded
processor speed. The PI-OBD hat uses just eight pins of the spacers and screws supplied.
RPi headers to provide power, connections for serial data inter- The Raspberry Pi is powered by the vehicle battery via the
face and reset signal to activate the PI-OBD bootloader. Serial OBD2 plug. No other external power source is required unless
you are testing or configuring the unit away from the vehicle Fire it up
when it will then be powered via its USB connection. Power for To begin using the PI-OBD HAT you will need some basic knowl-
the 7 Raspberry Pi display is provided by the two-pin header edge of the Raspberry Pi environment, the use of Linux and
on the hat. The photo is from under the RPi with the OBD hat the software installation. For the purposes of configuration and
fitted and the display PCB above. A description of the header operation, unless you are using a touch screen with the RPi,
pin connections is printed on the PCB, be sure not to you will need to plug in a keyboard
get them mixed up! and mouse.
There are two OBD2 ports on the PI-OBD hat, one
is suitable for free cabling hookup and the
other with a sub-D connector cable.
A single-row 9-way header
plug (or socket) can
be used to connect
to Port 2 along the
board edge. The
port 2 connector
has the advantage
it can be plugged in
and out whilst the hat is
attached to the RPi but there is
also the risk of plugging it in the wrong
way round. Always pay attention to the
printed identification on the PCB! There
can be no confusion on port 1 because the
connector on the board has a detent position and the 9-pin sub-D The first exercise now is to enable the RPis serial interface but
connector at the other end of the cable can only be connected a slightly different procedure is necessary for each different RPi
one way round. The flat band connector on this port must be model and space limitations here makes it necessary to provide
inserted before the hat is assembled onto the RPi, it cant be this information via this link [10]. The unit will be ready for use
plugged in or withdrawn without first releasing the hat. after a functional test using a terminal program.
Web Links
[1] HHEmu: www.elektormagazine.com/labs/firmware-update-and-emulator-for-obd2-analyser-ng-wireless-obd2
[2] OBD2-Analyser NG: www.elektormagazine.com/magazine/elektor-200909/19167
[3] DXM-Modul (German!): www.diamex.de/dxshop/DIAMEX-DXM-OBD2-Modul
[4] Bluetooth for OBD-2: www.elektormagazine.com/magazine/elektor-201004/19297
[5] HHGui: www.elektormagazine.com/labs/obd2-for-raspberry-pi
[6] www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=66368
[7] http://standards.sae.org/j1979_201408/
[8] https://en.wikipedia.org/wiki/OBD-II_PIDs
[9] www.iso.org/iso/home/store/catalogue_ics/catalogue_detail_ics.htm?csnumber=67245
[10] Pi-OBD-HAT: www.elektor.com/pi-obd-hat-obd2-module-for-raspberry-pi
https://goo.gl/V1EUOC
Swiss Pi Extensions
Hardware extensions
By Peter Sheeren
and Ilse Joostens (Belgium)
PROJECT INFORMATION
Microcontrollers
Raspberry Pi Swiss Pi
+12V +12V
K10
D18
3
2 R9 R10 R11 R12 R13 R14 R15 R16
1
1N4007
2k2
2k2
2k2
2k2
2k2
2k2
2k2
2k2
RY1 ... RY8 = G5Q-SPDT
C1 K1
D9
K11
1 100u
* * D1 2 RY1 S 1
P 2
2
3
1
O
1N4148
T1 K2
R18 D10
* 2 RY2 S 1
4k7 D2
P 2
BC547 3
1
O
1N4148
T2
R19 D11 K3
* 2 RY3 S 1
4k7 D3
P 2
BC547 3
1
O
1N4148
T3
R20 D12 K4
* 2 RY4 S 1
4k7 D4
P 2
BC547 3
1
O
K9
1N4148
1 2 T4
R21 D13 K5
*
3 4 2 RY5 S 1
4k7 D5
+12V 5 6 P 2
7 8 BC547 3
1
O
9 10
R17
1N4148
* T5
D14 K6
2k2
R22
* 2 RY6 S 1
4k7 D6
P 2
D17
BC547 3
1
O
T9 1N4148
T6
R26 R23 D15 K7
* 2 RY7 S 1
4k7 4k7 D7
P 2
BC547 3
BC547 1
O
R35
1N4148
T7
K8
100k
R24 D16
* 2 RY8 S 1
4k7 D8
P 2
BC547 3
1
O
1N4148
T8
R25
4k7
+12V R1 ...R8
560R
* RY1 ... RY8
100k
100k
100k
100k
100k
100k
100k
D9 ... D16 ZC
4 2
S202S02
T1 ... T8
BC547
1603 17 - 11
Figure 1. The eight-channel relay board is suitable for both conventional G5Q-SPDT relays and S202S02 solid-state relays.
when the supply voltage is present on such as 24 V. However, in that case a Eight-channel digital input
the Swiss Pi board. number of resistor values will have to board
If desired, you can also use G5Q relays be changed. This extension provides eight galvani-
with a different supply voltage rating, cally isolated inputs with an input volt-
D25 D29
D1 BC547B R1 R5
BC547B D13
T1 GPIO1 GPIO5 T5
220R 220R
OK1.A OK2.A
K1 1N4148 1 15 15 1 1N4148 K2
R9 D2 D3 D15 D14 R13
1 1
10k 10k
1 2 2 5
2x 1N4148 2x 1N4148
2 16 16 2
D26 D30
D4 BC547B R2 R6
BC547B D16
T2 GPIO2 GPIO6 T6
220R 220R
OK1.B OK2.B
1N4148 4 14 14 4 1N4148
R10 D5 D6 D18 D17 R14
3 3
10k 10k
2 4 4 6
2x 1N4148 2x 1N4148
3 13 13 3
D27 D31
D7 BC547B R3 R7
BC547B D19
T3 GPIO3 GPIO7 T7
220R 220R
OK1.C OK2.C
1N4148 5 11 K3 11 5 1N4148
R11 D8 D9 D21 D20 R15
5 1 2 5
10k 10k
3 6 3 4 6 7
2x 1N4148 2x 1N4148
5 6
6 12 7 8 12 6
9 10
D28 D32
D10 BC547B R4 R8
BC547B D22
T4 GPIO4 GPIO8 T8
220R 220R
OK1.D OK2.D
1N4148 8 10 10 8 1N4148
R12 D11 D12 D24 D23 R16
7 7
10k 10k
4 8 8 8
2x 1N4148 2x 1N4148
7 9 9 7
1603 17 - 12
Figure 2. Eight galvanically isolated digital inputs are implemented with optocouplers.
330R
+5V/1 +5V/2
the optocouplers and the indicator LEDs IC5
C7
D1
5 6 1
more or less constant, regardless of the 22u
C1 C2 1N4007 C8 C5
input voltage. This current is equal to 2
100n 100n 4700u 470n
the forward voltage drop of two 1N4148 4
4N25M
2
1 2
2
VS
voltage of the transistor, divided by 220 VDD1 VDD2 2
EF 1
K1
K5 IC1 IC3
(the resistance value of R1R8). The cur- 1 2
VIA VOA
7 3
IN1 OUT1
1 2
2 3 6 5 7 3
rent through the 1N4148 diodes ranges +5V/1 VIB
ADuM1200ARZ
VOB IN2
TLE5206-2
OUT2
4
1 2 4 5 4
amps over the input voltage range of 3 4 1 2
R2 2
5 to 45 V. If you look at the character- 5 6
330R
7 8 +5V/1 +5V/2
istic curve of the 1N4148, you can see IC6 9 10 D2
5 6 1
that this is precisely the region where C4 C3 1N4007 C9 C6
K1 1N5819 1N5819 K5
1 1
3 6 2 2 6 3
2 2
1 1
R41
10k
* 4 5 3
IC17.A IC19.A
3 5 4
R45
10k
*
R1 R33 R37 R17
* *
100R
100R
10R
10R
IC9, IC10, IC13, IC14 = LM358N
R51 R63
R2 IC17, IC19 = OPA2344PA R18
3 8 8 3
* *
T1 T5
10k
10k
10R
10R
1 1
R49 IC9.A IC13.A R61
2 5 +5V 5 2
10k 10k
4 BC D9 R50 7 7 R62 D13 BC 4
R3 R4 C17 IC9.B IC13.B C23 R19 R20
C1 557B 6 6 557B C9
* * * *
10k
10k
10R
10R
10R
10R
100n 100n
1n 5V1 8 C18 8 C24 5V1 1n
IC17 IC19
4 100n 4 100n
IC2 IC6
HCNR200 HCNR200
1 C4 C12 1
D2 1n 1n D6
2
* R7480k6 * R7880k6 2
K2 1N5819 1N5819 K6
1 1
3 6 6 6 6 3
2 2
7 7
R42
10k
* 4 5 5
IC17.B IC19.B
5 5 4
R46
10k
*
R5 R34 R38 R21
* *
100R
100R
10R
10R
R54 +5V R66
R6 R22
3 8 8 3
* *
T2 T6
10k
10k
10R
10R
1 1
R52 IC10.A K9 IC14.A R64
2 5 5 2
10k ADC1 1 2 ADC2 10k
R7 R8
4 BC D10 R53
IC10.B
7 7
IC14.B
R65 D14 BC 4
R23 R24
557B C19 ADC3 3 4 ADC4 C25 557B
C3 6 6 C11
* * * *
10k
10k
ADC5 5 6 ADC6
10R
10R
10R
10R
100n ADC7 7 8 ADC8 100n
1n 5V1 5V1 1n
9 10
IC3 IC7
HCNR200 HCNR200
1 C6 C14 1
D3 1n 1n D7
2
* R7580k6 * R7980k6 2
K3 1N5819 1N5819 K7
1 1
3 6 2 2 6 3
2 2
1 1
R43
10k
* 4 5 3
IC18.A IC20.A
3 5 4
R47
10k
*
R9 R35 R39 R25
* *
100R
100R
10R
10R
R57 IC11, IC12, IC15, IC16 = LM358N R69
R10 R26
3 8 IC18, IC20 = OPA2344PA 8 3
* *
T3 T7
10k
10k
10R
10R
1 1
R55 IC11.A IC15.A R67
2 5 +5V 5 2
10k 10k
R11 R12
4 BC D11 R56
IC11.B
7 7
IC15.B
R68 D15 BC 4
R27 R28
C20 C26
C5 557B 6 6 557B C13
* * * *
10k
10k
10R
10R
10R
10R
100n 100n
1n 5V1 8 C21 8 C27 5V1 1n
IC18 IC20
4 100n 4 100n
IC4 IC8
HCNR200 HCNR200
1 C8 C16 1
D4 1n 1n D8
2
* R7680k6 * R8080k6 2
K4 1N5819 1N5819 K8
1 1
3 6 6 6 6 3
2 2
7 7
R44
10k
* 4 5 5
IC18.B IC20.B
5 5 4
R48
10k
*
R13 R36 R40 R29
* *
100R
100R
10R
10R
R60 R72
R14 R30
3 8 8 3
* *
T4 T8
10k
10k
10R
1 1 10R
R58 IC12.A IC16.A R70
2 5 5 2
10k 10k
4 BC D12 R59 7 7 R71 D16 BC 4
R15 R16 C22 IC12.B IC16.B C28 557B R31 R32
C7 6 6 C15
* * 557B
* *
10k
10k
10R
10R
10R
10R
100n 100n
1n 5V1 5V1 1n
1603 17 - 14
Figure 4. The schematic of the current loop interface board looks fairly large, but it actually consists of eight identical circuits.
be daisy-chained to enable a total of ing sensors, despite the advent of digi- provide feedback from the power emit-
eight DC motors to be controlled with tal alternatives. Current loops are sim- ted by the LED. The overall transmission
the Swiss Pi. ple and robust, and they have a long characteristic is virtually linear because
Finally, a DC/DC converter provides the working range. Consequently, there are the current through the photodiode at
5 V supply voltage for the logic circuitry a lot of sensors available which use this the receive end is nearly the same as
on the H-bridge side. If you want to technology. the current through the photodiode at
use relatively high supply voltages, it is the transmit end.
essential to choose a DC/DC converter The interface described here (see Fig-
that can withstand a 40 V input voltage. ure 4) is built around HCNR200 linear For this circuit we used a fairly direct
optocouplers from Avago. The internal copy of the typical application circuit on
Current loop interface structure of these devices consists of two the Avago data sheet, with only a few
Current loop interfaces are still widely matched photodiodes and an LED. At the minor changes. For instance, we replaced
used in the industrial sector for read- transmit end, one photodiode is used to the LM158 opamps at the transmit end
10k
1u R4
10k
C1 8 8 C2 R6
5
IC1 IC2 10k
7
100n 4 4 100n IC1.B
6
R5
C10
10k
R7
IC1, IC2 = LM358N 10k 1u
R9
3
10k
1
IC2.A
2
R8
C8
COMPONENT LIST FOR CURRENT LOOP INTERFACE
Figure 5. The PWM to voltage converter board generates 0 to 10 V voltage outputs from PWM signals.
10k
+5V
1u R10
10k K1
K2 1
R12
PWM1 1 2 PWM2 5 2
10k
PWM3 3 4 PWM4 7 3
IC2.B
PWM5 5 6 PWM6 6 4
PWM7 7 8 PWM8 R11 5
C11
9 10 6
10k
R13
7
10k 1u
8
R15
3 9
10k
1
IC3.A
2
R14
+12V C9
10k
1u R16
10k
C3 8 8 C4 R18
5
IC3 IC4 10k
7
100n 4 4 100n IC3.B
6
R17
C12
10k
www.elektormagazine.com
R19
IC3, IC4 = LM358N 10k 1u
R21
3
10k
1
IC4.A
2
R20
C13
10k
1u R22
10k
R24
5
10k
7
IC5 IC4.B
IC6 6
10k
DC/DC
C15 C5 C6 1u
IN OUT
100u 100n 100n
1603 17 - 15
38
LM158 devices by OPA2344PA opamps.
Unlike the LMx58 opamps, the output
of the OPA2344PA can easily reach 4 V
with a supply voltage of 5 V. Unfortu-
nately, in the near future these opamps
will only be available in the SOIC-8
package. A possible alternative is the
LM6142BIN/NOPB.
PWM to voltage
converter
The PWM to 010 V converter board is
intended to drive light dimmers (includ
(includ-
extended range device ing LED dimmers), most of which use
for use from 55 to +125C. The 010 V control signals. The PWM signal
components used in the Raspberry Pi from the Swiss Pi is converted to a DC
by LM358 devices. and the Swiss Pi are intended for com- voltage by a RC filter, and this voltage is
They cost a lot less and are more read- mercial use with a temperature range of then buffered and doubled by the opa-
ily available than the LM158. The main 0 to 70C. In that situation there is not mps (see Figure 5).
difference is in the rated temperature much reason to use the LM158.
range of the opamps: the LM158 is an At the receive end we replaced the The current consumption of the opamps
R1 R2
T2
BOARD
330R 330R
R9 R10
STP36NF06L STP36NF06L
470R
470R
D1 D2
3 4
T3 T4
R3 R4
330R 330R
R11 R12
STP36NF06L STP36NF06L
470R
470R
D3 K1 D4
1 2
3 4
5 6
7 8
5 6
9 10
T5 T6
R5 R6
330R 330R
R13 R14
STP36NF06L STP36NF06L
470R
470R
D5 D6
7 8
T7 T8
R7 R8
is low and the load on the 010 V signals is usually low, so a
330R
R15 R16
330R
simple DC/DC converter is used to provide the higher supply
STP36NF06L STP36NF06L
voltage for the opamps. It converts the 5 V supply voltage
470R
470R
SERVO1 SERVO2
1 1
2 2
R1 R2
3 3
1k 1k
SERVO3
1 1
SERVO4 COMPONENT LIST FOR SERVO
2
3
R3
1k
K1 R4
1k
2
3
MOTOR BOARD
1 2
3 4
SERVO5 5 6 SERVO6
1 1
7 8
2 2
R5 9 10 R6
3 3
1k 1k
SERVO7 SERVO8
1 1
2 2
R7 R8
3 3
1k 1k
K2
1
2
1603 17 - 17
Figure 7. With this simple servo motor board you can control up to eight
servo motors from the Swiss Pi.
mouser.com
to 60 V with a rated current of 30 A (RDS(on) = 0.032 at
VGS 10 V / 15 A). The STP36NF06L is a logic-level MOSFET,
which means it can be driven fully on even with a gate volt-
age less than 5 V. With a VGS of 5 V the on resistance RDS(on) is
0.045 , which in practice means that you can switch about
5 A per channel without needing a heat sink for the MOSFET.
The Newest Products for Your Newest Designs
Each channel also has an indicator LED.
The resistors protect the Swiss Pi in the event that the three-
pin plug of a servo motor is accidentally connected the wrong
way.
In combination with the previous article and the many soft-
ware examples described there [3], you now have an arse-
nal of tools to tackle a wide range of applications with the
Swiss Pi / Raspberry Pi duo.
(160317)
Over 4 Million
products from over
600 manufacturers.
Web Links
[1] www.elektormagazine.com/150584
[2] www.elektormagazine.com/160317
[3] www.elektormagazine.com/160237
Ethernet
on the Android I/O Board
Using a USR-TCP232-T module
By Elbert Jan van Veldhuizen (The Netherlands)
The USR-TCP232-T module [1] is one of the cheapest modules other way round: the module takes the initiative to create a
around that can convert data from an Ethernet connection into connection to the app. For the Android I/O board we have to
serial data, which can be processed by the Android I/O board. configure the USR-TCP232-T as a server: The standard software
The advantage of an Ethernet module is that it doesnt use for the apps always takes the initiative to create the connection.
radio waves for the connection, which means that any inter- In both the server mode and client mode you can choose bet-
ference in that area is avoided. ween a UDP and TCP connection. With a UDP connection the
The USR-TCP232-T module can operate in one of four modes data is transmitted without any checks taking place that the
[2]. The main modes are a server mode and a client mode. data has been received successfully. With a TCP connection
In server mode the app has to create the connection with the there are checks to see that the data has been received (and
USR-TCP232-T module. In client mode the module works the in the correct order); if necessary, the data will be retransmit-
ted. The standard software for the Android I/O board uses TCP.
For the Android I/O board we therefore use the TCP server
USR-TCP232-T Android IO board mode for the USR-TCP232-T module.
The USR-TCP232-T module doesnt support DHCP. With DHCP,
CFG MOD4
RXD TXD GND the router allocates IP addresses to the devices on the IP net-
TXD
RST CFG
work, such as PCs or mobile phones. With the USR-TCP232-T
VCC
GND RXD module we can only set up a fixed (static) IP address. This
VCC
VDD address should be within the IP range of the (private) network
that the module is connected to.
If we want to connect a USR-TCP232-T module to the Android
Figure 1. The wiring diagram for the two connectors on the cable linking I/O board, we must first take care of two things. First of all,
the USR-TCP232-T module to the Android I/O board. we need to make a connection cable to connect the module
Object 1 Android
The choice of object determines which Android I/O board will Object 2 IO board 2
be used for the initializing of the Android I/O board, making a Object 3
Object 4
connection or the transmission of data. For example: Android
IO board 3
IOBoard[2].initiate(2, hnd, 192.168.178.120, 23, 1, Handler
this); Android
IO board 4
0.
PRICE HIT
50
VT-7126
( 0,58)
LED BULB, GU 10
Foto: Foto- und Bilderwerk
LIGHTS
AN D S AV E !
R E P L A C E NOW
LED BULB, E 27
These LED bulbs can be used to replace
nearly every energy-saving bulb and
LED STRIP conventional light bulb in an E27 socket.
Output: 18 watts Soyou can start saving energy right away.
Angle of radiation: 120
Length: 5m Width: 8mm Output: 10 watts
3.
Light colour: warm white
90
CRI (Ra): 80
Life: 20,000 h
VT-2016 3.90 ( 4,50) warm white CRI (Ra): 80
each
VT-2041 3.90 ( 4,50) neutral white
VT-2005 3.90 ( 4,50) cold white
6,
1.
99
23
LED STRIP VT-4209
aab
b
Output: 18 watts
Angle of radiation: 120
Length: 5m Width: 8mm
3.
( 1,42)
Flexible, easy installation
90
VT-2015 3.90 ( 4,50) red LOGY
GHT TECHNO
VT-2011 3.90 ( 4,50) green MORE LED LI
from
VT-2013 3.90 ( 4,50) blue The articles in this ad and many others
VT-2124 5.79 ( 6,68) RGB areavailable in our online shop:
http://rch.lt/zW
Daily prices! Price as of: 31. 1. 2017 Prices in plus statutory VAT, plus shipping costs reichelt elektronik, Elektronikring 1, 26452 Sande (Germany) Onlineshop languages:
www.reichelt.co.uk
PAYMENT METHODS:
The principle of operation of the described previously in Elektor for use interesting application of the SDR
theremin is straightforward and is at shortwave frequencies [1]. Here we shield.
based on the mixing of two RF signals use the shield as a direct-conversion The FET oscillator circuit shown
to produce a beat frequency. One RF mixer and we connect its output to an in Figure 2 operates at 420 kHz;
oscillator, called the pitch oscillator, active loudspeaker, thus replacing the moving your hand near to it will pull its
has its frequency tuned by variations second oscillator and the mixer in the frequency by up to 5 kHz. The antenna
in the capacitance to the thereminists original theremin. It is easy to set the for the SDR is a length of wire simply
hand thus adjusting the pitch of the frequency of the beat oscillator very placed close to the oscillator. The
note being played, while the other precisely (see Figure 1) and all we signal is so strong that only a weak
operates at a fixed frequency. The need now is the pitch oscillator. That coupling is required to the receiver.
outputs of the two oscillators are taken will give use our first simple theremin, Instead of connecting a PC to the
to a demodulator which works on the albeit without a volume control: an stereo output, we wire it directly to an
same principle as an AM radio. Overall
the circuit is very similar to a receiver
for unmodulated Morse signals. For Pitch
simplicity, then, our first experiment
will use a ready-made radio receiver.
27p
150p 1n GND
Arduino Uno running the standalone
VFO software, along with an LCD
panel on an Elektor extension shield.
An arrangement like this has been Figure 1. The receiver tuned to 421.3 kHz. Figure 2. A simple pitch oscillator.
50p 27p
2M2
100k
10mH 100u
16V
1k 4V
10mH 27p 60p
100uA
2M2
4mH7 27p 10n GND
Figure 3. A grid dip meter using a triode. Figure 4. Modified FET dip meter.
active loudspeaker. The shield operates whip antenna, gives a measured energy from the oscillator circuit,
as a simple direct-conversion mixer resonant frequency of 600 kHz. This reducing the amplitude of oscillation,
without the need for any SDR software. is not too far from the operating which can be measured as a change in
The standalone software for the SDR frequency of 420 kHz, which means grid current. At the point of resonance
shield and the extension shield allows that the capacitance of the hand the current dips, that is, falls to a
the tuning to be adjusted easily and has a noticeable effect. The result is very low value.
precisely. First it is necessary to use that the sensitivity of the circuit to In the theremin the negative grid
the buttons on the extension shield to the capacitance of the hand is very voltage of the oscillator is used to
locate the frequency of the oscillator good, with a useful working range of control the gain of a variable-mu tube
and find the point where the beat up to 30 cm. Because the oscillator in the audio signal path. This avoids
frequency is zero. If you now move frequency is low, stability is entirely potential problems of instability, as
your hand close to the pitch oscillator adequate, and with a weak coupling the dip frequency and the audio range
its frequency will go down and the beat to the SDR shield a pleasant sound is lie far from the frequency of the beat
frequency will rise. And now it is just a produced. frequency oscillators. In a tube-based
question of a little practice, and youll circuit the amplitude of oscillations can
be able to play your first tune. Testing the volume antenna be more than 10 V, and with a high
The connection to the antenna includes This simple theremin oscillator still has value (around 1 M) grid leak resistor
a 4.7-mH loading coil to increase its a shortcoming: there is no way to alter the grid voltage might be around
effective electrical length. The result the volume of its output. The original 10 V. If a second resonant circuit
of this is to ensure that the very small design had two antennas rather than is weakly coupled in, then the grid
extra capacitance introduced by the one, and the second antenna was voltage might dip to 1 V: this would
proximity of the hand, around one operated by the players left hand. correspond to maximum volume. If
picofarad, can cause a sufficiently As the hand approached the antenna the resonant circuit is now detuned
large change in frequency. A 1-mH the sound became quieter or even or damped, the negative grid voltage
inductor would require a capacitance of completely silent, making for a truly will rise significantly, and at 10 V the
143 pF for resonance at 420 kHz. With playable instrument. audio path will be completely blocked.
144 pF of capacitance, the resonant The first idea that might come to mind Our first attempt at a FET-based
frequency is 1.5 kHz lower. The load is to pass one of the two oscillator grid dip meter uses relatively large
inductor considerably increases the outputs through a resonant circuit inductances (see Figure 4). The circuit
size of this effect: you can visualize whose frequency is pulled by the does indeed oscillate with a large
it as being equivalent to having a volume antenna. Unfortunately, that amplitude, and the output voltage is
much longer antenna in the proximity will have the undesirable consequence 4 V. The resonance dip effect does
of a much larger hand. The trick of of also pulling the pitch oscillator, occur, but it is too weak: the voltage
using a loading coil was employed in resulting in an interdependency only changes by about 0.5 V. There
the original theremin design and in between pitch and volume. is also a coupling effect, which also
variations on it ever since. A glance at older theremin circuits occurs with regular dip meters: the
Putting it slightly more scientifically, reveals an alternative approach, i.e. amplitude changes suddenly on one
a series resonant circuit has a low using a third oscillator that operates edge of the dip.
react ance near to it s resonant in similar fashion to a grid dip meter.
frequency, which below this frequency A grid dip meter (Figure 3) is used Tesla coupling
corresponds to a large capacitance. to determine the resonant frequency Looking at older theremin circuits,
The coil we have chosen here, of a circuit. A resonant circuit in the we can see that they also contain a
in conjunction with an ordinary proximity of an oscillator coil draws kind of loading coil in the antenna
4mH7 4mH7
330k
1mH 100u
16V
3k3 0 V5 . . . 2V
0mH33
2M2
60p 10n GND
Figure 5. Oscillator with an antenna coil. Figure 6. Prototype construction of the volume oscillator.
connection. On closer inspection this The resonant frequency is easy to set, away. Calculation shows that this tiny
turns out to be a Tesla transformer: there is no longer any coupling effect change, just one picofarad, gives rise
the coil has a self-resonance at the and the control voltage range is large to a frequency change of 2 kHz, and
operating frequency and has a very enough. For experimental purposes only a small space near to the antenna
large inductance to capacitance this oscillator can be constructed on is available to the player. The effect of
ratio. It is also strongly coupled to a breadboard (Figure 6). A loop of the 4.7-mH loading coil is to increase
the oscillator, and in this case the cable terminated in crocodile clips can significantly the change in capacitance
oscillator (Figure 5) is tuned by the be used as an antenna. seen at the lower end of the coil.
Tesla coil, whose resonant frequency The dip oscillator also now uses a
will be pulled significantly even with Simplified oscillator circuit 1-mH inductor. The self-resonance of
tiny changes in capacitance. The modified oscillator circuit shown the loading coil for the volume antenna
When the circuit is in resonance the in Figure 7 avoids the need for a was found to be at 600 kHz, and so the
RF voltage on the antenna will be tapped inductor in the resonant circuit. free-running oscillator must adjusted
multiplied significantly. The secondary Instead, the resonant circuit works to approximately this frequency, which
circuit draws a considerable amount using a capacitive voltage divider. By requires a total capacitance of 70 pF.
of energy from the oscillator, which changing the ratios of the values of the At 600 kHz the antenna circuit draws
reduces its amplitude. The grid dip individual capacitors it is possible to so much energy from the oscillator that
effect comes into play at voltages of up adjust the impedances at the gate and the control voltage plunges to 2.5 V.
to 0.5 V, but with greater detuning or the drain of the FET. In the example If the antenna circuit is detuned by
damping, for example if the antenna is shown the oscillator runs at around bringing a hand near to it the oscillator
touched directly, this effect disappears 1 MHz, which is also where the self- amplitude increases significantly, the
and the grid voltage falls by up to 2 V. resonances of the two loading coils control voltage reaching 3.5 V.
lie. As in the previous experiment the The 4.7 mH antenna coil requires
amplitude of the oscillator increases a total capacitance of 26 pF for
when the upper circuit is detuned or resonance at 600 kHz. The majority
damped. The gate voltage then falls of this capacitance comes from the
to 2 V. windings of the coil itself, only a
1mH small part being due to the antenna.
The complete theremin Changing the capacitance by one
a p p ro x . 1 M H z
The complete circuit (Figure 8) picofarad by bringing a hand near to
1mH
includes the second oscillator, the the antenna detunes the resonant
0mH33 +12V mixer and a circuit for the volume frequency by 12 kHz, which is enough
3k3
BF256B
antenna. The second oscillator is to generate the required dip.
27p stabilized at 470 kHz by a ceramic The final element is the variable-gain
150p resonator, and so it must be possible amplifier. Its gain is controlled by its
to set the adjustable oscillator to this gate voltage: at 3.5 V the FET is fully
330k
0V5 ... 2V frequency. A trimmer capacitor is off and there is no output signal, and
provided for tuning. with 2.5 V at the gate the circuit
60p
The free-running oscillators now use already has a considerable gain. In this
1k5
2M2
2k2
3k3
3k3
56p
filter to minimize the amount of 100n 100n
5x BF256B
residual RF at the output. 1mH
The circuit can be constructed on the 1mH
ZTB470E
copper side of an uncoated printed
33p
circuit board (Figure 9). This has
150p 1n
the advantage of providing a good
150p
ground connection and decoupling 150p
the individual stages. Wherever a
ground is needed, the shortest possible
100k
1k5
100k
10k
1k
1k
1M
500p 300p 27p
path can be used. This construction
method, used along with small pieces 470kHz VFO Buffer 470kHz BFO Mixer
10k
27p
4mH7 100n Audio
is that JFET-based oscillators are very 150p 2x BF256B
stable in frequency, and insensitive to 330k
variations in supply voltage.
22u
In all these experiments the circuit was
earthed, as it was powered from an 16V 100u
1k
2M2
10k
earthed bench supply. However, when 60p 56p 100n 1n 22n 16V
Web Link
[1] www.elektormagazine.com/160165 Figure 9. All the stages on one circuit board.
Figure 10. Close-up of the volume oscillator. Figure 11. The instrument in its enclosure.
AVR Playground
Improves
the way
to do
Arduino
By Clemens Valens (Elektor Labs)
Before the rise of Arduino, microcont- The board can roughly be divided Extension connectors
roller development boards had on-board into four horizontal zones (Figure 1), The top-left corner of the board accom-
peripherals like pushbuttons and LEDs, a with, from top to bottom, the following modates the microcontroller and Arduino
display, one or more potentiometers for functions: Uno compatible extension connectors.
analog signals, extension connectors, etc. This part of the board behaves exactly
and, of course, a decent power supply. 1. extension connectors, USB-to-serial like an Arduino Uno.
The goal of these boards was to provide converter and power supply;
an easy way to start learning the micro- 2. user interface peripherals like a buz- Next to it sits a mikroBus expansion slot.
controller without having to solder or add zer, rotary controls and a display; This extension standard, developed by
other components. The AVR Playground 3. configuration switches; the Serbian company MikroElektronika,
a playful reference to the Arduino forum 4. pushbuttons and LEDs. is gaining popularity thanks to the avai-
known as the Arduino Playground was lability of hundreds of cheap extension
designed with this in mind, and extended If you want to see the schematics, the boards, ranging from GPS receivers to
with things from Arduino that we have PCB or the component list of the AVR humidity sensors and from LED arrays
learned to appreciate. Playground, please refer to [1]. right up to phone modems. Together, the
entry level
intermediate level
expert level
4 hours approx.
SMD Soldering
75 / $80 / 65 approx.
things are much more comfortable and LCD the frequently seen 4-bit semi-parallel
reliable when using a tool like the AVR The display, a small LC one with back- or 8-bit parallel interface. The evident
Playground. light, has an IC interface instead of advantage is that it only requires two
wires for connecting it to the MCU. The
inconvenience is the need for a special
Table 1. The functions of DIP switch S15. driver, but we took due care of that in
S15 Function Off On the Boards Package (see below).
1 Buzzer Disconnected Connected to PB1
2 LEDs Port B Disconnected Connected to GND Rotary controls
3 LEDs Port C Disconnected Connected to GND Two potentiometers provide analog sig-
4 LEDs Port D Disconnected Connected to GND
nals to the microcontroller. By positio-
5 USB-to-serial RXD Disconnected Connected to PD1
ning a jumper, they can be connected to
6 USB-to-serial TXD Disconnected Connected to PD0
any of the six analog inputs of the MCU
7 USB-to-serial DTR Disconnected Connected to Reset
without the risk of both being connec-
ted to the same input at the same time.
Table 2. The functions of 7-way DIP switch S25.
The rotary encoder is in reality the same
S25 Function Off On
thing as (up to) three pushbuttons hence
1 MCU voltage 5V 3.3 V
its effectively connected in parallel to
2 Arduino LED Disconnected Connected to PB5
3 LCD SDA Disconnected Connected to PC4 the pushbuttons on PD3, PD4 and PD5.
4 LCD SCL Disconnected Connected to PC5
5 Not used Arduino LED
6 LCD Backlight On (if S25-7 in On position) Connected to PD7 The LED connected to PB5 (Pin 13) on
7 LCD Backlight Off Controllable the Arduino Uno is available on the AVR
Playground too; it is located below the
Table 3. The functions of DIP switch S24. rotary encoder. This LED is used in many
S24 Port Down Middle Up sketches, reason why it is present on
1 PB0 Pulled down Not pulled Pulled up this board.
2 PB1 Pulled down Not pulled Pulled up
3 PB2 Pulled down Not pulled Pulled up Clock frequency & reset issues
4 PB3 Pulled down Not pulled Pulled up The preferred clock oscillator for the AVR
5 PB4 Pulled down Not pulled Pulled up Playground is the MCUs internal 8-MHz
6 PB5 Pulled down Not pulled Pulled up RC oscillator. This ensures that the MCU
7 PB6 Pulled down Not pulled Pulled up will always work within its specifications,
8 PB7 Pulled down Not pulled Pulled up no matter if the MCU voltage is 5 V or
Port mapping
Figure 5. After installing the Boards Package, scroll through the Boards list and select the AVR The first step is to decide which ports will
Playground. be used for what function (Table 6). This
also greatly determines the setting of the
configuration DIP switches (see Tables 7
(one line, no spaces, beware of typing them to right location. When done, close to 11). The settings chosen will switch
errors) into the Additional Boards Mana- the window. Now the AVR Playground the LCDs backlight on, and, because the
ger URLs box of the Preferences dialo- will be listed somewhere in the Boards level of the pushbuttons on port D is
gue. Close it when done. menu, under the header Elektor Labs set to logic high, an LED will automati-
(Figure 5). Of course you should connect cally light when the corresponding but-
Open the Boards Manager (Tools the AVR Playground to your computer ton is pressed. To make this free visual
Boards). In the upper left corner of the before you can select its Port. feedback work properly, the pull-down
window that opens select Contributed, resistors on these pushbuttons need to
look for the AVR Playground in the list Enter game programming be activated.
that appears, click on it and then click We developed a fun application using
the Install button (Figure 4). The IDE many of the boards options, its a sim- Controlling the LEDs
will download the required files and copy ple game called Simon Says inspired by a is slightly more complicated than usual
because the pushbuttons are connected
to the same pins. Also, to improve flexibi-
Table 6. The ports, their pins and their functions in the game. lity, a lookup table is added allowing the
Ten GPIO pins remain unused, showing that a microcontroller with fewer
use of other LEDs simply by modifying
pins might suffice, making the final design cheaper.
the table. (Listing 1)
Port B Function Port C Function Port D Function
PB0 Not used PC0 Not used PD0 RXD
PB1 Buzzer PC1 Not used PD1 TXD
Reading the pushbuttons
PB2 Not used PC2 Not used PD2 LED0 ... is based on the same technique as
PB3 Not used PC3 Not used PD3 LED1 lighting the LEDs, except for an input now
PB4 Not used PC4 LCD SDA PD4 LED2 being read instead of an output being
PB5 Not used PC5 LCD SCL PD5 LED3 driven. Due to the way the DIP switches
PB6 Not used PD6 LED4 are set, a pressed button will produce a
PB7 Not used PD7 LED5 logic high.
Table 9. S24 controls Port B, Table 10. S33 controls Port C and the pushbuttons
its not used in our game. active levels.
S24 Port Position S33 Function Position
1 PB0 Middle 1 Port B pushbutton level Middle
2 PB1 Middle 2 Port C pushbutton level Middle
3 PB2 Middle 3 Port D pushbutton level High
4 PB3 Middle 4 PC0 Middle
5 PB4 Middle 5 PC1 Middle
6 PB5 Middle 6 PC2 Middle
7 PB6 Middle 7 PC3 Middle
8 PB7 Middle 8 PC4 Middle
9 PC5 Middle
Table 11. S27 controls Port D. 10 Not used
S27 Port Position
1 PD0 Middle
2 PD1 Middle
3 PD2 Down
4 PD3 Down
5 PD4 Down
6 PD5 Down
7 PD6 Down
8 PD7 Down
A problem with pushbuttons is that they up. The table can be filled at the start RAND_MAX (which corresponds to 32,767
are mechanical devices in essence, exhi- of a game. in Arduino). A quick and dirty way to
biting milliseconds or more of time lag for The function rand is available for pro- bring the output in the wanted range
the contact to settle, hence it is neces- ducing random values in the range 0 to is by doing a modulo division (%).
sary to debounce the buttons. An easy
way to do this when there are no par-
ticular (timing) constraints as in our Listing 1.
simple game, is to scan the buttons a
#define LED_BUTTON_TABLE_SIZE (4)
second time after having waited a short
uint8_t led_button_table[LED_BUTTON_TABLE_SIZE] = { 4, 5, 6, 7 };
while. Only if a button is read twice as
being pressed, the program decides its
a valid button press. By scanning periodi- void led_set(uint8_t nr, uint8_t value)
cally at a high enough rate (10 Hz or so) {
the chances of missing a key press are pinMode(led_button_table[nr],OUTPUT);
minimal. A logic AND (&) of two scan digitalWrite(led_button_table[nr],value);
results will remove inconsistent reads. }
(Listing 2)
Random numbers
Listing 2.
The game needs a sequence of random
numbers (corresponding to the LED num- uint8_t button_read_all_debounced(void)
bers) thats long enough to make most {
players fail before reaching the end. The uint8_t buttons = button_read_all();
sequence can be stored in a table. The delay(10); // Wait for any bouncing to stop.
size of the table is important. If it is too buttons &= button_read_all(); // AND the second scan.
small, it is too easy for the player to
return buttons;
outplay the computer; if it is too large,
}
the player gets discouraged and will give
Listing 3.
129009-91: }
Ready assembled module }
Even though the LabNation SmartScope is mainly known as a full-featured oscilloscope, its rear port allows
you to hook up eight probes to measure digital signals. This article explains how to use the SmartScope as a
logic analyzer to validate your digital circuits, and to automate the decoding of digital protocols for you.
Most of todays circuits have a digital section; its either a in your communication streams.
purely digital circuit, or the digital core is used to control an And finally, logic analyzers are also used to monitor serial
analog circuit or capture its outputs. When a digital circuit isnt communication for passing messages between chips. Decoders
performing as it should, you want to see at which moments help you to convert those streams of transitions into meaningful
your digital lines are High and when theyre Low; you want to commands and values.
see at which moments exactly they change state.
Key specifications
The most basic usage of a logic analyzer is to study an event When looking at the SmartScope acting as a logic analyzer,
and its effect: attach one wire to the signal you want to monitor there are quite a few specifications to be aware of.
and a second wire to a trigger. Each time the trigger occurs,
the logic analyzer captures the behavior of both signals over a Number of inputs: even though two inputs would be
certain timespan, allowing you to analyze this at your own pace. the bare minimum (to wait for a trigger and watch its
For most cases, digital communication is all about multiple lines effect on a signal), more is better in this case, as it allows
which need to respect a certain mutual timing. The SmartScope you to combine the bits of multiple inputs into numbers.
offers eight digital inputs and includes quite some functionality Sometimes youll want to trigger on a number instead of
to measure the exact time between various pulse transitions a single signal. The SmartScope has eight digital inputs
e Third Kind
Open counter of th In December 2016 a rather surprising event took place in Berlin.
It was neither artistic nor sports- nor food-related although
beverages and pizza were being served during the event but
the opening of a store. And not just a store, but the worlds
first Arduino Store. As far as I know, and where I have lived,
electronics shops of the window & cash register type only go
out of business, and they have been doing so for some 35 years
now. Virtual electronics shops are flourishing, popping up all
over the Internet, but opening an electronics store with a
counter and paying someone to stand behind it is, well, nothing
short of a new or should I say revolutionary? concept. In
the new Arduino Store you can buy Arduino products (duh), but
not just that, as it doubles as a maker space where workshops
are being organized. Is this the beginning of a new trend? Will electronics
Maker Store Berlin, shops soon flower on every street corner like in the old days? Or will this store go down the
Berlin
Danziger Str. 22, 10435
same road as its predecessors?
o n d u ct o r ju n g le : eat or be eaten
Semic If you are
an electronics industry watcher or a mere
newspaper reader, you will have noticed the wave of mergers and takeovers
that have been going on over these past few years. Intel acquired FPGA
manufacturer Altera. NXP took over Freescale only to be reeled in itself a
few months later by Qualcomm. Microchip gobbled up its competitor Atmel;
ON Semiconductor bought Fairchild Semiconductor, and Analog Devices ate
Linear Technology. Component distributor Avnet took over colleague Farnell
who just had sold Cadsoft (Eagle) to Autodesk (AutoCAD); Mentor Graphics
merged with Siemens, and, right after the Brexit, ARM was bought by the
Japanese Softbank. Did you know that Amazon has entered this dance too?
They own Annapurna Labs from Israel. These are only the high-profile mergers
and acquisitions worth several hundreds of millions up to tens of billions of Big fish eat Little Fish,
eswenson.com
euros/dollars/pounds, but many smaller takeovers have taken place too. courtesy of www.catherin
Small companies merge to form larger entities, but when they become too big they start
an attempt to lose weight. NXP was split off from Philips, Freescale used to be part of Motorola; HP decided to cut itself in two,
and at the end of 2016 Samsung announced a possible split too. It is like watching stars and planets colliding and breaking apart
again. Is there a black hole hidden somewhere in this universe trying to suck up the whole industry?
B row n 1 1 x 1 0 1
1 % ( F ) 1 0 0 ppm RS-279?
R ed 2 2 x 1 0 2
2 % ( G ) 5 0 ppm
Most Elektor readers know RS-232, many know RS-485, some know
O range 3 3 x 1 0 3
1 5 ppm
RS-422, but who knows RS-279? You! This may come as a surprise,
Y ellow 4 4 x 1 0 4
2 5 ppm
G reen 5 5 x 1 0 5
0 .5 % ( D) but, since 1963, RS-279 is the official EIA standard for the resistor
B lue 6 6 x 1 0 6
0 .2 5 % ( C) color coding that you unwittingly memorized over the years. Devised
V iolet 7 7 x 1 0 7
0 .1 % ( B ) almost a century ago it became an IEC standard in 1952 that also
G ray 8 8 x 1 0 8
0 .0 5 % ( A) covers capacitors. SMD parts dont use color coding, but letter and
W hite 9 9 x 1 0 9
digit coding. The current international standard defining marking
G old x 1 0 1
5 % ( J )
codes for resistors and capacitors is IEC 60062:2016.
S ilver x 1 0 2
1 0 % ( K )
N one 2 0 % ( M )
hine?
p ri n te r ye t an other useless mac
The PCB Did you know that electronics would
not be where it is today without a
technique developed some 500,000
years ago? I dont mean the invention
of silicon which dates back even
further, a few billion years or so, but
engraving, the practice of incising
a design onto a hard, usually flat
surface by cutting grooves into it.
(Thank you, Wikipedia.) Printed
dw idth of 38 GH z circuit boards, or PCBs, can be made
with a ban
These tiny transistors
printer & assembler on a flex ible sub stra te using various engraving
The Voltera desktop PCB were engraved and pri
nte d
combines design and fun
ctionality.
oto cou rte sy of Jun g-Hun Seo).
(ph
Want to participate? Please send your comments, suggestions, tips and tricks to labs@elektor.com
Red Pitaya has become a familiar name line. First of all, sion it is 10 bits instead of 14 bits. The
in the electronics world. This credit-card the name has been changed to STEM- STEMlab 125-10 also has less RAM than
sized red board is a powerful instrumen- lab (STEM is an acronym of science, the -14 version, but for many applica-
tation platform with a built-in signal gen- technology, engineering and mathe- tions that is not important.
erator as well as a versatile FPGA devel- matics and is often used in the educa-
opment system for your own applications. tional sector to designate the scientific Fewer bits
We have already published several articles and engineering disciplines). The original I spent some time playing with a proto-
in Elektor about applications for the Red Red Pitaya has been renamed STEMlab type of the STEMlab 125-10 as well as
Pitaya, along with a separate book [1]. 125-14. It also has a little brother now: a series production board, and I hardly
the STEMlab 125-10. They differ in the noticed that it is a junior version of the
Now the engineers at Red Pitaya have resolution of the A/D and D/A convert- Red Pitaya. Thats because both versions
updated and expanded their product ers on the board. With the junior ver- work with the same apps and the mea-
Figure 1. The documentation on the Red Pitaya website. Figure 2. The updated user interface with the various app icon tiles.
Figure 3. The oscilloscope app included with the board is the same as the Figure 4. The Diagnostic Kit puts a very complete measuring station on
previous Pro version. your bench.
Truly Random-Number
Generator
Meets NIST standard with
cheap components
IC4
+3V3_SD
R1 L78L33 +3V3
3 1
+6V +3V3 K1
10k
K6 SD Card Socket
1 CD 1 +6V C13 2 C14 C12
2 R3 R5 DO 2
D1
L1 100n 100n 100u
3 PD6 3
Random Bit Stream
10k
1M
4 PD1 4 100uH
Bit Capture Trigger
5 SCL 5 C10 C11
+3V3_SD
1N4148 6 IC5
+3V3 100u 100u
DI 7 L78L33
20 3 1
R2 8
K5 VCC C1
2 1 DO RST 1 9
470k
PA2(RESET/DW)
4 3 SCL AIN0 12 IC1 C15 2 C16 C17 C18 C19
PB0(AIN0/PCINT0) 100n
6 5 RST AIN1 13 2
SW1
SW2
SW3
PB1(AIN1/PCINT1) PD0(RXD)
100n 100n 100u 100u 100u
PB2 14 3 PD1
ICSP PB2(OC0A/PCINT2) PD1(TXD)
15 6
PB3(OC1A/PCINT3) PD2(CKOUT/XCK/INT)
CD 16 7
PB4(OC1B/PCINT4) PD3(INT1) K4 R10 K3
DI DI 17 8 1 PD6 PD5 1
PB5(MOSI/DI/SDA/PCINT5) PD4(T0) 10k
DO 18 9 PD5 R9
PB6(MISO/DO/PCINT6) PD5(OC0B/T1) PWM
D2 SCL 19 11 PD6 R6 R7 R8
10k
PB7(UCSK/SCL/PCINT7) PD6(ICP)
S4 C6
470R
470R
470R
ATTINY2313A-SUR +3V3
D3 5 4 CD
PA1(XTAL2) PA0(XTAL1) GND
4
10u R4
6 3 DI
4 X1 5 10 C5
3
20M
R45
2
8 1 SCL
100n
ON
C2 C3 C4
1
100k
D5
10MHz
R46
100n 22p 22p AIN1
4x 100k
P5
1N4148
R44 200k
S1 AIN0
100k
R47
+18V +18V C35
PD1
PB2
330k
BC847 +14V
T1 T3 100n
R16 R20
LED4
R15
BC857
10k
10k
R11
1k5
10k NJM7806DL1A-TE1 2 IC3 R49
K2 R12 R14
IC2 +6V
1 1 3 1 R18 R21 10k
100k
10k
S7
R17
100k
4k7
2 1 6
ON
TL431AMFDT 3
1
1k5
T2 2 R50 2 5
IC6 3 2 4
10k
TL431AMFDT 2 R22
3
R13 P1 P2
BC847
100k
C7 S2 C8 C9 1
1M
R19 S3 R23
BAT854W
15k
33k
+6V L2
10k
1k
1k
100u L3 C36
+3V3 C30
T4 T5 100uH
220p
2x 100n
BC847
R38 R41
+14V P3 +14V
200R
100R
1k
C37
L4 R48
R30 R26 R36 100p C44
C23 C21 C22
S5 C38
10k
470R
470R
R39 R42
10k
10k
1k5
T6 9 6 C39
R31 C24 C27 R35
6
11 4 C40 C45
10n 10n
4
P4 13 2 C41 C46 6 5
D8
2
D7
1
1n 120p 9 2
100k
1
220R
2k2
1N4148 1u C31
470p
150116 - 1 - 11
Figure 1. The Random Number Generator or RNG cleverly combines analog and digital electronics to produce a truly random bit stream.
COMPONENT LIST
RNG
VDD
VSS
R/W
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
VO
RS
GND
A
C
E
Transistors T1 and T2 along with out- 100u
16V
100n
3
10u
25V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
22k
1k
L1
switches the circuit on, making the MCU R3 C3 10uH C5
22k
22k
PB4(MISO) PC2(ADC2)
F8 17 26 8F
PB5(SCK) PC3(ADC3) D1
soft-stop button used to stop the record- PC4(ADC4/SDA)
27
20 28
ing at any time while keeping the data. AREF PC5(ADC5/SCL) D2
PB6 PB7
S2 is a hard-stop button which turns GND (XTAL1) (XTAL2) GND GND
R5 R7
3 7 8 5 21 C23
off the power immediately. Pressing it X1 JP1
10k
10k
C4
10k
10k
Trimpot P1
Adjust to obtain 14 V at the emitter of
T3.
Trimpot P2
Determines the voltage that triggers the
low battery warning (LED4 turns off).
If the RNG is powered by two 9-V NiMh
batteries, the warning should trigger at
15.4 V (because such batteries contain
seven 1.2-V NiMh cells, and when dis-
charged to 1.1 V per cell this totals to
15.4 V). Connect an adjustable power
supply on K2; vary its voltage between
15 V and 16 V. Adjust P2 to make LED4
turn off when the voltage at connector
K2 drops to 15.4 V.
Trimpot P5
1. Turn off the power (press S2, hard
stop);
2. Hold S3 (soft stop), then press S1
(start) to enter Test Mode. LED3 turns
on;
3. Connect an oscilloscope (or a DC volt-
meter) to PD5 to monitor the PWM sig-
nal that compensates DC drift. Adjust
P5 to make the PWM signal stabilize
at around 50%;
4. The Test Mode runs for about 40 sec-
onds, then the PWM value is written
to the internal EEPROM of the MCU
and LED1 is turned on. Restart the
test mode if you need more time. If
the PWM saturates at 0 or 100% LED2
turns on and the PWM value is not
Figure 3. The simulated transfer function of the filter built around T7 (black curve). The blue curve
written into the EEPROM. If this hap- is the transfer function of T7, defined by its bandwidth. The lower cutoff frequency is controlled
pens, restart Test Mode. by S5 and its capacitors C36 to C43. The red curve is the transfer function of the corrective filter
L4-R48-CS6-RS7. For clarity, transistor amplification was left out, the real black and blue curves lie
S5, S6 and S7 about 30 dB higher.
Figure 3 shows the transfer function of
the circuitry around T7. S5 together with
its capacitors control the lower cut-off
frequency. Use S6 to adjust the filters
resonant frequency as in:
Auto-trimming
The last PWM value is always kept in
internal EEPROM. In normal random data
recording mode, the PWM duty cycle is
adjusted constantly. At the end of a
recording (at completion or a soft stop Figure 4. This histogram of the data generated by the RNG reveals a poorly tuned corrective filter.
Looking only at the leftmost and rightmost bars (occurrences of respectively 0x00 and 0xFF) the
due to a low-battery condition) the cur-
zero-to-one ratio seems fine, however, because the corrective filter is not tuned properly, the
rent PWM duty-cycle value is written to
occurrences of 0x0F and 0xF0 are almost three times higher than those of 0x55 and 0xAA.
EEPROM to be used the next time the
RNG is powered on. It is therefore rec-
ommended to first record one small 16
MB file (and discard it) prior to record-
ing a file of the desired size so that the
PWM signal can be adjusted by the MCU.
When done, set the desired size with DIP
switch S4 and restart the RNG immedi-
ately. The random data will now have
the highest quality because the DC off-
set will be properly adjusted from the Figure 5. After proper tuning of the corrective filter the histogram is almost flat. Now you have
very beginning. premium-quality random data.
Advertisement
DLP-IO8-G DLP-IOR4
8-Channel Data Acquisition 4-Channel Relay Cable
DLP-TH1b
Temp/Humidity Cable
Only
$29.95! DLP-RFID1
HF RFID Reader/Writer
DLP-FPGA
8 I/Os: Digital I/O USB-to-Xilinx FPGA Module
Analog In
Temperature
USB Port Powered
Single-Byte Commands
www.dlpdesign.com
Web Links
The sample code and a video showing it in action can be found
at [1]. [1] www.walabot.com/applications/projects/piano
[2] www.walabot.com/applications/projects/pageflipper
Example #2: Page flipper [3] www.youtube.com/channel/UCULlgO9fDk3jFHdVWKAcDjg
Another example of an interface based on hand gestures is
[4] www.walabot.com
flipping pages by swiping your hand in front of the Walabot,
to the left or to the right. In this case, only the history of the [5] http://api.walabot.com
Y coordinate plays role, to determine whether the hand moves [6] www.walabot.com/applications/projects
left or right.
Google has released a new version of Android especially for single-board computers and for measurement
and control applications. Having tested Android on the Raspberry Pi, we can now show you in simple steps
how to get a first Hello World project to work.
By Tam Hanna (Slovakia) With the Redmond brigade now well coincidental Android Things is by and
advanced along the road towards plat- large a normal version of Android, albeit
form independence, convergence is the one that contains some extensions for
Microsofts rapid advance into Raspberry new keyword. Google simply cannot interacting with hardware. Figure 1
Pi territory has certainly caused Google afford to ignore the IoT arena, as other- shows the structure of the operating
some headache. After desktop compu- wise Microsoft could exploit this and open system.
ters, tablets and smartphones, the Inter- a second front on which to attack the
net of Things (IoT) looks like becoming smartphone market. The Things Support Library incorpora-
the next battleground. ted with this consists of two modules.
However, Googles Brillo platform and First up is the Peripheral I/O API, which
language for the Internet of Things at the time of writing provides access
Pay attention to quality! announced about a year ago made little to the following four types of peripheral
If you are ordering memory cards
impact. Maybe the name was the prob- (whether OneWire will be retrofitted is
from China make sure you carry
lem. Whatever the reason, for its second currently unclear):
out detailed quality tests. Many
attempt, Google knew it must go direct
manufacturers offload batches of
for the jugular and named its new pro- GPIO with PWM
inferior quality products that may
duct simply Android Things. I2C
well report the full complement of
SPI
memory to your microcontroller. In
Simple access to hardware UART
actual use, however, your data may
Lets begin with the obvious. Despite all
be lost.
the kerfuffle comparisons with Micro- The second component is the User Driver
softs Windows 10 IOT Core are purely API. Were talking here about a program-
Preconfigured images
At press time Google (doubtless having
learnt from its flop with Brillo) already
offered ready-built Images for the Intel
Edison, NXP Pico and Raspberry Pi 3 plat-
forms. In this first article we shall focus
Figure 1. Android Things is a variant of Android (image credit: Google).
on the (by far most widely selling) Ras-
pberry Pi 3.
The first stage involves downloading
the Image that awaits you at [2] and
then burning it in the normal way onto
a memory card (in this connection dont
miss the text panel Pay attention to
quality). For the steps that follow the
author used an 8 GB capacity card. Using
cards of greater capacity should not be
a problem; on the other hand the Image
size of 4.6 GB means that it will not work
with cards any smaller than this.
tamhan@TAMHAN14:~/Android/Sdk/
Development environment
platform-tools$ ./adb devices
For space reasons, we have to assume
at this point that you already have a
working installation of Android Studio List of devices attached
Figure 3. Using GitHub has always been a
on your development PC. If this is not 10.42.0.44:5555 device
challenge and remains so.
the case, please refer to [4] for help
The verdict
WaveformEmitter myEmitter=new WaveFormEmitter(myGPIO);
The program just created is a classic
new Thread( myEmitter ).start();
example of overkill in the embedded
}
domain: a shrewd programmer could
generate a stable waveform without any
real-time operating system, using just a
few lines of code and an IC.
Made in Belgium
Bilingually, naturally
Over the past few months some friendly advice (gene goesting, Jan?) came in from Belgian readers
saying their national products are not receiving enough coverage in the Retronics section. Amends
are made here with descriptions of a few DIY kits from the erstwhile MBLE company, aimed at affluent
hobbyists in the early 1970s.
By Jan Buiting to dad. These EE kits definitely had the Dutch, German,
addiction factor as they were horri- The full history of the Philips EE series of
bly expensive not only shiny new from electronics educational kits is a complex
Hands up all of you having started out the shop but also as far as replacement one and beyond the scope of this article.
electronics with a Philips EE (Electronic components were concerned (like in my The complexity is mainly owing to Philips
Engineer) kit stored under your bed and case 1 pc. AC187K = 1 weeks allowance) Holland being a company constantly in
used on the kitchen table! Fond memo- so youd tread cautiously. turmoil shifting around whole factories,
ries of the fantastic projects you could departments, and thousands of people.
build from discrete parts (like sirens And mum was happy the howling and
and electronic canaries) and equally the blinking stuff youd build could be made The story is rendered in a nutshell here
extension kits you dreamt of and put to disappear magically into the cardboard mainly to put the MBLE kits I want to
on your Xmas wishlist preferably filed box again after the proud demo. discuss into the right perspective.
BEM004 Low-Frequency
Generator Kit
Low-frequency may be a bit of mis-
nomer, or just modesty, for this tubed
signal generator since it covers 10 Hz
right up to 1 MHz in five ranges. The elec-
tronic design is not spectacular around
the usual complement of Philips Mini-
watt tubes like EF86, ECC88, EL83, and
EL85 not forgetting four small bulbs in
the oscillator. Basically, this is an econ-
Figure 7. The BEM005 oscilloscope. Note again Figure 8. Inside, the BEM005 has plenty of omy version of one of Philips profes-
that this instrument was built from a kit of space. Note the use of printed wiring boards sional lab grade instruments from the
parts. (PWBs) in combination with vacuum tubes, GM56xx series. Figures 4 and 5 show
which as we know is felicitous only if quality the pristine and perfectly built BEM004 I
tube sockets are used in combination with was given. By todays standards the plas-
proper soldering and solid copper traces. tic knobs may have a cheap look and feel
This BEM004 works, though a 50+50 F Trigger 01: Type 1650-A impedance Bridge (1960), Elektor June 2007.
400 V dual electrolytic can capacitor liter-
Trigger 03: Tektronix 564B Storage Oscilloscope (1963), Elektor May 2011.
Figure 12. With a Belgian pinch of salt MBLEs BEM045 multi-instrument can be called an electronics lab in a box. Note though that this was never a kit
for home assembly but an important adjunct in Philips PRACTRONICS course for audio and acoustic engineering.
Q What if I want to use a brushless motor to avoid wear? A The most commonly encountered problem with stepper
motors is losing steps when the stepping rate is too high
or the load is too heavy. When that occurs, the positioning is
A Then you can use the type of motor often used in model
building, which has three connecting leads (Figure 4).
These motors are actually equivalent to brushless AC motors,
no longer accurate. Another frequent issue is resonance at low
stepping rates, which causes audible humming. Whats worse is
that resonance can destroy drive trains. For that reason speed
but with the rotating stator field generated externally. If you reduction with gears, which always have a certain amount of
want to use one of these brushless motors, its a good idea to play, should not be used. Toothed belt drive is a better solution.
buy a ready-made controller. The controller is driven by a pulse
signal with a range of 1 ms (stopped) to 2 ms (full speed). The
frequency of the control pulses can vary, but 50 Hz is almost Q Is there an alternative to stepper motors?
Web Links
Q Can stepper motors be operated with a different sup-
ply voltage, the same as DC motors? https://en.wikipedia.org/wiki/DC_motor
https://en.wikipedia.org/wiki/AC_motor
We know that the young (and the old) pin out is not breadboard compatible.
PROJECT INFORMATION hackers out there dont want to be teth- Initial attempts to locate something cost
ered to a phone all the time, and no effective almost ground this project to
Microcontrollers
doubt there are endless projects you a halt before it even started. It is funny
BBC micro:bit Bluetooth
can do that will require your micro:bit how simple problems can have such a
Prototyping to stand alone. significant impact! Welcome to engineer-
So we set out to design a docking board ing. Fortunately we were able to finally
entry level
(and maybe a series of docking boards) source a low cost edge connector and we
intermediate level to bring many additional features and all celebrated as we could build the dock
expert level functionality to the base micro:bit sys- we really wanted to bring you!
tem. The goal of the first dock was to
provide some more I/O, prototype space, Weve done a lot of development boards
2 hours approximately
and an easy way to break out the full and have our favorite features. The first
micro:bit pin array to a bread board. iteration of the dock board had ALL
of these plus the standard Engenuics
That edge connector daughter board connection so you
SMD Soldering
The first challenge to solve was the could attach infinite other boards. We
edge connector. While it looks kind of made some assumptions about how the
cool and is essentially free to put the micro:bit would work because at that
20 / $25 / 15 contacts on the board, it makes plug- time it wasnt easy to get our hands on
approximately ging the micro:bit into anything practi- one. This board also used our original
cally impossible. Edge connector recep- two-stage connector idea as we hadnt
tacles are not exactly cheap and their found an edge connector yet (Figure 1).
Figure 1. A 3D rendering of our first go at a BBC micro:bit dock. Figure 2. The final iteration of the BBC micro:bit dock looks like this.
P11
P9
P16
R26 R9 R29 R11 R27 R10 R30 R12
M ICR O : B IT 100k
100k
100k
100k
0R
0R
0R
0R
E D G E CO N N E CT O R
BUTTONA BUTTONB BUTTONC BUTTOND
J6
S1 S2 S3 S4
1
P22/GND B U T T O N S
2
GND
3 M ICR O : B IT
GND B R E A D B O A R D B R E A K O U T
4 J3
GND 1 +3V3 +3V3 +3V3
5 J7
GND
6 R3 P3 1
P21/GND P1 TRIM1 R8 R15 R16 P3/LEDCOL1/AN
7 P20 0R P0 2
P20/SDA1 P0/AN
49R9
100R
8 P19 10k P4 3
P19/SCL1 A N A L O G P4/LEDCOL2/AN
P18/3.3V
9 IN PU T IR R17 P5 4
P5/BUTTONA
10 T R A N SCE IV E R 0R P6 5
3.3V P6/LEDCOL9
11 J4 +3V3 D1 Q3 R28 P7 6
3.3V 1 PT91 IR_IN P8 P7/LEDCOL8
12 0R P1 7
3.3V -21B/TR7 P1/AN
3.3V
13 IR PLCC
Q5
R19
* P8 8
P8
14 0R P9 9
P17/3.3V R25 R20 P9/LEDCOL7
15 P16 P2 IR_OUT not mounted P10 10
P16 0R P10/LEDCOL3/AN
0R
16 P15 P11 11
P15/MOSI1 P11/BUTTONB
17 P14 DMG1012UW P12 12
P14/MISO1 P12/RESERVED
18 P13 P2 13
P13/SCK1 P2/AN
19 P13 14
P2/AN +3V3 +5V P13/SCK1
20 P14 15
P2/AN P2 P14/MISO1
21 +3V3 P15 16
P2/AN 1 3 P15/MOSI1
22 C5 P16 17
P2/AN J5 +5V P16
23 P12 18
P12/RESERVED 2 3.3V/5V
24 P11 1u C4 19
P11/BUTTONB R4 U2 VA 7 8 5 3.3V
25 P10 P12
C+ C VDD 20
P10/LEDCOL3/AN 0R 3.3V
26 P9 LCD_RST 1 1u P19 21
P9/LEDCOL7 R31 RST NHD-C02220Biz-FS +3V3 P19/SCL1
27 P8 P19 I2C_SCL 2 6 P20 22
P8 0R SCL (RGB)-FB-3V VOUT P20/SDA1
28 I2C_SDA 3 23
P1/AN R32 SDA LCD 20x2 C6 GND
29 P20 24
P1/AN P1 0R VSS GND
30 25
P1/AN BK GK RK 4 1u GND
31
P1/AN
32 P7 R13 R14 R18
P7/LEDCOL8
33 P6
150R
150R
150R
P6/LEDCOL9
34 P5
P5/BUTTONA R23
35 P4 Q1 BUZZER P0 C7 C8 C9
P4/LEDCOL2/AN 0R
36 R7
P0/AN P15 LCD_BL_BLU R21
37 0R
Q2
3x
P0/AN P0 DMG1012UW
150R
2 R34 R33
150R
D C1 MCP1824 C2
3 3 4 P1
100k
100k
D+ SHDN ADJ Q6 1
4 GND
ID 1u D3 1u J8 R24
5 2 R2 3 P2 P2
100k
GND SERVO 0R 2
2 SERVO
BLU0603 5V
GND
1 DMG1012UW GND
USB-MICRO B SE R V O O U T PU T 16027 4 - 11
COMPONENT LIST
Web Link
Light control: use the analog trim and the buzzer to dial in any tone [1] www.elektormagazine.com/160274
pot and BLE connectivity to dim the you wish. If you have an oscillo-
lights in the room. scope, looking at the PWM signal is
a great way to explain what audio FROM THE STORE
Simple text messenger (with LCD): actually is.
160274-91
though the UI would be a little dif- Ready assembled module
ficult (think dialing-in character by Annoying buzzer 2: set a high fre-
SKU 17773
character), you could send messages quency tone and hide the board in BBC micro:bit
board-to-board or even board-to- your friends desk. Turn it on via BLE
SKU 17589
phone. You could code some stan- or just on a timer and watch them
5V AC/DC 2A Power supply with
dard favorite message and select look for it. Turn it off if they get too micro-USB
them with the buttons. close. or
SKU 18012
Alarm clock (optional LCD): build IR remote control: Use your Battery holder 2x AA with JST
your own fully featured alarm clock micro:bit and dock to learn and pro- connector
gram the main features of your TVs
Annoying buzzer 1: Use the trim pot remote. Or code some simple board-
Advertisement
Extruded enclosures
standard and heatsink
www.hammondmfg.com/1455.htm
www.hammondmfg.com/1455NHD.htm
01256 812812
sales@hammondmfg.eu
PROJECT-INFORMATION automatically. That should not be positive opamp input Vi is always greater
difficult, I thought. And it should also than zero, whereas the capacitor voltage
motor PWM work without using a microcontroller! V c at the negative input is still zero.
Duty cycle You take a PWM generator, use this to Opamp output Vo goes into saturation
control the motor, measure the current at its maximum output voltage (Vomax).
through the motor and feed this back to The output voltage charges capacitor C1
entry level the PWM generator as a control signal. via R1, until Vc becomes greater than Vi.
intermediate level
With a couple of opamps, a MOSFET Well call that state VtH. When this point
expert level for the motor control, some resistors is reached the output flips back to zero,
and capacitors plus a simple, single 5 V whereupon the capacitor is discharged
USB power supply it ought to succeed. via R1 to the point VtL where Vc drops
30 minutes approx. I started out with the classic circuit in below Vi. Now Vo goes high again and the
Figure 1, taken from the datasheet for cycle repeats. The circuit is a combination
the LM358 [1]. (The component numbers of a saw-tooth generator and a Schmitt
Soldering iron have been modified to accord with those Trigger.
Old motor from a in the definitive schematic in Figure 2.) The great thing now is that you can
CD/DVD drive drop these components into a couple of
Theory formulae, with which you can calculate
The basic principle will be familiar to exactly which values you need for a
15 / 12.50 / $16 approx. many readers: VDC is a DC voltage (DC particular cycle. We can also approach
for direct current, not to be confused with this a bit more intuitively. Using any 741-
DC for Duty Cycle [2]). At switch-on the type opamp that you choose, Vomax will
R2 C1
100k the less VDC contributes to Vi, thus the
lower the duty cycle.
100k
100n T1
2
The lower R8 is, the more the conduc-
1
R4 IC1.A tance of V i to ground (GND) and
Vdc 3
100k IRF3708
consequently the lower the duty cycle.
R6 R7
The lower R7 is, the greater the influence
68k 220k Vs
R3 R8 R5 of Vomax on VtH and hence the greater
the difference between VtH and VtL. But
100k
1R8
33k
GREEN Membe
rship
6x Elektor Mag
azine (PDF)
Access to Elekto
Also available:
r Archive
Access to over
1,000 Gerber fi
les
The all-paperless GREEN Membership! 10% Discount
in Elektor Store
Exclusive Offer
s
www.elektor.com/member
Ever since the earliest days of telegraphy, electrical communication has been possible over a single wire.
Today the 1-Wire Bus and similar protocols function using just one conductor, without the need for an
additional clock line. Infrared (IR) remote controls operate on similar principles. In this session we get to
grips with temperature and humidity sensors among other things, and in particular with the IR Transmitter
and Receiver in Elektors 35 Sensors Kit.
We commence with the temperature sensor 18B20 Temp in the power the IC. In the main, however, people use the third (VDD)
kit, which is available from the Elektor Store [1]. The DS18B20 connection of the DS18B20 for supplying power, which then
under discussion may look like a regular transistor in a TO92 adds up to three wires in total. On the sensor PCB there is also
package but its actually a complex IC embracing a tempera- an LED plus its dropper resistor, connected to the data line.
ture sensor and a special interface. The 1-Wire Bus was devel-
oped by the Dallas Semiconductor Corporation. One or more Arduino software for the 18B20
sensors can be handled using a single wire, if you discount the There are two Libraries that we need to load into the Arduino
GND line. As this wire carries only data, it can also be used to IDE: OneWire and DallasTemperature. Both are supplied on
4k7
Y
VDD A2
R
18B20 DQ +5V
G
GND GND
18B20 Temp
Figure 1. 18B20 temperature sensor Figure 2. Temperature output in the serial Figure 3. Temperature curve.
connections. monitor.
the Sensor Kit CD and they have to be copied into the Libraries programming of your own. Of course this takes some time
folder in the Arduino Sketchbook directory. In each case you but it does also open up some interesting opportunities. You
will find a header file *.h and a C++ file *.cpp. Its interesting can then make use of some special features of the sensor, for
to look closer at these files. If you manage to get all the way instance for altering the resolution or for reading out the unique
to the end, leaving nothing at all unread, thats pretty good ID number included in every IC.
going! After that, all you need do is integrate the header files
into your own program and then call up a few functions. Thanks The Bascom sample code (Listing 2) shows how we read out
to Arduino, all this is straightforward. The program in Listing 1 temperatures. Two commands need to be sent, (Skip ROM,
shows how to interrogate and retrieve a temperature pure and &HCC and Convert T, &H44). Following a delay while the mea-
simple, repeated every 500 ms. The data line is connected to surement itself is taken, we send the command Read Scratch-
A2 (= PC2) (Figure 1). All the code mentioned in this article
can of course be downloaded from the Elektor website [4].
Not only does the thermometer have a serial output but it can The 1-Wire protocol
also indicate the temperature on the LCD screen, if you are
With the 1-Wire Bus everything is channeled down the
using the Elektor Extension Shield [2] [5]. And because there
single wire DQ. However, we also have GND and VCC wires.
is space on the second line of the display, we have additionally
In standby mode the data line DQ is taken High with a pull-
programmed a minimum/maximum thermometer.
up resistor. The Master (Controller) can now send a Reset
pulse for initiating communication with Slaves, in order to
The temperature is indicated as a real number to two decimal
then send commands or receive data. Both partners can
places. The actual resolution amounts to 0.06 degrees C per
load data onto the Bus. A 0 Bit is represented by a 15 s
step. The absolute accuracy is given within 0.5 degrees. On
long Low pulse and a subsequent, 45 s long High state. In
the serial monitor (Figure 2) you can read the data. A touch
contrast a 1 Bit is symbolized by a 60 s long Low pulse.
on the sensor will demonstrate a change in temperature.
Between individual Bits there is a resting state, during
The serial plotter indicates changes in temperature over time
which the data line is taken High by the pull-up.
(Figure 3). In the plot shown the sensor was touched (warmed)
The Master always sends a Reset followed by one or more
twice by finger. This shows clearly the differing time constants
commands. A sensor chip then responds with the wanted
for heating and cooling. Also interesting is how the finger was
data. If you study the data sheet for the chips in detail,
visibly warmer on the second touch. Something must have
you will find information there not only on the general Bus
caused the rise in temperature during the intervening time.
protocol but also countless commands and the makeup of
Thanks to the high resolution of the sensor even small varia-
the data structure that is repeated back. Matters become
tions can be detected.
even more complex, because multiple Slaves can be
attached to the same Bus. You can hardly imagine how
18B20 in Bascom
much work it would take to program all of this yourself.
Bascom supports the 1-Wire Bus, although the Bus alone does
Thank goodness you dont have to reinvent the wheel every
not provide a complete solution for using the 18B20. So you
time and can refer to ready-made code almost always.
need to dive a little deeper (into the data sheet) and do some
pad (&HBE) and then read out the two Bytes. From these the pulse from the Master (controlling device) lasting at least 18
software calculates a 16-Bit number and the temperature (in ms. After this a total of 40 Bits are read out, which the Master
steps of .0625 degrees). Thats pretty clever and even better, requests each time by means of an 80 s long Low pulse. The
the program is only slightly longer than the Arduino version. sensor responds with High pulses, in which a period lasting
Once again we have the bonus of a minimum/maximum ther- 28 s maximum stands for a zero and a period of 70 s for
mometer with LCD readout. a one. The 40 Bits then contain one High Byte and one Low
Byte for the humidity and the temperature plus an additional
Temperature and humidity using the DHT11 parity Byte for checking correct transfer of the data. With the
At first glance the combined humidity and temperature sensor DHT11 the Low Bytes are always set to zero, meaning that no
DHT11 looks like a straightforward resistive humidity sensor. post-decimal point figures are transferred. However, there is
This impression is reinforced when you see that an analog Pin also a DHT22 device using the same protocol, which does indeed
is recommended (Figure 4). In reality, however, the insignif- handle the decimal places in addition. Consequently both types
icant-looking exterior conceals a complex sensor with a dig- of sensor can be interrogated using the same software Library.
ital interface. Once again we are fortunate that someone has already taken
the trouble to re-format the complicated protocol into an Arduino
The Chinese company Aosong has come up here with a scheme Library. Using this is quite simple, once you have copied the
that (only at first sight) brings to mind the 1-Wire Bus of Dal- Library directory DHT from the CD into the Arduino Library
las Semiconductor. Each measurement is initiated by a Low folder. The sample code (Listing 3) indicates how the two
R
GND GND GND +5V
IR
NC G
DHT11 +5V VDD GND
D
G A2
10k
VDD
8 (Bascom), 2 (Arduino)
IR
S
9 (Bascom), 3 (Arduino)
IR Emission
Figure 4. Temperature and humidity sensor Figure 5. Measuring ambient humidity by Figure 6. IR receiver and transmitter.
DHT11 connections. finger touch.
measured values are interrogated and can be displayed on the infrared transmit diode is modulated with a frequency
the LCD screen. Once again we select Pin AD2 for connecting between 30 and 40 kHz. This signal is then pulsed (in one of
the data line. a number of methods) so as to transmit individual packets of
On the datasheet the absolute accuracy for temperature mea- data. An integrated infrared receiver detects the signals with
surements is stated modestly as within 2 degrees, that for air a photo diode, amplifies and filters them and demodulates
humidity as within 5 %. Ambient humidity is difficult to judge them back into a digital signal. By design the internal filters
because all run-of-the-mill moisture meters are fairly impre- are dimensioned for specific frequencies in the range 30 to
cise. However, for temperature at least, the results measured 40 kHz, although the bandwidth is sufficient to also receive
on our sample device seemed really good. A digital thermom- off-frequency signals at shorter ranges.
eter that was to hand indicated 23.8 C, the DHT11 showed
24 C, and the DS18B20 read 23.37 C, in each case leaving You can also use an IR zapper for other, more general, remote
enough time for the sensor to settle properly. control or switching tasks. The Sensor Kit includes an IR trans-
mit diode or emitter (IR emission in the diagram) and an inte-
DHT11 and Bascom grated IR Receiver (Figure 6). In conjunction with an Arduino
Many ready-to-use commands and functions exist in Bascom you have the choice of receiving or transmitting IR signals (or
of course but the DHT11 is not supported directly as such. both!). Here we will demonstrate a program that can do both.
Consequently for most topics your most profitable approach Two buttons are used to send commands that are evaluated in
is to search the Net to see if someone else has tackled them the receiver in order to switch an output. The same assignment
already. On this occasion our search delivered positive results is performed both in Bascom and in Arduino-C. Both programs
in the Bascom Forum, where a user by the name of Grtze are sufficiently compatible to the extent that that the Bascom
had written a program called DHT11LCD.bas that does exactly controller can tell the Arduino-programmed Uno what is to be
what we want. The code is easy to read and reflects more or switched and vice versa.
less exactly what is said in the data sheet. Only minor adjust-
ments are needed for using it with the Extension Shield and
enabling the sensor to work using Pin AD2. Beyond this, we
Listing 4. Using the DHT11 in Bascom (excerpt).
also incorporated a serial output, initially only for the humidity
data, as it was intended that these would be mapped out using 'DHT11LCD an AD2, PORTC.2
the serial plotter from the Arduino IDE (Figure 5). ...
The significant activity takes place in the function Get_dht11(). Do
This is where we carry out exactly the same processes that If Get_dht11() = 1 Then
exist in the corresponding Library for the Arduino. In this way
Print Humidity
we can create a complete miniature weather station equally
Locate 1 , 1
well using Bascom (Listing 4).
Lcd "H: " ; Humidity ; " % "
Locate 2 , 1
Infrared remote control
We are all familiar with infrared remote controls or zappers Lcd "T: " ; Temperature ; " C "
for TVs and other home entertainment equipment. Numerous End If
different manufacturers and protocols exist that are not com- Waitms 1000
patible with one another, meaning that a remote control hand- Loop
set must be a correct match for the equipment it commands.
End
One feature common to all designs is that the signal sent by
A standard frequently used for IR remote controls is RC-5, on the remote control is transmitted. This switches on the out-
developed by Philips (see boxout panel). Simple commands put at the receiver, making LED2 come on. With button S2 you
for this are provided in Bascom, making decoding zappers a send a zero and switch off the output at the receiver once more.
simple task. Listing 5 provides a simple RC-5 receiver and
transmitter in Bascom. All received data is displayed on the LCD Arduino and IR
screen. The command is also sent over the serial interface. At For programming in Arduino-C we need to install the IRremote
the same time a check is made for any output to switch to Port Library (Listing 6). This makes use of Timer2 and its output
B. Given that LED2 is available at B.2 on the Extension Shield, OC2B (PD3, Arduino Pin 3) for generating pulses applied to
we have designed the code to illuminate this with button 2 on the IR LED. This is also the E wire of the LCD screen on the
the zappers and switch it off with button 0. Extension Shield. That unfortunately means the program can-
not interact simultaneously with the LCD. However, thats not
The RC-5 receiver can be connected to any input Pin you choose. totally bad news, as we still have the serial outputs for view-
So we have again deployed input PC3 (AD3) for this. For the ing the received data.
command Getrc5 Bascom uses the Timer0 Interrupt in the The input is a matter of choice and is assigned here to A2 once
background, which you must enable globally. In addition we more. Programming an input pull-up is overwritten by the
have switched in the internal pull-up resistor for input PC3. It Library, rendering this ineffective. But its not even necessary,
is then possible to use the controller for transmitting (only) as reception does not block the program even when an open
without an IR receiver connected. Had we not done this, an input is in the Low state. Our goal remains achievable, to use
open high-impedance input without a pull-up might otherwise a program without modification or reconfiguration for a choice
assume a Low state and cause the program to hang. of receiving only, transmitting only or handling both tasks.
For the transmit output (command Sendrc5 in Bascom) we The crucial advantage of the IRremote Library is that it can
normally use PB1 (Arduino Pin 9), because the output OC1A speak not only RC-5 but also a multiplicity of other standards.
of Timer 1 is connected to this Pin, used for generating the Most of us have a whole collection of disparate remote controls
36 kHz transmit signal (warning: in the Arduino-C++ soft- at home. If so, it makes good sense to point each of these once
ware a different output is used for this task, meaning that on at the IR Receiver. You will then get a report of the standard
this occasion we cannot keep the same hook-up allocations). employed and the data received. RC-5 is shown as Type 3. If
In Bascom the standby state of this Portpin must be defined you press several times on button 2 of an RC-5-compatible
in advance using a Port command; here it needs to be Low remote control, the following messages appear:
during inactive intervals. For each pulse packet the software
then switches over from the Port to the timer output. Because 3
the IR diode has no series resistor, it makes sense to switch 382
this to a different output Port, in order to use the two internal 3
resistors for current limiting. Here we selected PB0, which is also B82
switched Low as an output. In that way we still have four out-
puts on Port B as potential switching outputs for received data. The data is output as 12-Bit numbers. The lower 5 Bits denote
In transmit mode two commands are supported. If you press the key code. Next comes the 5-Bit device address, in this case
button S1 on the Extension Shield, then the code for button 2 the address 14 for a DVBT receiver. The highest value Bit is the
#include <IRremote.h>
void loop() {
int RECV_PIN = A2;
if (irrecv.decode(&results)) {
IRrecv irrecv(RECV_PIN);
Serial.println(results.decode_type);
IRsend irsend;
Serial.println(results.value, HEX);
decode_results results;
d = results.value & 15;
int d;
Serial.println(d);
int S1 = A0;
if (d==2) digitalWrite(LED,1);
int S2 = A1;
if (d==0) digitalWrite(LED,0);
int LED = 13;
}
int kathode =2;
if (digitalRead(S1) == 0) irsend.sendRC5(0x382,
void setup()
32);
{
if (digitalRead(S2) == 0) irsend.sendRC5(0x380,
Serial.begin(9600);
32);
irrecv.enableIRIn();
irrecv.enableIRIn();
pinMode(S1, INPUT_PULLUP);
delay(100);
pinMode(S2, INPUT_PULLUP);
}
pinMode(RECV_PIN, INPUT_PULLUP);
pinMode(LED, OUTPUT);
pinMode(kathode, OUTPUT);
In Figure 1 you can see the block diagram of the new power negative low-dropout regulator brings this down to 4 V. A
supply arrangements. After the 5-V supply from the USB positive low-dropout regulator generates +4 V directly from
connector has been filtered, a charge pump generates an the filtered USB supply.
unregulated negative voltage of (roughly) the same magnitude Figure 2 shows the complete schematic. IC1, an LT1962EMS8,
as the input voltage. Following some additional filtering, a provides the stabilized positive supply voltage. The same
function is performed for the negative voltage by IC2, an
LT1964ES5. A MAX1697 (IC3) serves as charge pump.
Presence of the USB voltage together with the two regulated
voltages is indicated by LEDs (D2, D3 und D4). Coils L1 and
Positive
Filter Low Drop +4V L2 take care of filtering the raw USB voltage.
Regulator The circuitry of the differential amplifier (IC4) remains largely
unaltered. Only the two series-connected input resistors on
USB each input are each combined in a single module. This enables
the op-amp to be moved forwards on the PCB, in order to make
room for the power supply components.
Negative
Filter Charge Filter Low Drop 4V
In contrast to the schematic published in Elektor 4/2015, some
Pump Regulator alterations have been made. As non-isolated voltage converters
have been used, the GND connection of the USB connection
has been commoned with the signal GND.
Despite elaborate filtering, the clock frequency of the charge
pump (around 200 kHz) is visible on a spectrum analyzer at
Figure 1. Block diagram of the new USB power supply arrangements. < 80 dBm. On an oscilloscope it cannot be detected, however.
C3
10n
3
+5V IN L1 +4V0
8 BYP 1
IN OUT
10uH
IC1 R2
10k
D2
LT1962EMS8
5 2 R8
6k81
D1 C1 SHDN SENSE
D2 = OVS-0606 GND C4
R3
3k83
D3,D4 = OVS-0604 4
1N4007 R1 1u D3
25V C2 10u
10V
4k64
R4
562R
GND 1u
25V
C8 R5
562R
D4
1u C10
C6 25V R6
3k83
1u 1
GND 4 R9 10u
6k81
ADJ 10V
25V IC2
6 3 R7
10k
C1+ C1 LT1964ES5-BYP
L2 L3
2 1 2 5
10uH
IN IC3 OUT 10uH
IN OUT
BYP
MAX1697 4V0
5 3
SHDN C9
GND
C5 C7
4 10n
1u 25V 1u 25V
1 6 VS
1 5 VS
1 3 VS
1 4 VS
R10
511R
+4V0
ADA4927-1
FB 1 12 PD
+IN 2 11 OUT
5
12 6
PD
+VS
7
+VS
8
IN + R11 R13 SIG
+VS
1
2 11
+VS
2k55 + IC4 FB
OUT
49R9
R12 ADA4927-1 R14 (Coax)
3 +OUT
2k55 EXP +FB 100R
VS
PAD 10
IN 4 GND
VS
VS
9 16
VS
VOCM 15
14
13
C14 C13
100n 10u
10V
R15 4V0
511R 1508 01 - 12
Figure 2. The complete schematic. The section surrounding the differential amplifier (IC4) is fundamentally unaltered.
To begin you will need an Arduino Uno along with the starter
kit which amongst other things contains:
A humidity sensor;
A multicolor LED;
A large LED-Matrix with 64 LEDs;
4 x 7-segment LED displays;
A handheld IR remote controller plus IR receiver chip;
A complete LC-Display module with I2C bus interface.
#include <dht.h>
This however will give quite a poor
#include <LiquidCrystal_I2C.h>
resolution for the measured tempera-
#include <Wire.h>
ture range. The LM35 generates a full
range output voltage from 0 V to just
LiquidCrystal_I2C lcd(0x27,16,2); // LCD address 0x27
over 1 V. If we use 5 V as the refer-
dht DHT;
ence voltage for the ADC it means
const int DHT11_PIN= 4;
that 80 % of the available input range
const int A0 = 0;
will never be used and the measure-
float tempLM35 = 0;
ment resolution of the limited range
long LM35val = 0;
we are using will be quite poor. To get
float TempCal = 0.1075;
maximum resolution we can set the
internal reference voltage to 1.1 V.
void setup()
With a reference of 1.1 V the formula
{ lcd.begin();
for temperature needs to be changed.
lcd.backlight();
Now the measurement resolution
analogReference(INTERNAL);
is equal to 1.1 V divided by 1023
}
which comes out at 0.001075 V or
1.0752 mV. With the output charac-
void loop()
teristic equal to 10 mV/C the result-
{ DHT.read11(DHT11_PIN);
ing conversion factor equals:
LM35val = analogRead(A0);
float TempCal = 0.1075; //1.075
tempLM35 = (LM35val * TempCal);
/ 10
A servo motor is included with the RFID kit and this can be used [5] Project page and download pack:
to operate a sliding door bolt. Figure 2 shows how the servo www.elektormagazine.com/160322
is hooked up to the Arduino. A green LED is also connected to
the board and indicates that the door (or locking mechanism
for a locker) is unlocked. The sketch has been expanded at the
end to include some basic servo control commands from the
servo-library. Make sure that any electronic door entry system
you install cannot prevent you from quickly exiting a building
in the event of an emergency or power failure.
Summary and outlook Listing 2. Display the RFID-UID using the Serial Monitor.
Most modern electronic experimenter kits con-
// RFID-RC522_data.ino
tain modules that just plug together rather
than individual components. This means that
#include <SPI.h>
we dont get so close to the hardware but
#include <MFRC522.h>
reflects the trend in electronics system design
so that now we can quickly get modules talking
#define RST_PIN 9
and then decide in software how the system
#define SS_PIN 10
behaves, that can also be quite challenging.
Thanks to the wide selection of software library
MFRC522 mfrc522(SS_PIN, RST_PIN);
functions we can have a sketch up and running
in no time.
void setup()
{ Serial.begin(9600);
These kits are worthy successors to the bags of
SPI.begin(); // Start SPI bus
loose components that were a feature of earlier
mfrc522.PCD_Init(); // Initialise MFC522 Reader
experimenters kits. Electronic newbies, prac-
mfrc522.PCD_DumpVersionToSerial(); // Show RC522 details
ticing engineers and old hands alike are sure
Serial.println(Place RFID TAG in range!);
to find that these kits interesting. The range of
}
components is sure to get you thinking what
you could use them for and they are a good
void loop()
{ // Card present?
if ( ! mfrc522.PICC_IsNewCardPresent())
{ return; }
Table 1. Hook up of the RFID
module and Arduino. // Select card
RC522-Pin Pin Arduino Uno if ( ! mfrc522.PICC_ReadCardSerial())
{ return; }
VCC (3V3) 3.3 V
GND GND
// Send data to serial interface
RST 9 mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
SDA (SS) 10 }
MOSI 11
MISO 12
SCK 13
The predecessor to this column first appeared in the March 1996 issue with the name electronics on-line. In
the following years many subjects were described, which these days are nearly all outdated, but a few have
withstood the test of time quite well. In the December 1997 issue a few websites and programs for building
your own loudspeakers were described. What has changed on this topic in the intervening 20 years?
Since I was a passionate box designer and builder at the more recent models you will nevertheless have to enter
time, I have calculated many box designs with the help of the necessary data yourself. This is an excellent program,
the loudspeaker design programs available at the time. I which offers a lot of features and, in any case, runs very
thought it would be nice to see what free programs are well on Windows 7.
available today (there are plenty of commercial programs, Another interesting program, but now already 8 years old, is
but as a hobbyist you much prefer to spend your money Basta! from Tolvan Data[2]. This was originally a commercial
on loudspeakers than on software). I was initially very dis- program, but the developer discontinued the development a
appointed. A large number of programs that you will come few years ago and now makes it available as freeware. The
across havent been updated in years. Often they can still be program, according to them, also runs on Windows 8/10
made to work in a DOS-box or with a few tricks, but there and can calculate and simulate open baffles, closed boxes,
is very little to be found that has purposely been developed bass-reflex and band-pass boxes. Basta! can also deal with
for modern computers with Windows 7, 8 or 10. There is ports and passive radiators. In addition there are various
nothing actually wrong with that as such, since the under- other features, such as the calculation of diffraction at box
lying calculations havent changed, but it is often quite a corners, calculation of air speeds from cones and in ports,
task to get these programs to function correctly. maximum cone deflection and more.
For the measurements of loudspeakers the program Sirp [3]
One of the programs that just appeared in 1997, is Win- is also available on the same website, which with the aid of a
ISD [1] and is 20 years later still being developed, logarithmic sine sweep measures the frequency response of
although at a very slow pace. The abbreviation ISD stands a driver and from that also calculates the impulse response.
for Interactive Speaker Designer and the program offers Although this is not as effective as an MLS-based measure-
the options of calculating closed, bass-reflex and band- ment for eliminating ambient influences, it is nevertheless
pass boxes. The program can also calculate and simulate a very useful method. Sirp can also measure the imped-
various kinds of passive filters and equalizers. There is a ance curve of a system. The measured data can also be
database of drivers and most brands are present, but for imported into Basta!
Gnublin 2
Linux Board
A build-it-yourself alternative
to the Raspberry Pi
By Dipl-Inf (FH) Benedikt Sauter and
Dipl-Inf Benedikt Heinz
As the 2 in Gnublin 2 hints, the Store [2]. Our company embedded all its successors, but also an ever-
design has some history behind it. Its projects GmbH also has its own web increasing range of other new and
predecessor, the Gnublin 1, formed the pages covering the design [3]. improved Linux boards addressing a
basis for the Elektor Linux board and an Five years have passed since that similar target market. So the question
embedded Linux course in Elektor [1]. original design: practically an eternity arises: does it make sense to produce
A number of further articles followed, in microelectronics terms. During that an updated version of the Gnublin
and a wide range of hardware is still period we have seen not only the board? If the answer is going to be
available for purchase from the Elektor appearance of the Raspberry Pi and yes, then we will need to create
idle state, the Gnublin 2 (including its connected to the ATSAMA5D41 SoC management unit) [5]. The PMU
256 MB of RAM) dissipates less than (U1) over a 16-bit bus. Compared to includes several switching and linear
0.3 W at a clock rate of 600 MHz. In other boards, which use a bus 32 bits regulators and can be configured from
the block diagram shown in Figure 1 wide, this results in a simpler and the SoC over its I2C bus.
the SoC is outlined in bold. As you cheaper printed circuit board and in The supply for the real-time clock
can see, besides the processor core lower power consumption. Even so, integrated into the SoC comes from a
itself, the SoC includes a number of with a RAM clock of 300 MHz the DDR2 type TPS78001 low-dropout and ultra-
important modules such as the RTC interface achieves a total data rate of low-power linear regulator (U2), which
(real-time clock) and interfaces to over 1 Gbit/s. in turn can be supplied from a button
external memory hardware. A detailed The SoC needs various supply voltages cell or externally over a connector.
circuit diagram can be downloaded for its I/O pins and for the processor The real-time clock of course uses
at [6]: it is too large to include here. core. These voltages are generated a standard 32.768 kHz watch
The 256 MB memory device IC1 is by IC2, an ACT8865 PMU (power crystal (Y1). The main system clock
Python is used in many universities and new to programming. MicroPython, orig- Read-Evaluate-Print-Loop or REPL, is
technical colleges around the world as inally targeted at 32-bit ARM microcon- not available in compiled languages
the initial programming language for stu- trollers, is compatible with Python and, such as C or C++.
dents. The large collection of powerful thanks to its small size, makes an excel- In addition to the large number of
libraries and the ease of use of Python lent choice for use on embedded pro- built-in functions, an extensive set
make it an ideal language for everyone cessors. With MicroPython complex and of function libraries is available that
manageable code can be developed to can be included in (or imported into)
control embedded systems that would a program. For example, there are
otherwise require languages such as C or libraries for random number gener-
C++. MicroPython allows experienced as ation, trigonometry, making music,
well as novice Python users to program networking, string & file processing,
small embedded systems. graphics & gaming, and much more.
The main reasons for MicroPython to not MicroPython can be mixed with other
fully support Python 3 are the lack of suf- programming languages such as C
ficient memory and missing hardware and or C++. This gives additional power
software features (such as multitasking and flexibility since parts of the
and multiprocessing) of embedded pro- code that require high speed can be
cessors. The differences between Python 3 developed using languages better
and MicroPython can be found at [1]. suited for such tasks.
Exceptions and error handling
Why MicroPython? are supported, which is especially
MicroPython and Python offer some important in real-time program-
Figure 1. The ESP01, a highly practical and unique features compared to other pro- ming. Without proper error handling
popular ESP8266-based module. gramming languages. In a nutshell: a crashed program may stop the
processor in an unknown state which
(Micro)Python is interactive mean- can have highly undesirable effects.
ing the program is not compiled It is open source meaning that the
and uploaded into the target pro- latest release can be downloaded
cessor, but rather interpreted and [2] and run at no cost. The source
acted upon at runtime. Although code of MicroPython can be modified
this makes programs run somewhat and ported to specific processors of
slower, it has the advantage of the interest.
user being able to easily experiment Finally, the language is human-read-
with his/her code. For example, we able and its syntax is easy to learn
can simply do interactive calcula- and understand.
tions as if we are using a calcula-
tor, or experiment with parts of the What MicroPython can
Figure 2. The BBC micro:bit can be programed program until we get the desired and cant do
online in MicroPython. results. This feature, also known as MicroPython can, in general, do every-
thing other programming languages can UART, ADC and IS. This may well be one SAMD21, LoPy, STM32F4-Discovery,
do too, like controlling hardware devices of the cheapest ways to start out with if Raspberry Pi and BeagleBone (both run
such as LEDs & displays, switches & but- you wish to experiment with MicroPython. the full Python 3 code).
tons, sensors, motors and so on. Com-
munication busses such as RS-232, CAN, BBC micro:bit MicroPython program example
IC, SPI, and others can easily be used This credit card sized board (Figure 2) Here is a simple MicroPython program
thanks to built-in and external libraries. with its many built-in features such as that runs on the BBC micro:bit. Its a
Network and Wi-Fi-based programs can 25 LEDs, two pushbuttons, an acceler- thermostat where the CPU temperature
be written to communicate with other ometer, a compass, GPIO, IC, UART, is read continuously and an appropriate
devices on a network, or to develop IoT and ADC is supported by MicroPython. message is displayed on the on-board
systems. Programs can be created online which LED matrix. When the temperature is
Because MicroPython is an interpreted removes the need to do any setup or equal to or higher than 25 C the mes-
language it is slower compared to other configuration. The BBC micro:bit is sage HIGH is displayed. If the tem-
embedded programming languages, highly recommended for people new to perature is between 20 C and 25 C
consequently it is not a good choice for programming. MEDIUM is shown. Otherwise, LOW
fast digital signal processing or real-time is displayed.
applications where high execution speeds pyboard
are critical. In addition, although less Based on the STM32F series Cortex M4 #Simple CPU thermostat program
important nowadays, MicroPython uses processor this development board (Fig- from microbit import *
slightly more memory than most other ure 3) comes preloaded with MicroPy-
embedded languages. Since MicroPython thon. The pyboard can be connected to while True:
is a subset of Python that does not sup- a PC through its USB port. The board
temp = temperature()
port all the Python libraries, a program features a real-time clock, an acceler-
If temp >= 25:
developed in Python may not work on an ometer, GPIO, an ADC, four LEDs, and
display.scroll("HIGH")
embedded system running MicroPython. a microSD card slot.
elif temp >= 20 and temp < 25:
Lead-acid
Battery
Activator
0-30 V
Also shows
the battery quality
A well-known electronics store has
been selling a very simple lead-acid
battery activator for many years [1].
Although I cant prove it, my lead-acid batteries do
seem to last longer since I started using the activator. The principle behind this
circuit is very simple. The battery is loaded with a current of about 100 A for a period of 100 s, which is
repeated every 30 seconds. But this circuit is capable of more, which well show you in this article.
By Jan Lichtenbelt (The Netherlands) The theory is that short (large) current This internal resistance gives an indica-
pulses will revert the sulfating of the tion as to the quality of the battery: the
lead plates [2]. I have used the Conrad lower it is, the better. The circuit shown
Electronics circuit in parallel with a sim- here has an extended functionality. The
PROJECT INFO ple power supply, which is based on an design is suitable for use with 2, 6, 12
LM317, set to 13.8 V, and used with a and 24V lead-acid batteries and works as
Test & Measurement
7-Ah lead-acid battery. This power supply both an activator as well as for the mea-
Hobby Modelling didnt seem to have any problems with surement of the internal resistance of all
Batteries these large current pulses. primary cells and batteries up to 30 V.
Not only is sulfating prevented, but these At first we thought wed enhance the
entry level types of peak current can also be used to Conrad design, but that resulted in a
intermediate level determine the quality of batteries. We do ramshackle circuit that wasnt really suit-
expert level this by letting a large current (I) flow for able for use with such high currents. The
a very short period through an external disadvantage of the Conrad circuit is that
shunt while measuring the reduction in the 0.1 / 2 W shunt wasnt designed for
3 hours approx. the terminal voltage (Vt). The current use with these current pulses. In practice
flow is given by: it could fail without you noticing.
It is shown in the literature [3] that the
I = Vshunt / Rshunt internal resistance depends mostly on the
No special tools are required temperature, the State of Charge (SOC)
The internal resistance is: and the age of the battery. The resistance
increases when the temperature drops. It
Ri = (V0 Vt) / I also increases when the battery is heav-
60 / $65 / 50 approx. ily discharged. Older batteries can also
Where V0 is the no load terminal voltage cause the internal resistance to increase.
and Vt is the terminal voltage under load. When you want to compare internal resis-
Table 1. The three LEDs give a quick overview of the state of charge of lead-acid batteries.
Measurement range 0-10 V 0-20 V 0-30 V
Voltage V < 2.5 2.5 < V < 5 5 < V < 10
LED 2-V battery 4-V battery 6-V battery 12-V battery 24-V battery
Red < 1.98 V 2.5 - 4.00 V 5 - 5.95 V < 11.9 V < 23.8V
Orange 1.98 - 2.08 V 4.00 - 4.16 V 5.95 - 6.25 V 11.9 - 12.5 V 23.8 - 25.0 V
Green 2.08 - 2.5 V 4.16 - 5 V 6.25 - 10 V > 12.5 V > 25.0 V
RO-0515S/P R27 *
C8 C5
K3
50mR
R26 IC4 10u 100n
TP1
390R
1 4
50V
Vb *
BT1
T1
R22
2 3
1k
R21
VO615A D10
IRLB8721
PbF
* not on PCB
1k
15V F1
Vl Vh Vt
R2 R8 R14
22k
22k
22k
1% 1% 1%
R3 R9 R15
22k
22k
22k
1% 1% 1%
JP1 JP2 JP3 JP4
1 1 1 1
R1 JP1...JP4
Vsel 2 H 2 R4 H 2 R10 H 2 R16
10k open: V' = V/6
3 L 3 L 3 L 3 H: V' = V/4
22k
22k
22k
1% 1% 1% L: V' = V/2
+5V R5 R11 R17
22k
22k
22k
1% 1% 1%
R6 R12 R18
22k
22k
22k
1% 1% 1%
22k
22k
1% 1% 1%
LCD1
LC DISPLAY 2 x 16
R20
C6
LED1 LED3
LED+A
LEDC
1k
VDD
VSS
R/W
100n
RS
VL
D0
D1
D2
D3
D4
D5
D6
D7
E
+5V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 14 D3 D5
VDD
1 18
RA2 RA1
2 17 R23 2V4 2V4
RA3 RA0
3 16 560R
P1 RA4 IC2 RA7
4 15 R24
10k RA5 RA6
560R
D4 D6
+5V
PIC16F1847
6 13
RB0 RB7
R25 7 12 2V4 2V4
RB1 RB6
8 11 LED2 LED4
10k
RB2 RB5
9 10
RB3 RB4
VSS
1 JP5
5
off time
open: 30s
closed: 10s
160064 - 11
Battery quality measurements shunt wont be connected again. The cir- voltages you should use a fuse with
0.2-30 V cuit will have to be restarted in order to a maximum rating of 10 A fast blow.
From here on, when we talk about batter- get out of this error condition.
ies this implies both lead-acid batteries Negative values may be possible when the Electrical circuit
as well as primary cells. battery isnt connected properly. The val- The section with large currents consists
If a single shunt of 50 m is used, the ues read will then depend on the charges of the shunt circuit with D9 as protec-
theoretical value of the current through that happen to be present at the time. tion diode, low-inductance shunt resistor
the shunt varies from 40 A to some When the circuit starts, the red, orange R27 and finally MOSFET T1. A current of
600 A. In practice the total resistance and green leds flash alternately. When 100 A can be switched using a gate volt-
of the shunt circuit will be higher due you want to test a number of batteries age (Vgs) of 5.5 V. For a current of 220 A,
to the connecting cables, contacts, the in quick succession, it would be useful if Vgs should be 9-10 V. The switching times
internal resistance of the battery and the the pulses would repeat more quickly. A given are in the order of 10 ns, but will
voltage drop across Schottky diode D9. jumper on the board is used to set the be longer in practice because of the use
The resulting currents will therefore be period to either 10 s or 30 s. For lead-acid of a resistor at the gate input.
lower than the theoretical ones. Ideally, batteries you must always select 30 s. The MOSFET was selected because of
the current pulse would have a value of its low total gate charge (Qg) of 7.6 nC
10 A for the range from 0.2-10 volt and Safety measures at 4.5 V. This results in a corresponding
100 A for anything above that. In a circuit with currents of 100 A and capacitance of:
When an extra resistor is connected above, good safety measures are para-
externally in series with the discharge mount. Of concern here is the shunt cir- C = Q / V = 7.6 / 4.5 2 nF.
circuit, the maximum current will be cuit. Three safety measures have been
restricted at higher voltages. Alterna- put into place (two circuit improvements With a 1-k resistor (R22), the RC time
tively, you may decide to use a shunt and one preventative measure). is:
for one specific range only. For ranges of 1. The connections in the shunt circuit
about 0.2-10 V, 5.5-20 V or 5.5-30 V you have to be able to cope with the short, Ton = 103 x 2 x 10-9= 2 s.
should use a shunt of 50, 100 or 220 m large pulses. All the copper tracks in
respectively. As mentioned earlier, you the battery shunt circuit on the PCB Adding R21, Toff becomes 4 s. These are
must always use an external supply when must therefore be tinned with a thick very good switching times for a 100s
the voltage is less than 5.5 V. layer of extra solder. In addition, the pulse.
The input voltage at the ADC may have a long leads of the diode, shunt and
maximum value of 5 V. A potential divider MOSFET have to be used to connect The MOSFET is brought into conduction
is therefore required for the above-men- them together. The space left between by raising the gate voltage to a sufficient
tioned ranges, with values of 1:2, 1:4 or the leads and the copper track should level in a very short time. Since this gate
1:6 respectively. This can be selected be filled with solder. circuit has to be isolated from the micro-
using a set of jumpers in the circuit. 2. Cables should be kept as short as pos- controller circuit, an optocoupler seems
Under certain conditions the program sible. Under no circumstances should the most appropriate to drive the gate.
stops, see Table 2. The reason is shown on they be rolled up, which would create There are commercial opto gate-driv-
the LCD. However, since the LCD may not inductive loads, along with very high ers available that can even supply the
be in use, the error condition is also shown peak voltages. The program stops required energy to drive the gate. We
using the leds. The most severe error con- when the load is too high, but only tried many, but none of them was able to
dition is when the current is too high. When after the current has been measured. produce a good pulse of 100 A for 100 s
this occurs, the red led lights up and the The damage will have been done by with short switching times. It was often
then. the case that either the turn-on time or
3. If for any reason the MOSFET con- the turn-off time was good, but never
ducts too long or breaks down, the both. The supply required for the gate
Figure 1. In the circuit the different sections fuse (F1) will blow. For 1.2V batter- voltage (Vgs) has to be at least 8 V in order
can be clearly seen from top to bottom: supply, ies we would recommend a 3 A fast to make currents of 100 A to 220 A flow.
MOSFET circuit, potential divider with jumpers, blow fuse. For other primary batter- When the battery voltage is less than this,
and control and display via the microprocessor. ies and lead-acid batteries with higher the voltage has to be generated some-
PARTS LIST
best of health. But at least the car still charged and had an internal resistance come off worst, or was that just chance?
starts reliably! of 101 m. After charging them with It can be clearly seen that there is a ten-
The example in Figure 4 shows the 2000 mAh the value dropped to 86 m. dency for the resistance to increase as
restorative effect of the current pulses We can report the following regarding the the batteries are more discharged. How-
in another battery. After just four or five accuracy we experienced in practice: The ever, further research is needed before
pulses the internal resistance has halved lead-acid batteries returned values with the differences between the brands can
and is getting close to its eventual value. a variation of 1% or less, which was very be explained. It looks like this tester wont
In a 12-V lead-acid battery of 7 Ah we good. On the other hand, AAA and AA bat- be getting much rest!
find that the temperature dependence teries (alkaline and NiMH) had variations (160064)
of the internal resistance is about of over 10% in the measurements. This
0.7 m/C. It changes in value from means that one measurement of such a
34 m at room temperature to 62 m battery is not enough to get a reliable FROPM THE STORE
in the freezer (18 C). value. In order to obtain the correct result
160064-1
A new lead-acid battery (12 V, 7 Ah) has you should take a number of measure- PCB
an internal resistance of 34 m 2 % ments for these batteries and then take
160064-41
when it was charged, while an 8-year the average. Fortunately it only takes a
Programmed controller
one of the same type had a resistance minute to take six measurements.
160064-71
of 52 m 3 %. Both types have a ter- Lastly, I measured all of my AA alkaline
Kit of parts
minal voltage of 13.2 volts. batteries. The result of this can be seen in
Tw e l v e s u b - C N i M H b a t t e r i e s o f Figure 5. Its very noticeable that there 120061-74
2x16 character LCD
4600 mAh, connected via solder was a large spread between the different
tags with low resistances, where dis- brands. A well-known brand seems to
Web Links
[1] Conrad lead-acid battery activator 191123: www.conrad.com/ce/en/product/191123/
[2] A lead-acid battery desulfatation tutorial: www.chargingchargers.com/tutorials/battery-desulfation.html
[3] Battery and Energy Technologies in Electropaedia: www.mpoweruk.com/performance.htm
[4] Software download: www.elektormagazine.com/160064
7. Elektor Uno R4
www.elektor.com/elektor-uno-r4
www.elektor.com/microscope-v160
This book will not only familiarize you with the world of Arduino This book makes use of the ARM Cortex-M family of processors BrainBox Arduino is a rugged version of the Arduino Leonardo.
but it will also teach you how to program microcontrollers in in easy-to-follow, practical projects. It gives a detailed Thanks to the solid connectors, the 500mA outputs, the servo
general. Having completed this fun and playful course, you will introduction to the architecture of the Cortex-M family. The outputs and the many power supply options this Brainbox is
be able to program any microcontroller, tackling and mastering architecture of the highly popular ARM Cortex-M processor immediately useful for most projects you can think of. Perfect
I/O, memory, interrupts, communication (serial, IC, SPI, STM32F107VCT6 is described at a high level, taking into for educational and DIY purposes by the solid construction and
1-wire, SMBus), A/D converter, and more. This third, extended consideration its clock mechanisms, general input/output the large amount of free educational materials.
and revised edition contains two new chapters: AVR Playground ports, interrupt sources, ADC and DAC converters, timer
and Elektor Uno R4. facilities, and more.
member price: 33.95 38.65 US $43.00 member price: 28.95 35.95 US $38.00 member price: 46.95 53.96 US $57.00
LEGO Control Board for Raspberry Pi Red Pitaya for Test & Measurement Sand Clock
This Raspberry Pi HAT puts at your disposal 4 motor-control The Red Pitaya is a credit card-sized, open-source test This supercool gadget built around an Arduino Uno writes the
outputs for LEGO EV3 motors and 16 buffered I/O connections and measurement board that can be used to replace most time into a layer of sand. After an adjustable time the sand is
that can be used in combination with a powerful Raspberry Pi. measurement instruments used in electronics laboratories. flattened out by two vibration motors and everything begins
Programming is possible in languages such as C and Python. This book aims to teach the principles and applications of all over again. This kit contains everything to build this sand
The board combines the flexibility of LEGO with regards to basic electronics by carrying out real experiments using clock by yourself: all mechanical parts, the motors, an Arduino
mechanical construction and the flexibility of the RPi with the Red Pitaya. Many fun and interesting experiments are Uno, a special RTC/driver shield, a power adapter and even a
regards to software, Internet communications and sensors. included. The book also makes an introduction to visual small bag with sand.
programming environment.
member price: 34.95 40.46 US $43.00 member price: 26.95 31.45 US $34.00 member price: 92.95 107.96 US $114.00
The Hexadoku puzzle employs numbers in the hexadecimal thicker black lines). A number of clues are given in the puzzle
range 0 through F. In the diagram composed of 16 16 boxes, and these determine the start situation.
enter numbers such that all hexadecimal numbers 0 through
F (thats 0-9 and A-F) occur once only in each row, once in Correct entries received enter a prize draw. All you need to do
each column and in each of the 44 boxes (marked by the is send us the numbers in the gray boxes.
Participate!
Ultimately March 23, 2017, supply your name, street address
and the solution (the numbers in the gray boxes) by email to:
hexadoku@elektor.com
Prize Winners
The solution of Catdoku in edition 12/2017 (January & Ferbruary) is: 28D45F.
The 50 / 40 / $70 book vouchers have been awarded to: N ico R oz endaal ( T he N etherlands) ,
G ilb ert L uyck x ( B elgium) and T orb en M unk ( Denmark ) .
Congratulations everyone!
A B C D E F G H I J K L M N O P Q R S T
1 F 9
2 8 7 0 F
3 B C 4 7 E 1
4 1 6 2 3 9 0 4 E A 5 D
5 D 5 9 E C B 7 1 6 A 8 4 3 2
6 0 A 8 2 E 4 3 7 9 F B 6 C D
7 4 0 1 5 6 D F 8 B 3 2 9 A 7
8 5 E B 9 1 0 2 D 4 C 6
9 2 6 D A 3 4 E B F
10 6 C 2 F A 1 3 8 4 B
11 F 7 9 A 2 4 6 8 3 5 1 0 D E
12 A 3 4 6 F B 1 C E D 5 7 0 8 9 2
13 0 B 2 8 D 4 5 F 9 1 6 E C 7 A 3
14 D 1 9 E B 7 A 8 0 2 4 C F 3 6 5
15 4 3 A 1 E B 0 5 7 9 D 8
16 9 F C D 7 8 A E 3 B 6 1
17 F 9 1 3 6 C 5 2 0
18 3 6 E 9 A 4
19 8 5 7 1
20 B D 0 C
The competition is not open to employees of Elektor International Media, its subsidiaries, licensees and/or associated publishing houses.
Our graphics solutions are supported with the free MPLAB Harmony software
framework and offers developers the choice of two best-in-class tools:
www.microchip.com/MCU32GFX
The Microchip name and logo, the Microchip logo and MPLAB are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. All other trademarks are the property
of their registered owners. 2017 Microchip Technology Inc. All rights reserved. DS60001462A. MEC2138Eng01/17