Lektor: 6-Channel Temperature Monitor & Logger
Lektor: 6-Channel Temperature Monitor & Logger
com
lektorlabs
DESIGN BUILD SELL ELECTRONICS magazine
6-Channel Temperature
Monitor
& Logger
AS-Interface Essentials
Industrial automation bus system explained
6-Channel Temperature Monitor & Logger AC-in, DC-out Baristors An Elektor BoBs Catalog AS-Interface Essentials Bright
Flashing LED Create a 100% Private Vocal Assistant with Snips Creating a New Component (Symbol) in KiCad Differential
Probe Power Supply Display Serial Data on a Web Page ESP32 as a Time Server ESP32 Battery Monitor Fair Algorithms
From Tubes to Silicon Hexadoku IOTA Crypto Currency (and an FPGA for the RPi) MIDI I/O Breakout Board and more...
DISCOVER OUR
NEW PRODUCTS!
IP 67 Multimeter from 79,- €
Graphic Multimeter from 189,- €
Bluetooth Multimeter from 109,- €
from
79,- €
Whether you are looking for professional digital multimeters with data logger
and Bluetooth interface, 4-channel oscilloscopes with integrated generator,
multimeter and CAN bus decoder or simply a low-cost basic oscilloscope
– PeakTech® offers extensive new products at the best price!
www.peaktech.de Our value is measurable.
Elektorlabs Magazine
Edition 4/2019
Volume 45, No. 496
July & August 2019
www.elektor.com
www.elektormagazine.com
Regulars
63 Peculiar Parts, the series
TL431 Precision Programmable Reference
76 Questions & Answers
(Almost) everything you always wanted to
know about...Analogue Design and Circuitry with –240 °C to 850 °C
80 Err-lectronics
Corrections, Feedback and Updates to
published articles industrial range
82 Elektor Store Highlights
Equipping Your Maker Lab
90 HomeLab Helicopter
Wondrous Things Electronic Snips Speech Recognition
Spotted From Above with an example for the Raspberry Pi
104 Retronics
Language assistants like Alexa, Google Home or
From Tubes to Silicon
Siri are now commonplace. However, the actual
110 Elektor Ethics recognition of the spoken words is not done
Fair Algorithms locally, but in the Cloud of the provider –
112 Elektor Store which raises questions about data privacy.
what’s available @ www.elektor.com There are other solutions such as Snips – a
speech recognition system that runs entirely
114 Hexadoku on local hardware like the RPi. We took a
The original Elektorized Sudoku look at a speech recognition kit and show
how you can use it to develop your own
applications...
Features
14 Create a 100% Private Vocal Assistant
with Snips
Everyone’s entry ticket to the world of
22
Artificial Intelligence, with a Raspberry Pi
72 AS-Interface Essentials
22 Snips Speech Recognition How the industrial automation bus system
with an example for the Raspberry Pi works
104
34 Revolutionary Battery Pack Design 78 An Elektor BoBs Catalog
from TUE/InMotion It’s the little things...
(it’s) Student Demonstration Time!
49 Heading Towards a Tsunami of Light
News from Chalmers University Retronics
52 Elektor Start-up Challenge - Paris 2019 Projects From Tubes
An international launchpad for start-ups
to Silicon
64 IOTA Crypto Currency
(and an FPGA for the RPi) 6 6-Channel Temperature Monitor
Part 2: PiDiver — FPGA board for fast & Logger
calculations Measures from −240 °C to +850 °C
In the olden days everything was controlled using hand-made custom cabling
and proprietary data formats. In the industrial world at least, however, this
kind of thing is long gone: now entire systems are based instead around
fully-featured bus architectures. As well as the obvious advantages of easier
maintainability and expandability there are other reasons to prefer such an
approach. For example, a widespread
Next Editions
industry standard ensures the long-
term availability of hardware and
software components, at least to ElektorLabs Magazine Edition 5/2019
some degree. In this article we Horticulture Box • Build Your Own RFID reader Writer •
will take a look at AS-Interface. 8 Channel Timer with OLED Display • Sound Blink DIY
Portable Speaker • Flicker Free LED Dimmer • WSPR
72
SDR • Q&A on Sensors • Littlevgl GUI library with ESP32
and a Raspberry Pi Touchscreen • USB-RS232 converter
(FT231X BoB) • Remote Control for Hover-Catamaran •
A Time-Corrected Woofer Concept • Universal battery
Charger • Wireless In-Car Voltmeter.
6-Channel
Temperature Monitor
& Logger
Measures from
−240 °C to +850 °C
By Clemens Valens (Elektor Labs) and Sunil Malekar
(India)
Even my low-cost Bluetooth speaker up to +850 °C. Note that these are soft-
sounds an alarm when it gets too hot (as ware limits; the real-world limits greatly nickel. Sensor preci-
I discovered after placing it on a heater). depend on the sensors being used. sion depends on the purity of the metal.
Because humankind likes to measure Platinum has the most stable resistance/
temperature so much, we decided to Resistance thermometers temperature relationship over the largest
design a device capable of measuring To measure temperature, we will use temperature range.
up to six of them. Usually, thermometers so-called RTDs in the shape of Pt100 A Pt100 probe is an RTD made from plat-
only measure one temperature — some probes. RTD is short for Resistance inum wire (‘Pt’ in the Periodic Table). The
can do two, often labelled ‘inside’ and Temperature Detector, a device con- value ‘100’ indicates that its resistance
‘outside’ — but for process control more sisting of a length of metal wire with a is 100 Ω at 0 °C. Other val-
channels may be required. Range is also known resistance/temperature relation- ues can be
important, which is why the device pre- ship spiralled on a suitable supporting
sented here can measure temperatures material. The metal typically
across the massive range from −240 °C used is platinum, copper or
entry level
Æ intermediate level
expert level
4 hours approx.
soldering iron,
C2 programmer (see text)
Pt100 V–
400
350
R4
300
R3
250 V+ V
R [Ω]
200 Rw
150
RTD
100
I RTD
50 Rw
VRW
0 Rw
-200 -100 0 100 200 300 400 500 600 700 800
T [°C] 190118-010
Figure 1: The relationship (in blue) between resistance and temperature of a platinum (Pt) wire is Figure 2: The Howland current source has a
nonlinear. It may be approximated using a lookup table of short “straight” segments of the curve. very high output impedance. It is used here to
excite a 3-wire RTD.
10K
10K
10K
important to compensate the sensor for
13 11
Y0 A
them to ensure reliable and repeatable 14
Y1 B
10
IC5
results. To avoid complicating our sys- 15
Y2 C
9
12
Y3
tem too much, we opted for 3-wire RTDs. 1
Y4 R13 IC6
3 5 3 3
Y5 4051 Z 1k R11
K7 2 2 6
Y6 OP07 1k
An RTD is not a thermocouple RTD2 1 4
Y7 INH
6 2
K3 2
One last but important thing to mention RTD6 1
100n 100n
Y5 Z IC11
1n
temperature from the measured resis- 2
Y6
8 1 100n R20
4 6 7 2
Y7 INH 10k
tance. The Callendar–Van Dusen equation R3 6 3
R22 IC10
has long been used for platinum RTDs, 5 4
10k
2
470
6
LM336M-2.5 OP07
but in 1990 the Comité International des 0.01% 3
R21
Poids et Mesures replaced it by a 12th-or- C38 R1
10k
+5V 10k
der polynomial valid over the tempera- 100n
ture range from -259.35 °C to 0 °C and C20 C30 C35 C34 C29 C41
peratures from 0 °C up to 961.78 °C. 8 IC5 8 IC7 8 IC9 IC8 IC6 IC10
C24 C33 C36 C32 C25 C39
Because evaluating such polynomials 7 7 7 4 4 4
calls for heaps of computing power (and 100n 100n 100n 100n 100n 100n -5V
190118-006
debugging), most applications simply use
lookup tables. We did so too.
GND 100
+3V3 K2 16V
3
R9 1 2
3 4 8 7 6 5 4 3 2 1
1k
C1 C11
5 6
AIN0.7
AIN0.6
AIN0.5
AIN0.4
AIN0.3
AIN0.2
AIN0.1
AIN0.0
R10
7 8
1k 9 32 1 100n
9 10 AGND VREF-
C19 10 31
AV+ VREF+
11 30
FRC10 PIN
PC2.0/C2D P1.7/IDA1 RN1
1 12 IC4 29 2
/RST/C2CK P1.6/IDA0
13 28 3
+5V P0.0 P1.5
14
P0.1 C8051F350 P1.4
27 4
1
+5V
15 26 5
P0.2/XTAL1 P1.3
MBR140 D1 16 25 6
USB P0.3/XTAL2 P1.2
7
RX/P0.5
TX/P0.4
DGND
VDD
P0.6
P0.7
P1.0
P1.1
6 x 10k
CBUS3 +5V
17 18 19 20 21 22 23 24
CBUS2 VCCIO C6
CBUS1 +3V3 +3V3
CBUS0 GND 100n
RESET
BOB1 CTS R2
DCD RI +5V
+5V
10
S4 S3 S2 S1
RXD
GND
TXD
RTS
P1
10k
10k
10k
1n 100n 10 100n
SAVE INCR DECR MENU 10V
+5V
LD1117DT50TR +5V
IC1 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
C5 C4
VCC
GND
RS
ADJ
A
R/W
D7
D6
D5
D4
D3
D2
D1
D0
E
K
10 100n
16V LCD1
LD1117DT33TR +3V3 MC21605G6WD-BNMLW-V2
K1
D2
IC2
MBR140 C7 C8 C9 C10 C2 C12
Each multiplexer has eight channels, two Power supply MCU used here runs internally at 49 MHz
of which are used for reference signals Theoretically, the supply voltage for the and executes most of its instructions in
Vmin (GND) and Vmax (VR3). Now you finally circuit connected to K1 can be up to one cycle, making it a pretty fast device.
understand why there are six RTD chan- 15 VDC, but this will put unnecessary The C8051F350 is part of a family of
nels and not seven or five. These refer- strain on the low-drop voltage regulators. four that differ only by package type and
ence signals follow the same paths as The minimum supply voltage is 7.5 VDC, ADC resolution. The ‘F350 is the largest
the RTD signals (R3, a 0.01% tolerance the recommended value is 9 VDC. The part with a 24-bit sigma-delta ADC, eight
resistor, is even mounted close to the total current consumption is around dedicated analogue inputs, and 17 dig-
RTD connectors to mimic an RTD as close 70 mA including the 20 mA consumed ital I/O pins. It's an analogue-oriented
as possible). Because the values of these by the backlight in LCD1. (Note that the controller with built-in digital filters and
signals are known, this allows the soft- latter has a built-in current limiting resis- two 8-bit DACs. In this project we do
ware to calibrate the digitizer stage and tor.) IC1 lowers the supply voltage to 5 V not use all its capabilities, but you may
remove errors introduced by the multi- for most of the circuit except microcon- want to study the MPU further for some
plexer and current source. troller IC4; IC2 creates a 3.3-volt supply future project.
The outputs of the input multiplexer are for this clever part. Although running from 3.3 volts, the
individually amplified by a factor of 13 The analogue input stage also requires C8051F350's digital I/O pins are 5 V tol-
by IC6 and IC8. The signal ‘V’ from Fig- a −5 V supply voltage, and this is taken erant, which is why it interfaces nicely
ure 2 then arrives at the microcontrol- care of by IC3. with the 5-volt-powered peripheral cir-
ler’s ADC input 3 (AIN0.3), while signal cuitry (note the pull-up resistors R4 to
‘VRW’ connects to AIN0.5. The microcontroller R8 and network RN1).
Over the past years, we have seen so A quartz crystal or resonator is not called
Current source, part two many Arduino-based circuits flashing for as the MCU has a calibrated oscilla-
The Howland current source in the proj- by that some have come to believe that tor on chip.
ect comprises IC10, resistors R1, R20, there exists only one type of 8-bit micro- Four pushbuttons (S1—S4) and an LCD
R21 and R22. V+ from our description controller. That this is not true is proven provide the user interface. P1 sets the
above is connected to GND and therefore by our circuit with its pimped-up, 8051- display contrast level; if you forget to
has a value of 0 V. V− is equal to −2.5 V, based brain! Now, before turning away adjust it when you power the board for
produced by voltage reference IC11. R21 in disgust, be aware that almost forty the first time, the display may not show
corresponds to R3 from the description years after its introduction the 8051 is anything.
above. The output current is: still a widely used 8-bit processor. Manu- For communication with a computer,
(0 − −2.5) / 10,000 = +250 [µA]. factured by Silicon Labs, the C8051F350 we added the option to plug a USB-to-
component list
Advertisement
Snips is a platform for connected “things”. It allows developers and manufacturers of “things” to add a voice
assistant to their products Your Raspberry PI may not yet obey your finger or your eye, but thanks to Snips
it is at your command. This article explains how to add “ears” to a Raspberry Pi.
Snips Console
Then go to [1] to create an account, then a new assistant.
This assistant may have one or many function(s), you can
choose from the Apps available in the App Store (Weather,
recipe book, control of Philips Hue lamps... See Figure 3)
or construct your own. You can also personalise an App from
the App Store to produce a unique version thanks to the fork
function (Figure 4).
Figure 4: The fork function allows the creation of a copy of an existing An App captures intentions, or intents, thanks to the training
App to modify it (this message appears automatically on clicking Edit). of the NLU model. It also captures the parameters, or slots, if
Figure 6: Possible phrases registered in the intent start_quiz to start a game. This can of course be done in any of the available languages.
Figure 7: For the intent gives_answer, the numbers are highlighted for the Answer type slot.
with Hermes(MQTT_URL) as h:
# defines TTS
tts_good = "Good answer !"
# Subscribe to intents
tts_bad = "Wrong answer ..."
h.subscribe_intent(INTENT_STARTS_QUIZ, starts_quiz)\
tts_no_answer = "I'm sorry I didn't get your answer"
.subscribe_intent(INTENT_GIVES_ANSWER, gives_answer)\
tts = ""
.subscribe_intent(INTENT_DOESNT_KNOW, doesnt_know)
We hope that this first article about the Snips voice assistant
will get you on the way to using it. You are now ready to add
voice commands to any of your Raspberry Pi projects. To make
this easier, don’t forget to check in the App Store in case some-
one has already designed an App close to your needs.
(180733-02)
Web Links
[1] Snips console, tools and documentation : https://console.snips.ai
[2] Python Code of the App on the Article Page: www.elektormagazine.com/180733-01
[3] Review: Snips — Speech Recognition for the Raspberry Pi:
www.elektormagazine.com/news/review-snips-speech-recognition-for-the-raspberry-pi
Advertisement
Plastic enclosures
standard and miniature
More than 5000 different enclosure styles:
hammfg.com/electronics/small-case
01256 812812
[email protected]
Language assistants like Alexa, Google Home or Siri are now commonplace. However, the actual recognition
of the spoken words is not done locally, but in the Cloud of the provider – which raises questions about data
privacy. There are other solutions such as Snips – a speech recognition system that runs entirely on local
hardware like the RPi. We took a look at a speech recognition kit and show how you can use it to develop
your own applications...
Anyone with a fear of Big Brother will be happy to know there The sensors and actuators
are alternatives available such as Snips — this is speech rec- The temperature and humidity sensor is a Sensirion type SHT31
ognition software that works completely offline and ensures mounted on a Grove module. The temperature can be measured
your data does not go any further than your home network. to ±0.3 °C and the humidity with ±2% accuracy.
It doesn’t need a permanent Internet connection or a bank of The relay is also a Grove module from Seeed Studio. Its contacts
computers to perform speech recognition. To explore the sys- can switch 250 VAC / 30 VDC with a current rating of 5 A and
tem further we will use the Snips Voice Interaction Kit which should be good for 100,000 switching cycles. Although the relay
uses a Raspberry Pi 3B+ as the base unit. can switch mains voltages the board has not been designed to
operate with them because there is no insulation provided and
In addition to the RPi we need a few more components for this it would be easy to accidentally touch live conductors. As long
speech recognition application. Let’s take a look what’s in the as the load voltage is below the extra-low voltage safety level
kit (Figure 1). (<25 VAC / <30 VDC) and within the relay parameters, you
can safely use this relay module for experimentation.
The kit A small speaker is included so you can hear what the language
The kit arrives packed in a plain blue cardboard box. Inside assistant is saying. As you would expect from a small speaker
are all the components including the Raspberry Pi 3B+, a 5-V the sound quality is quite poor but adequate for the purpose.
3-A mains power adapter, a relay, a temperature and humid-
ity sensor, a speaker, a ReSpeaker 2-Mics Pi HAT, a mounting ReSpeaker 2-Mics Pi HAT
plate and an SD card with pre-installed system along with a The heart of the system — apart from the RPi itself — is the
quick start guide. ReSpeaker 2-Mics Pi HAT [1]. This is built around a WM8960
This gives us all the ingredientsto build our own small language audio codec. Unfortunately, this one is not yet supported directly
assistant. When assembling the kit, use the appropriate spacers by Raspbian, and the driver also has a few bugs. Therefore its
and screws. Unfortunately the manual skips over some details necessary to when using the shield with a naked Raspbian-im-
here so we are left wondering which screws go where. After age, the driver itself has to be translated for the RPi. Here are
some trial and error we finally get it sorted. The RPi board is the instructions to manually configure the driver. The WM8960
not ideally positioned to easily access the SD card slot. integrates a Class D power amplifier which can supply 1 W into
8 Ω per channel and also includes wiring for microphones. Two
The perforated acrylic mounting board microphones are installed on the board; the connections for a
An acrylic mounting board is supplied onto which you can fix speaker or headphones are also available.
the various modules using self-tapping screws. The matrix of On the board there are also three RGB LEDs (APA102), which
fixing holes allows a certain degree of freedom as to where connect via SPI to the Raspberry Pi. These can signal when
the modules can be fixed. the voice assistant starts to listen (or has not understood).
Setup
The Raspberry Pi now needs access to our network, the eas-
iest way to do this is by using a cable. If you want to do the
whole thing via Wi-Fi, the SD card must be taken out of the
RPi and the file wpa_supplicant.conf placed in the drive with
the name boot. The file contains:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<your_country_id>
network={
Figure 2: Creating an Intent (speech command).
ssid=”<your_ssid>”
psk=”<your_password>”
}
A pushbutton is also provided to provide interaction with the The corresponding country, SSID and password entries must
system. Finally, there are the connections for the relay, the match your own Wi-Fi credentials.
temperature and humidity sensor. Using snips-base.local you can connect to the Raspberry Pi
A micro-USB port on one side provides convenient power sup- via SSH and explore the system. The snips software is already
ply connection to the RPi. Unfortunately, the header connector preinstalled on the system.
strip is not feedthrough so we can’t stack another HAT on top After the basic setup of the RPi, which is quite straightforward,
and it’s not possible to use a SPI-TFT display as a GUI. we install Sam. Sam is a command-line interface that lets you
Make sure you connect the cables to the correct ports when monitor and manage the Snips software on the Raspberry Pi.
hooking up the relay, humidity and temperature sensor. After To install Sam we need to open a terminal and enter sudo
everything has been assembled and the SD card inserted we npm install -g snips-sam. We can now link to the Snips soft-
can begin. An HDMI monitor and a USB keyboard are useful ware on the Raspberry Pi with sam connect snips-base.local.
now so that we can track the RPi’s first boot process. With sam status we can then output the state and the version
numbers of the individual components. The output should look
like Listing 1.
Listing 1. State output and version number Since the software is still subject to updates, it can occur that
of the individual Snips components. one or other of the versions will sometimes not work properly.
To get the latest version, we now run sam update. The RPi now
Connected to device snips-base.local downloads and installs the latest version. Finally we need to
OS version ........... Raspbian GNU/Linux 9 (stretch) run the sam update-assistant. This will then also update the
Installed assistant .. MakerKitBundle_EN applications and all Snips components should be online again.
Language ............. en If we now enter sam status, all components (except snips-
Hotword .............. hey_snips analytics) now run and the RPi should respond to the example
ASR engine ........... snips commands from the tutorial.
Status ............... Live
Build your own application
Service status:
After creating an account [2] you can use the web interface to
create your own application, and even better, train the assis-
tant on your own voice commands. As a small demo, we will
snips-analytics ...... 0.60.8 (running)
get the language assistant to give us the current time.
snips-asr ............ 0.60.8 (running)
We first create a new wizard, in this case we call it WhatTi-
snips-audio-server ... 0.60.8 (running) meItIs. Within a wizard, apps can now be created. We create
snips-dialogue ....... 0.60.8 (running) an app called “currentTime”. This app is then responsible for
snips-hotword ........ 0.60.8 (running) issuing the current time on command.
snips-nlu ............ 0.60.8 (running) In order for the app to understand a voice command, we have
snips-skill-server ... 0.60.8 (running) to train it as an “intent” (short for intention), see Figure 2.
snips-tts ............ 0.60.8 (running) There are a couple of built-in modules that can make things
easier for us if we Talking numbers or a date. Since our key-
import time
now = time.localtime()
if len(intentMessage.slots.DateTime_Req) > 0:
date_or_time = intentMessage.slots.DateTime_Req.first().value # We extract the value from the slot
result_sentence = "Current time is : {} {} ".format(str(now.tm_hour), str(now.tm_min))
# The response that will be said out loud by the TTS engine.
else:
result_sentence = "Time is running out"
current_session_id = intentMessage.session_id
hermes.publish_end_session(current_session_id, result_sentence)
Web Links
[1] Embedding an audio driver: http://wiki.seeedstudio.com/ReSpeaker_2_Mics_Pi_HAT/
[2] Snips homepage: https://snips.ai/
[3] Snips documentation: https://docs.snips.ai/articles/console/actions/actions/snippets
At the start of 2019, some 35 years after its introduction, version 2.0 of the Musical Instrument Digital
Interface, better known as MIDI, was announced. MIDI 2.0 introduces many new features, two of them being
two new connectors. A new universal MIDI interface breakout board is due and here it is.
know is that the new standard will remain 3.5 mm and 2.5 mm, where the latter
Quick Features 100% compatible with MIDI 1.0. is the recommended type. The motiva-
• One PCB for MIDI In, MIDI Out tion for this addition to the standard is
and MIDI Thru TRS? Like "jack"? simple and size related: the venerable
• Configurable for 5-V and 3.3-V To be honest, the new MIDI connec- DIN plug is too bulky to fit in modern,
systems tor specification was released in the flat smartphone-like equipment.
• Supports DIN, 3.5-mm TRS and summer of 2018, and therefore is pre-
2.5-mm TRS connectors MIDI 2.0. In a Letter of Agreement for New, new, all new!
• Compliant with latest MIDI Recommended Practice the Tip-Ring- The new MIDI breakout board (BoB) we
standard Sleeve (TRS) socket/plug combination present here can be equipped with either
got accepted as the MIDI connector/plug, one of the three connector types: DIN,
and the way to wire it to the traditional TRS-3.5 or TRS-2.5. Furthermore, the
5-way DIN connector/plug is standard- BoB supports RF grounding and 3.3-volt
At the time of writing this article (April ized. Most people will know the TRS con- signalling, and the same PCB can be con-
2019) the MIDI 2.0 specification has nectors as 'audio jack' plugs and sock- figured as either a MIDI In or MIDI Out
not been released yet. We will therefore ets. Actually, the new connectors are just (or MIDI Thru, which is the same thing
not go into any detail here. What we do one but with two different diameters: as Out).
1k
2.5mm
220
100n Breakout Board
IC1
4 1 1 6 3
Æ entry level
K4
* *
C2 C1 D1
2
K1 & 4 intermediate level
2
100n 5 100n BAT54 expert level
3 DIN5 2 5 1
H11L1MS
K2 R4 1 hour approx.
R5
*
L2
soldering iron
Figure 1: This slightly muddled schematic of the MIDI I/O BoB is what you get when you combine
multiple circuits into one configurable circuit.
component list
We already made use of the MAX1000 board in the first part which defines the CPU, achieve this.
of this series [1]. We will now briefly describe how to get a
compiled program into the FPGA. The process of compiling the parameter sCcodeMemAddressWidth=12 ;
C program itself is relatively quick, and results in two files, parameter sCdataMemAddressWidth=10 ;
codemem.txt and datamem.txt. The content of these files must reg [40-1:0] sCcodeMem [0:(1 <<
be loaded, in effect, into the CPU’s memory space, which is sCcodeMemAddressWidth)-1] ;
physically located inside the FPGA.
reg [32-1:0] sCdataMem [0:(1 <<
sCdataMemAddressWidth)-1] ;
The following lines of the Verilog source file sCCCPcpu1v01.v,
initial begin
$readmemh(“CodeMem.txt”,sCcodeMem) ;
$readmemh(“DataMem.txt”,sCdataMem) ;
sC Sourcecode end
experiment1.c Verilog-Code
TopLevel.v
sCCCPcpu1v01.v The first four lines above specify the word size and the number
SFRs.v of words of storage for the code and data memories.
SC Compiler
The lines after ‘initial begin’ specify that the code and data
memories are to be initialized with the contents of the named
files. That means that these files must be available at the time
Quartus
Mem1.java
Synthesis Tool the FPGA code is synthesized. We therefore synthesize the
FPGA design after compiling the C program to generate the
bitstream that is to be loaded into the FPGA. This step is rela-
CPU
Processing sketch
SFRs
tively time-consuming (on the author’s machine it takes about
UploadCode...pde
Memory five minutes) and the synthesis process must be repeated from
scratch after each change to the C source code.
This resynthesis process becomes somewhat tedious after a
Uploader while, and we might wonder if it is possible to load the program
FPGA
and data memory after synthesis has been done. One way to
achieve this is to build an ‘uploader’ into the FPGA design.
Let us look at how this is done. In the working directory of
Figure 1. The uploader can be used to send compiled application experiment5 (available for download at [3]) there is a Quar-
programs to the CPU after the synthesis step: this makes the tus project file (.qpf extension). In order to use the uploader
development cycle much quicker. we need to synthesize this project and load it into the FPGA.
Figure 2. Hardware extension to allow uploading programs over the service interface. For
the time being we will not be using the PWM interface. Connecting peripherals
The CPU that we will use for experiment 5 is
equipped with other functional blocks alongside
the UART used for the service interface. These
The workflow that we will be able to use as a result is illus- include a real-time counter (RTC), a pulsewidth modulator
trated in Figure 1. (PWM), an analog to digital converter, a GPIO port, and, last
A serial interface will be used to send data and program code to but not least, a user UART. The user UART can be connected
the FPGA. So first a few remarks on how that is implemented. to the PMOD2 connector on the MAX1000 board (J6) using the
hardware shown in Figure 3.
Our first hardware extension
The serial interface uses the standard 8N1 protocol at We will now look at how the CPU in the FPGA can be expanded
115200 baud. The hardware shown in Figure 2 is used to using simple peripheral modules. First we will use three pins as
connect the PC’s serial port to the MAX1000 board. If on the general-purpose I/O (GPIOs). In Verilog we do this as follows.
PC side you are lucky enough to have a real serial port, this
hardware can be connected to the 9-pin connector. In that case parameter GPIOINPWIDTH = 3 ;
IC1 is not required (and jumper JP1 can be removed). This wire[GPIOINPWIDTH-1:0] GPIOinp ;
is the setup used by the author with his serial port. Although parameter GPIOOUTPWIDTH = 3 ;
the circuit does not strictly meet the interface standards, it reg[GPIOOUTPWIDTH-1:0] GPIOoutp ;
nevertheless works well.
Many readers may have a USB-to-TTL serial cable, with the To read data from the expansion module the CPU needs to
signal levels inverted with respect to the RS-232 levels. Such execute an INPA c instruction, where c (for ‘channel’) is the
a cable can be connected at K4. To make things even simpler number of the port to which the GPIO peripheral is connected
it is possible to connect the USB-to-TTL cable directly to the in the CPU implementation in the FPGA.
FPGA, but in that case the inversion of the signals must addi-
tionally be implemented inside the FPGA. In Verilog the mechanism is modeled using the variable inpA,
which holds the value that will eventually end up in register R0
Serial service interface as a result of executing the above instruction. The source of
To upload an application program over the ‘service interface’ the data for this variable is selected using a large multiplexer,
requires a small program running on the development PC. The which is implemented as follows.
author implemented this program using Processing [4]. The
program can be downloaded as Processing\UploadCodeViaSe- assign inpA=
rial1v01 at [3], and it can be launched directly from the Pro- (inpAchannel==0) ? { 32’h12341234 } :
cessing development environment. Before running it, however, (inpAchannel==1) ? sCuartRXdata :
it is necessary to modify the line (inpAchannel==2) ? sCTXuartBitsLeft :
(inpAchannel==3) ?{ 20’h12300 , ADCval[12-1:0] } :
String serialPort=”COM3”;
(inpAchannel==4) ? RTCtimer :
(inpAchannel==5) ? debugReg1 :
to suit the COM port that you will be using for communication
(inpAchannel==6) ? aDacSignal :
with the hardware.
GPIOchannel EQU 18
GPIOout(int p){
p ; // ‘calculate’ the value of p and leave it in R0
#asm // now a bit of assembler code
OUTA GPIOchannel // write value in R0 to GPIO channel
#endasm
}
GPIOin(){
#asm // switch to assembler code
INPA GPIOchannel // read value from GPIO channel into R0
#endasm // switch back to C
}
the ‘MAKE’ button will compile the C code. the FPGA: the example here reads values from the three chan-
nels of the LIS3DH acceleration sensor and outputs them over
c.bat: the user serial port at 115200 baud. The results might appear
Java as follows.
-jar c:\SCCCP\CompilerAsJar\sCCCP.jar
-s experiment5.c x= -00000032 y= -00000128 z= +00016576
Web Links
[1] The SCCC Project (1), ElektorLabs magazine 2/2019: www.elektormagazine.com/180394-01
[2] The SCCC Project (2), ElektorLabs magazine 3/2019: www.elektormagazine.com/180394-B-01
[3] Project page for this article: www.elektormagazine.com/180394-C-01
[4] Processing: http://www.processing.org
int GPIOoutShadow ;
#define bitMaskLISsenINT1 1
#define bitMaskLISsenINT2 2
#define bitMaskLISsenSDO 4
#define bitMaskLISsenCS 1
#define bitMaskLISsenSDI 2
#define bitMaskLISsenSPC 4
LISinit(){
GPIOoutShadow= bitMaskLISsenCS | bitMaskLISsenSPC | bitMaskLISsenSDI ;
GPIOout(GPIOoutShadow) ;
}
LSIclockPulse(){
GPIOoutShadow = GPIOoutShadow & (~bitMaskLISsenSPC) ;
GPIOout(GPIOoutShadow) ;
GPIOoutShadow = GPIOoutShadow | bitMaskLISsenSPC ;
GPIOout(GPIOoutShadow) ;
}
SPItxrxByteMSBfirst(int vTX){
int vRX ;
int k ;
int GPIOinp ;
vRX=0 ;
for( k=0 ; k<8 ; k++){
if(vTX & 0x80) {
GPIOoutShadow =GPIOoutShadow | bitMaskLISsenSDI ;
}
else {
GPIOoutShadow =GPIOoutShadow &( ~ bitMaskLISsenSDI );
}
LSIclockPulse() ;
vRX = vRX << 1 ;
GPIOinp=GPIOin() ;
if( GPIOinp & bitMaskLISsenSDO ) { vRX = vRX |1 ; }
vTX=vTX<<1 ;
}
return vRX ;
}
Experiment 5 is one of our more complicated endeavours, as SPI functionality directly in the FPGA, but for our simple and
it involves a disparate range of files, programs and compo- non-time-critical application the bit-banging approach is much
nents. If something fails to work as it should, then the first more straightforward.
things to check are the following: are all the paths specified
in the batch files correctly set to reflect the installation? And In the next installment of this series we will take a look at how
are the COM port numbers and baud rates correctly set for to generate analog signals, with the help of sigma-delta DACs
the serial interfaces? and interrupts. Stay tuned!
When you do have everything up and running you can then (180394-C-02)
take a look at the code in experiment5.c in order to learn how
it goes about outputting data using the user UART.
The code drives the acceleration sensor using a bit-bang-
ing technique. It would also be possible to implement the
TUE/InMotion:
Revolutionary Battery Pack Design
The InMotion student team from the Technical University Eindhoven (TUE) in The Netherlands
is grabbing this space to publicize they’re working on ‘Electric Refuelling’, a concept which aims
to offer a solution to recharge electric cars as fast as you would refuel those with a combustion.
Interesting, right? Let’s see what they’re up to...
The InMotion student team, which I am industry, permitting work at the very tric refuelling by joining the Garage 56
a member of, consists of more than 50 edge of technology. We are working on Class during the 24 Hours of Le Mans
young and ambitious students from the a concept called ‘Electric Refuelling’, race with a fully electric endurance race
Eindhoven University of Technology and which is the ability to charge your car in car in 2023. For this, we need to develop
the Fontys University of Applied Scien- the same amount of time as you would our own custom-made battery pack and
ces. Student teams offer a unique col- refuel a car with a combustion engine. We this is my responsibility for this year. So,
laboration between universities and the intend to showcase the potential of elec- in case you have ever wondered
• how electric vehicles are powered force us into a dilemma. For one, we
• how it’s possible to power a vehicle can aim for a high-capacity battery pack
with cells so small they fit in the that allows you to take more energy with
palm of your hand you and therefore cover longer distances.
Alternatively, we can build a high-po-
then this article is just for you. wer battery pack that’s more suitable
to high-power applications and faster
First things first charging. Since the focus of InMotion is
If ever you wanted to design a battery on developing fast-charging technology,
pack no matter its application, you our battery pack of choice is the latter.
should always clearly define what you So, we are now developing a battery
want in a set of requirements. The four pack with a lower capacity than offered
main requirements are the (minimum, by some commercial vehicles. Still, this
nominal and maximum) voltage, capa- allows us to develop technology that can
city, weight, and power. Furthermore, be used when battery technology has
you should always take safety features improved to a level where high-power
and regulations into account. battery packs provide enough capacity
Current battery technology seems to for commercial applications.
Module
The design variables of a single module
are determined by the free space requi-
red around each cell. With pouch cells the
space above, below and on the sides of
the cells are all parameters that need to
be determined or acquired. These usually
depend on the placement of the tabs and
the type of cooling used.
Pack
With the dimensions of the modules
determined, they’re ready for stacking to
make a pack. This will determine where
Figure 1. An example of a battery cooling pack made by Kokam [1]. cooling lines need to be run, as well as
how the modules need to be connected
electrically inside the pack.
Structure ant decision in the process. It is the defi-
As mentioned before, a battery pack is ning factor in the battery pack’s per-
made up of lots of smaller battery cells. formance. InMotion uses pouch cells Fancy software
Several cells are bundled in a module, because they’re better suited for fast At InMotion the development stage is
and these modules are then configured charging than cylindrical cells. very dynamic. It allows us to change
in a battery pack (see also Figure 1). things on-the-fly. It also means that not
They can take more abuse, usually have all our requirements are set in stone,
Cell a lower internal resistance which in turn and we’re trying to find a set that fits
The cell type is probably the most import- generates less heat, and they have a lar- our goals. The battery pack is a good
Get your
ways. But how to find out which configuration works best?
To avoid having to generate a model for every single con-
figuration, I have made a battery pack configurator that
optimizes the pack for different input parameters. To ensure
TI Chips
ease-of-use and to allow the user to try out different con-
figurations without having to understand the underlying
code, I created a GUI (see Figure 2). It basically takes
at Mouser
all the design variables as input and then tries to fit as
many modules in a given space, stacking them in the same
direction. In the space that’s left, it will once again try to
fit as many modules as possible, even if that means the
orientation of some modules is different than that of others.
The script uses a heuristic method rather than an analytic
approach to this space optimization problem. This is done
because it is easier to write and still reaches local minima.
It is also extremely efficient and fast. On an average PC
the script creates 190 optimal configurations, selects the
best for a given set of preferences, and plots it within
5 seconds. Within this time it also saves all created opti-
mal configurations, allowing them to be filtered for diffe-
rent preferences. If a different configuration turns out to
be better, it’s easily plotted using the GUI.
Achievements
With Electric Refueling we aim to be able to charge an elec-
tric car in just a few minutes. If successful, it will undoub-
tedly accelerate the energy transition from petrol to elec-
tric in the automotive industry. To show the world how
fast electric racing can be, we have created the “Fusion”,
an electric formula car that currently holds the electric lap
records at Circuit Zandvoort, TT Circuit Assen (both in The
Netherlands) and Circuit Zolder (Belgium). Our concept car
“Vision” is the true embodiment of future electric mobility.
It is designed to be 10 times more aerodynamically effi-
cient than a Formula 1 car. It is truly the endurance racer
of our dreams.
180732
Mouser is an authorised distributor with the largest
selection of Texas Instruments’ chips in stock
mouser.co.uk/ti
Web links
[1] Website for Kokam: http://kokam.com/modulepack
[2] InMotion website: www.inmotion.tue.nl/
This project shows the simplicity and ease of measuring analogue values with an ESP32 board and to send
the values via Wi-Fi to a router, and from there, to the ThingSpeak website where the data are saved and
displayed.
At the moment, Laurent is working on available, the author used two exter- The analogue/digital converted of the
several projects powered with solar nal batteries (powerbanks), one small ESP32 is equipped with an internal atten-
energy. He was looking, amongst other (1000 mAh) and one large (10,000 mAh). uator which may be set by the Arduino
things, to develop a solar power source The smaller is connected permanently to sketch with the function analogSetAt-
for his Nixie watch [1]. By its nature, power the ESP32 board. It is recharged tenuation to one of the following val-
solar radiation is not dependable, so it by the larger one which is replaced ues: 0 dB, −2.5 dB, −6 dB or −11 dB;
may take some hours or even days to almost every day so that the system is corresponding to factors of 1 ; 0.75 ;
test a power supply model. He developed always working. If only a single battery 0.5 or 0.28.
three different modules, each charging was used, measurements would be lost By default, the full scale voltage of the
three identical small batteries (130 mAh) during the recharge of the battery pow- ADC is 1.1 V. This voltage is the max-
with a resistor to simulate the power ering the ESP32. imum that can be read (as a function
drawn by the watch. Then he read the of the number of bits configured for
battery voltage on the three modules and Three I/O pins of the ESP32 (Figure 1) ADC1: 4095 for 12 bits, 2047 for 11 bits,
sent them to the free ThingSpeak plat- are used to take the measurement sof 1023 for 10 bits, 511 for 9 bits). To
form [2] for the Internet of Things (IoT). the three channels/batteries. Each pin read higher voltages (up to the max-
has its own voltage divider and a 100 nF imum voltage for the pin, generally
Measurements filter capacitor. In the sketch, this attenu- 3.3 V = Vdd), an attenuation greater
The measurements are taken by an ation is represented by the variable Coef_ than 0 dB must be set for the ADC chan-
ESP32-PICO-KIT-V4 development board Vx and its value may be adjusted to com- nel in use. Table 1 sets out the the
powered by USB (5 V). As the device pensate for tolerances in the external settings and the ranges which can be
is used outside, with no mains power voltage divider. used. For an attenuation of −11 dB, the
576k
FSD2 FCLK ESP32-PICO-KIT
1% 100n FSVP IO21
ThingSpeak Wi-Fi
FSVN IO22
MOD1
IO25 IO19
R3 1%
IO26 IO23 Æ entry level
V2 1M1
intermediate level
IO32 IO18
R4 C2
IO33 IO5 expert level
576k
IO27 EN IO10
1% 100n
IO14 IO9
IO12 RXD0
IO13 TXD0
2 hours approx.
R6 1% LED1
BOOT
V3 1M1 IO15 IO35
C3 IO2 IO34
R7
576k
1k
3V3 EN
GND GND
5V 3V3
USB
170500-013
€15 / £12 / S18 approx.
Figure 1. Circuit diagram: the ESP32 board takes care of most of the work.
maximum voltage is limited by VDD_A, Speak for a weather station project. So then create an account (Figure 2). Then
and not by the full scale voltage. he naturally opened a page there to store click on Connexion to access your account
The circuit was designed to monitor the measurements taken for his watch and fill in your ID information. Then cre-
LiPo batteries at 4.2 V and the analogue batteries (see [3]).. ate an account where the Battery Moni-
inputs are calculated to support a maxi- ThingSpeak is a free web service with tor data will be collected (New Channel),
mum input voltage of 5 V. with a voltage open source code, which allows you to give your channel a logical name which
divider using resistors of 1.1 MΩ and gather and store in the cloud data from will be easily recognised as your battery
576 kΩ, the inputs of the ESP32 board sensors, and develop applications for monitor data. In the Channel Settings,
are specified for a voltage of ±1720 mV the Internet of Things. Sensor data can add three fields to sort the data which
for a voltage input of 5 V, which is the be sent to ThingSpeak from Arduino, the Arduino sketch will send in the form
maximum input voltage recommended Raspberry Pi, BeagleBone Black and of strings and label them (in our case V1,
for and attenuation of −6 dB.Of course, similar boards. V2 and V3 as in Figure 3). Now choose
you can modify the input circuit if you Also, it is possible to use functions from the API keys tab, here you will find the
need a different input voltage range, and/ various MATLAB (from MathWorks) tool- Write API key which you must copy into
or change the internal attenuation of the boxes on a ThingSpeak connection. For the sketch of the ESP32 board to iden-
ADC of the ESP32 board. that it is necessary to be connected with tify the ThingSpeak channel(Figure 4).
a MathWorks account with an active
Note: you can only apply DC voltages licence in order to use these toolboxes. Battery Monitor Sketch
to the inputs which are within the range If you’re starting this project and you The Battery_monitor_elektor_3.ino
defined by the settings of the ADC. In don’t yet have a ThingSpeak or Math- sketch written in C is not very compli-
addition, there is no protection against Works account, Go to www.thingspeak. cated, but before compiling it and upload-
reverse polarity or overvoltages! com and click Get Started For Free, ing it to the ESP32 board, you need to
Pin GPIO17 of the ESP32 board drives a
LED which lights during voltage measure-
ments and data transmission. Then the
LED goes off and the ESP32 board goes Table 1. Theoretical full scale of the ADC and actual full scale available, as
into sleep mode until it automatically a function of attenuation settings if VDD_A = 3.3 V
wakes up for the next measurements. Theoretical Actual range for the most
ADC Attenuation
This minimises energy consumption from full scale accurate results
the external batteries. 0 dB (ADC_ATTEN_DB_0) 1.1 V 100 - 950 mV
You can easily wire up the circuit on a 2.5 dB (ADC_ATTEN_DB_2_5) 1.5 V 100 - 1250 mV
breadboard or a piece of stripboard.
6 dB (ADC_ATTEN_DB_6) 2.2 V 150 - 1750 mV
11 dB (ADC_ATTEN_DB_11) 3.9 V 150 - 2450 mV
Create a ThingSpeak account
Laurent uses the online platform Thing- (Source : https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/adc.html#adc-calibration)
modify it so that the board connects to in the Tools menu. Make sure that the until now).
you Wi-Fi network and sends the data transmission speed of the monitor is set Then the ESP32 board (re)connects to
to your ThingSpeak channel. to 115200 and you should receive a mes- you Wi-Fi network and shows that the
On line 68 of the sketch, enter the Write sage from the ESP32: Battery monitor connection is successful with the IP
API key that you got from the Thing- V1.0 Start followed by the first three address of the ESP32, or sends the mes-
Speak site to identify your channel. voltage measurements. sage WiFi cannot connect if the attempt
Then enter the SSID and the password After each measurement cycle the ESP32 fails.
for your local area network in lines 70 passes into sleep mode. Boot number: x You can set the measurement interval
and 71 respectively. Then upload the indicates how many cycles have run since by modifying TIME_TO_SLEEP on line 45.
sketch to the ESP32 board and open the beginning of the session (i.e. how Note that only the setup function is
the serial monitor of the Arduino IDE many measurements have been made executed, it performs all the process-
Figure 3. Channel settings on ThingSpeak. Figure 4. API key to recopy into the sketch.
Web links
[1] Elektor Labs Nixie watch page: www.elektormagazine.com/labs/nixie-watch-1
[2] ThingSpeak Platform: www.thingspeak.com
[3] ThingSpeak battery monitor public page: http://thingspeak.com/channels/329068
[4] Installation of ESP32 boards in Arduino IDE:
http://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions
[5] Elektor Labs Battery monitor page: www.elektormagazine.com/labs/simple-wifi-multimeter
[6] Article support page: www.elektormagazine.com/170500-02
Advertisement
GREEN
MEMBERSHIP
✔ 6x ElektorLabs
Magazine (PDF)
✔ 3x Elektor Indu
stry Magazine
(PDF)
✔ Exclusive Offer
www.elektor.com/member
s
L1 R2
100
JP2
C3 C5 C7
+12V
100n 47 100n
16V
GND
LED1
C8
–12V
JP1 1
IN+
6
100n
OUT+ R3
+5V C1 C2 DC1 100
5
COM R4
GND 47 100n IH0512S 100
16V R1 2 4 JP3
IN– OUT– C9
1k
+12V
100n
GND
C4 C6 C10
LED1 = HSMR-C150
–12V
L1,L2 = Ferrit 1.000 @ 100MHz 100n 47 100n
R5
L2 16V
100
180177-010
Figure 1. Schematic of the power supply circuit, equipped for two probes. Figure 2. PCB layout and component placement.
Web Links
[1] Rosenkränzer, Alfred: A Simple Current Sensor Probe, Elektor July/August 2016: www.elektormagazine.com/150182
[2] 2W DC-DC Converter IH0512S: www.xppower.com/Portals/0/pdfs/SF_IH.pdf
[3] Project page: www.elektormagazine.com/180177-02
Occasionally it may be useful to visualize a continuous stream of data arriving through a serial connection as
a web page in a browser. But how do you go about? May we suggest a bit of scripting?
Basically, the problem boils down to periodically creating a it every ten seconds (the timeout can, of course, be another
webpage containing the latest serial data. A web browser then value). If we rewrite the page every ten seconds and put fresh
can display the page, be it on the same computer or over a serial data into it, then the browser will show it too.
network. Therefore, what is needed is a small program that
continuously converts the serial data into for instance HTML or Split the task in two
PHP files. Aha! Isn’t PHP a programming language for Inter- It is also possible to put the refresh tag in a PHP file instead of
net related applications? Yes, it is. So, can we use PHP to get an HTML file and the browser will do the same thing. The PHP
the job done? Yes, we can. But there are other ways too, as file then could also contain a script to read the data from the
we will see. serial port. This is the point where things become complicated
because PHP doesn’t natively support serial ports. And even
Use automatic page refresh if it did, it would mean that every time the browser requests
It all starts by remembering that HTML allows the use of a meta the (latest version of the) page, the script would have to open
tag that instructs the browser to reload a page periodically: the serial port, get some data and close the port again. Data
received outside this window is lost. Furthermore, some Ardu-
<meta http-equiv="refresh" content="10"> ino-like systems may reset when the serial port is opened,
making the setup useless. A solution to this is to split the pro-
This tag tells the browser to reload the page containing the cess in two subprocesses:
tag every ten seconds. (In case your browser does not sup-
port this tag, it can be replaced by a piece of JavaScript. See • Process 1: A script to continuously read the serial port and
download at [1]) If we create a web page that includes this update a data file that is imported by the PHP webpage
tag and point the browser to it, the latter will keep reloading (Listing 1);
include “php_serial.class2.php”;
$serial = new phpSerial;
$serial->deviceSet($comPort);
// On Windows (10 only?) all mode settings must be done in one go.
$cmd = “mode “ . $comPort . “ baud=115200 parity=n data=8 stop=1 to=off xon=off”;
$serial->_exec($cmd);
$serial->deviceOpen();
while(1)
{
$read = $serial->readPort();
if (strlen($read)!=0)
{
$fp = fopen(“data.txt”,”w”);
if ($fp!=false)
{
fwrite($fp,trim($read));
fclose($fp);
}
}
}
?>
<?php
// Table begin.
echo “<table border=’1’ border-spacing=’5’ style=’text-align:center;’>”;
echo “<tr><th>ID</th><th>Value</th></tr>”;
foreach ($numbers as $x => $x_value)
{
echo “<tr>”; // Table row begin.
echo “<td>”, $x, “</td>”; // Table column 1.
echo “<td>”; // Table column 2 begin.
if ($x_value>=500) echo “<font color=’green’>”;
else echo “<font color=’red’>”;
echo $x_value;
echo “</font></td>”; // Table column 2 end.
echo “</tr>”; // Table row end.
}
// Table end.
echo “</table>”;
}
}
echo “</body>”; // Body end.
echo “</html>”; // Page end.
?>
Sounding off
In this article we presented a method of displaying serial data
in a web browser. The method is neither new, exclusive, or
"the best". If you know of another way — simpler, more ele-
gant, whatever — please share it with us [1]. And, of course,
you don’t need Python to write the script, feel free to use any
programming language capable of doing serial communications
and writing files. The advantage of using Python with pySerial
is that it will run on Windows, macOS, and Linux machines
(and more).
The code developed for this article in the shape of PHP and
Python scripts, and an Arduino sketch can be downloaded
from [1].
(170111-01)
Web Links
[1] Downloads for this article:
www.elektormagazine.com/170111-01
[2] PHP Serial: https://github.com/Xowap/PHP-Serial
[3] pySerial: https://pypi.org/project/pyserial/
Figure 3: This Arduino sketch generates a serial data stream that can be
used for script development, debugging, and testing.
def write_page(data_list):
fo = open(file_name,”w+”)
# Start of HTML page.
fo.write(“<!DOCTYPE HTML PUBLIC ‘-//W3C//DTD HTML 4.01//EN’ ‘http://www.w3.org/TR/html4/strict.dtd’>”)
fo.write(“<html><head><title>”+page_title+”</title>”) # Page & Head begin.
fo.write(“<meta http-equiv=’refresh’ content=’1’>”)
fo.write(“<meta http-equiv=’Content-Type’ content=’text/html; charset=UTF-8’>”)
fo.write(“<link rel=’shortcut icon’ href=’favicon.ico’ />”)
fo.write(“<link rel=’icon’ type=’image/x-icon’ href=’favicon.ico’ />”)
fo.write(“<link rel=’icon’ type=’image/png’ href=’favicon.png’ />”)
fo.write(“</head><body><center><p>”+page_title+”</p>”) # Head end, body begin.
# Table begin.
fo.write(“<table border=’1’ border-spacing=’5’ style=’text-align:center;’>”)
fo.write(“<tr><th>ID</th><th>Value</th></tr>”)
for i in range(0,len(data_list),2):
fo.write(“<tr>”) # Table row begin.
fo.write(“<td>”+data_list[i]+”</td>”) # Table column 1.
fo.write(“<td>”) # Table column 2 begin.
fo.write(“<font color=’”)
# Values >= 500 will be printed in green, smaller values will be red.
if (int(data_list[i+1])>=500): fo.write(“green”)
else: fo.write(“red”)
fo.write(“’>”)
fo.write(data_list[i+1])
fo.write(“</font></td>”) # Table column 2 end.
fo.write(“</tr>”) # Table row end.
fo.write(“</table>”) # Table end.
fo.write(“</body>”) # Body end.
fo.write(“</html>”) # Page end.
# Done, close file.
fo.close()
while 1:
data_str = s.readline().decode() # Read data & convert bytes to string type.
# Clean up input data.
# Expected format: “$,id1,value1,id2,value2,...,CRLF”
data_str = data_str.replace(‘ ‘,’’) # Remove whitespace.
data_str = data_str.replace(‘\r’,’’) # Remove return.
data_str = data_str.replace(‘\n’,’’) # Remove new line.
data_str += ‘123,65,1,999,cpv,236’ # Add some more data
print(data_str)
# Split data in fields separated by ‘,’.
data_list = data_str.split(“,”)
del data_list[0] # Remove ‘$’
# Write HTML page.
write_page(data_list)
9k09
3k3
By Bram Melse, MSc. (The Netherlands) 1
T2
2
A flashing LED? What is so special about that, you
may well ask yourself. A microcontroller plus a BC177 R3
+
5k6
handful of discrete parts, and Bob’s your uncle – C1
15 VDC T1
R2 R5
that is built entirely from discrete parts and hopefully
LED
47R
330R
triggers your own experimentation! D1
The author has kept himself busy professionally with the design Figure 1: The schematic counts only a few parts. The transistors are not
of (mainly) analogue chips. But to prove that you don’t always critical; just about any TUP and TUN should suffice.
have to use an IC, and also because it is sometimes just fun to
figure out an analogue circuit, he presents here a flashing LED
that needs no more than a couple of transistors and a handful
of small parts. The result is drawn in Figure 1. Audio variant
The operation of the circuit is best described as follows. For If you have an appetite for that, you can also build an audio
convenience we start with the situation where the voltage at variant of this circuit. The circuit remains practically the same;
node 1 is relatively low. A current flows towards node 3 via R3 only the component values need to be changed as follows:
and R4 (and therefore also R2), but the current is not large • Resistors: R1 = 3k9; R2 = 180 Ω; R3 = 2k7; R4 = 1k8;
enough to turn T1 on. R5 = 15 Ω.
Capacitor C1 is continually being charged through resistor R1; • Capacitor: C1 = 0.2 µF.
once R1 (via T2) also starts to supply current towards node 3, • Transistors: T1 = BC109C; T2 = BC240B (not critical, any
the sum of the currents becomes large enough for T1 to turn TUP and TUN will do).
on. The voltage at node 2 will be pulled low and the circuit • The loudspeaker (8 Ω) is connected between C1 and
locks itself in this state (functions as a latch). ground; the LED is omitted.
The current towards node 3, via resistor R3, now stops, but
instead capacitor C1 is discharged (via T2) and the LED lights This variant generates a (somewhat objectionable) sound with
up brightly. As C1 discharges, the current through T2 towards a frequency of about 1 kHz. However that would be perfectly
node 3 diminishes until it is no more than what is supplied via suitable for alarm applications.
R1, and that is not enough to keep T1 turned on. Node 2 will The construction of the circuit is not very critical; a small piece
now be pulled high by R4, which turns T2 off. At this instant of prototyping board is more than sufficient.
the entire cycle begins again. (180542-02)
Resistor R5 has an important function as a bypass: without this
resistor, the LED would cause a threshold voltage that is too
high for T1 to turn on, with the consequence that the latching
action doesn’t happen. The bypass current amounts to about
10% of the LED current.
Note that the LED flashes very brightly (with the component @ www.elektor.com
values indicated, at a rate of about 0.8 Hz); a simulation (in
ªBook, Electronic Circuits for All
LTspice XVII) indicated a value of about 600 mA. Of course www.elektor.com/electronic-circuits-for-all
it is not ideal when the capacitor is discharged only through
ªBook, The Art of Electronics, part 1 (analoue electronics)
the transistors and the LED; you can experiment here with a www.elektor.com/the-art-of-electronics-3rd-edition
current-limiting resistor (which, by the way, will also increase
the duration of the flash).
Tsunami of Light
Researchers at Chalmers University of Technology and the
University of Gothenburg, Sweden, have proposed a way to
create a completely new source of radiation. Ultra-intense
light pulses consist of the motion of a single wave and can be
described as a tsunami of light. The strong wave can be used
to study interactions between matter and light in a unique
way. Their research is now published in the scientific journal
Physical Review Letters.
“This source of radiation lets us look at reality through a new tific landscape of light sources.” says Tünde Fülöp.
angle — it is like twisting a mirror and discovering something Read the scientific paper Electron beam driven generation of
completely different,” says Illia Thiele, a theoretical physicist frequency-tunable isolated relativistic sub-cycle pulses in Phy-
at Chalmers University of Technology. sical Review Letters [1].
Together with Dr Evangelos Siminos at the University of Gothen-
burg, and Tünde Fülöp, Professor of Physics at Chalmers, Illia A more detailed description of the new method
Thiele now presents a theoretical method for creating the fastest for creating ultra-intense light pulses
possible single wave motion. This kind of radiation has never The researchers propose a method for the generation of ult-
yet been observed in the universe or even the lab. ra-intense light pulses containing less than a single oscillation
The radiation source is interesting for understanding the pro- of the electromagnetic field. These so-called sub-cycle pulses
perties of different materials. Since it offers an ultra-fast swit- can be used to probe and control matter in unique ways. Con-
ching of light matter interactions, it can be useful in material ventional methods can only produce sub-cycle pulses of limited
science, or sensor related research, for example. Moreover, field strength: above a certain threshold the amplifying medium
it can be used as a driver for other types of radiation, and to would be ionized by the intense fields. The researchers propose
push the limits of how short a light pulse could be. to use an electron beam in a plasma, which is not subject to a
“An ultra-intense pulse is like a great tsunami of light. The wave damage threshold, as an amplifying medium for a seed electro-
can pull an electron out of an atom, accelerating it to almost magnetic pulse. To ensure that energy is transferred from the
the speed of light, creating exotic quantum states. This is the electron beam to the pulse in such a way that a sub-cycle pulse
fastest and strongest switch possible, and it paves the way is produced, the beam needs to be introduced at an appropriate
for advances in fundamental research,” says Dr Illia Thiele. phase of the oscillation of the electromagnetic field. This can
The new pulses can be used to probe and control matter in unique be achieved by using a mirror to reflect the seed pulse while
ways. While other light pulses, with multiple wave periods, impose the electron beam is being injected. This scenario leads to sig-
changes in the material properties gradually, pulses with a single nificant amplification of the seed pulse and the formation of an
strong wave period cause sudden and unexpected reactions. intense, isolated, sub-cycle pulse. Readily available terahertz
Researchers worldwide have tried to create this source of radi- seed pulses and electron bunches from laser-plasma accelera-
ation, since it is of high interest for the scientific communities tors could generate mid-infrared sub-cycle pulses with millijou-
within physics and material science. le-level energies, which are highly desirable as probes of matter
“Now, we hope to be able to bring our theoretical setup to the but not possible to produce with conventional sources.
lab. Our method could help close the existing gaps in the scien- 190252-01
Weblink
[1] Electron Beam Driven Generation of Frequency-Tunable Isolated Relativistic Subcycle Pulses :
https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.122.104803
In software development, the client usually supplies a spec- version, you can even build applications that don’t use open
ification sheet — listing what functions the software should source code — it is advisable to study the terms of the license
perform in the finished product. In this case, the instructions agreement for Qt more closely. The commercial Qt license
from the editorial board here at Elektor was pretty basic — includes additional tools useful for embedded applications.
“Make it so…”
Fair enough but before any work can begin it’s always helpful Qt
to get a basic specification of what expected from the software. Qt [2] is a cross-platform framework that can be used to create
It turned out that what was needed was a Linux application applications in C ++/QML that ideally run on multiple platforms
running on a Raspberry Pi to provide control for some FM radio based on common code. This includes the usual suspects such
hardware and also to display RDS information if it is available as Windows, Linux, Android, iOS, QNX and some embedded
in the received signal. It goes without saying that it needs to Linux variants. Using this framework saves work in a number
be finished by… yesterday. of places since you don’t have to bother about the peculiar-
At this point, I chose to implement the project using the Qt ities of different operating systems. In addition to the many
framework [2]. Qt is available under a dual-licensing model, as other libraries available in the framework, those designed for
the source code will be open source, I did not need to decide GUI use are especially helpful for speedy code development.
between GPL and commercial versions of Qt. Using the GPL What is generally true of the framework is also applicable to
Web Links
[1] FM Radio with RDS, Elektor 1 / 2019: www.elektormagazine.com/magazine/elektor-70/42360
[2] Qt framework: www.qt.io
[3] Qt manual (PDF, 41 pages): https://github.com/ElektorLabs/160520-QT-compile-and-install-manual
This is where
your start-up
meets the future
Where? Paris Expo Porte de Versailles
Go to:
Participants and winners of the Fast Forward electronica 2018 contest. www.elektormagazine.fr/escparis2019
The winner will automatically participate in the electronica contest in The Jury at work, headed by Clemens Valens from Elektor Labs.
Munich next year.
Note:
The final date of entry is fixed at
Wednesday 31st July 2019.
In case of a high number of applications, it is possible that
the limited number of places will cause us to bring forward
the closing date for entries. So don’t wait to go to
www.elektormagazine.fr/escparis2019 to enter.
190232-02
10k
1
Upgrading the CPLD board: With XO1
270
4
VCC OE 1
C15 C16 C17 C18 C19
an MAX10M08 CPLD as the core C1 C2 C3 C4
3
22 22 22 22 22
10u 100n 22 100n FO 10V 10V 10V 10V 10V
component, the board not only 25V 10V LED2
R4 R3
GND
100
50
provides more logic elements XO91SMD 2
CLK disable
10k
28
CLK1N
29 33
implementable microcontrollers. CLK1P PLL_L_CLKOUTP
+VCC
30 10M08SAE144 31
+VCC VREFB2N0 VCCIO2
BANK 2
R10
R11
R7
R8
R9
+VCC JTAG
1k
10k
10k
10k
10k
2
15
JTAGEN 21
DIFFIO_RX_L14N
4
C22 16
TMS 22
DIFFIO_RX_L14P
6
18
TCK 24
100n DIFFIO_RX_L16N
8
19
TDI 25 RX_L16P
DIFFIO_RX_L16P
10
20
TDO
In the May & June 2018 issue of Elektor
RX_L1N 6 11 RX_L5N
magazine the author presented a board RX_L1P 7
DIFFIO_RX_L1N/ADC1IN1 DIFFIO_RX_L5N/ADC1IN5
DIFFIO_RX_L1P/ADC1IN2 DIFFIO_RX_L5P/ADC1IN6
12 RX_L5P
42 TX_RX_B7N 46 59 TX_RX_B16N
can be built with 570 LEs, you have to MC1525TT
2V5
GND@1
53 TX_RX_B7P 47
DIFFIO_TX_RX_B7N DIFFIO_TX_RX_B16N
60 TX_RX_B16P
GND@2 DIFFIO_TX_RX_B7P DIFFIO_TX_RX_B16P
switch to a different CPLD family if that 1 IC3 2 5
ADC_VREF GND@3
63
40 +VCC
68 48 10M08SAE144 VCCIO3_1
is not enough. As the MAX V family only 3
GND@4
83
VREFB3N0
BANK 3 VCCIO3_2
49
3 ANA_IN1 GND@5
offers a few extra features compared to C20 C21
R6
GND@6
95
104
10k
0
JP1
supply with an integrated 3.3-V LDO vol-
1 2
C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 RX_L5P
?
R14 3 4 tage regulator (only single power sup-
100n 100n 100n 100n 100n 100n 100n 100n 100n 100n
RX_L5N
?
R15 5 6
ply is possible with the selected device),
RX_L3P R16 7 8 R28 RX_L3N
? ?
9 10 RX_L1P several flash memory block sizes, ana-
RX_L1N R17 11 12 RX_T26N
RX_T26P
?
R18 13 14
log to digital converters (ADCs), tempe-
?
RX_T23N
?
R19 15 16 RX_T22N rature sensors, dual configuration flash
17 18 RX_T22P
RX_T20N R20 19 20
(two dynamically usable images on the
RX_R1P 75 85 RX_R10P ?
RX_R1N 77
DIFFIO_RX_R1P DIFFIO_RX_R10P
87 RX_R10N
RX_T19N 21 22 RX_T20P same device), and much more.
DIFFIO_RX_R1N DIFFIO_RX_R10N RX_T19P R21 23 24 BOOT_SEL
?
RX_R2P 74 25 26 RX_T18P
DIFFIO_RX_R2P 84 RX_R11P
RX_R2N 76
DIFFIO_RX_R2N
DIFFIO_RX_R11P
DIFFIO_RX_R11N
86 RX_R11N
RX_T10N
?
R22 27 28 R29
?
RX_T16P
From CPLD to FPGA
RX_T10P R23 29 30
?
RX_R7N 79
DIFFIO_RX_R7P RX_T6P
?
R24 31 32 RX_T4N In addition to pure CPLD functions, the
RX_R7N 81 78
DIFFIO_RX_R7N IO_78 RX_T1N
?
R25 33 34
MAX 10 family has fully operable FPGA
+VCC RX_R33N R26 35 36 RX_T1P
80 10M08SAE144 82 ?
VREFB5N0
BANK 5
VCCIO5 RX_R33P
?
R27 37 38 RX_R28N functions such as up to four internal
39 40 RX_R27N
PLLs for generation of higher clock fre-
+VCC +5V
RX_R14P 88
DIFFIO_RX_R14P/CLK2P R30 R31
quencies, implementable (NIOS) micro-
RX_R14N 89
DIFFIO_RX_R14N/CLK2N
DIFFIO_RX_R27P
99 RX_R27P controllers, digital signal processing
0
Figure 2: Pin assignments of the three connectors on the CPLD board and the Raspberry Pi GPIO connector.
rence for the A/D converter integrated can be plugged into a breadboard or for comparison. Adjacent pairs of pins,
in the CPLD (bank 1A). used with a stripboard like a large DIL each marked with the same background
The prototype is fitted with a type 10M08 IC, the key consideration is that both colour, form differential inputs or out-
device, which has 8 K logic elements of the long pin/socket headers have the puts. They can also be used in single-en-
(LEs), one PLL and one A/D conver- same pin assignments as the 2×20- ded mode, just like the pins without a
ter. However, the board is suitable for way GPIO connector of the Raspberry background colour.
all members of the MAX 10 family with Pi (type 2 or later), so that they can be
2 K to 50 K LEs, as long as they are plugged directly onto the Raspberry Pi. Combinations
housed in an EQFP-144 package. The This way the processing power and PC This creates a variety of options. As
board layout has four layers to ensure interfaces of the Raspberry Pi can be shown in Figure 3, the board can be fit-
reliable operation even at relatively high combined with the hardware capabili- ted directly on a Raspberry Pi (the moun-
clock frequencies. ties of an advanced CPLD. The pinouts ting holes also match). Connector JP1
As with the previous version, not all pos- of the three connectors (with the CPLD is mounted on the bottom of the board
sible I/Os are fed out to the connectors, pins) are shown in Figure 2, along with as a socket header and mates with the
and for good reason. Although the board the Raspberry Pi GPIO connector pinout GPIO connector of the Raspberry Pi. The
Figure 3: The CPLD board mounted on top of a Raspberry Pi 3 Model B+. The mounting holes also match.
Web links
[1] CPLD Breakout Board in DIL Format, Elektor May & June 2018: www.elektormagazine.com/160425
[2] MAX 10 family overview: www.intel.com/content/www/us/en/products/programmable/fpga/max-10.html
[3] Resources for the MAX 10 family:
www.intel.com/content/www/us/en/programmable/products/fpga/max-series/max-10/support.html
Waterflow
Monitor
with ESP32
with text/SMS alert
of leaks
By Denis Lafourcade (France)
Prevention is better than cure! which include an alert if a water leak is tions to oversee my water consumption.
Everything that happens downstream of suspected. But the deployment of these By chance many water meters, mine in
your water meter is your responsibility. systems is slow, and most communities particular, are equipped with counter
In case of leaks, the extra consumption have not got them yet. But some water wheels. The units wheel has a magnet
is for your account, and it can cost you meters are equipped with a pulse trans- attached on the zero digit, allowing you
dearly: mitter which sends a pulse for each litre to detect each revolution, which generally
used, and some meters can be retro- corresponds to a litre of use. There are
• a dripping tap: 4 l/h, that’s 35 m3 fitted with the transmitter. The system on the market pulse transmitters (Fig-
per year, over €100; presented here uses this possibility and ure 1) which clip onto the meter and
• a leaking toilet flush: 25 l/h, that’s allows you to keep a permanent monitor produce a signal over radio or wires for
220 m3 per year, nearly €1000; on your water consumption. each passing of the magnet past a Hall
• a leak in the buried pipes between Over a few months, three of my neigh- effect detector. These transmitters are
the meter and your house: sev- bours here in France discovered, after powered by a Lithium battery with a life
eral m3 per hour, several thousand a receipt of their water bill, that they had of around 15 years, so they don’t need
week! a leak between their meter and their an external power source.
house. The leak was undetectable for
These figures will obviously depend on several weeks, entailing a huge over- Wired or wireless?
the country you live in and your cost of consumption and a bill of several thou- I first looked at the transmission of infor-
water. sand euros! mation between the transmitter and the
The water companies have started to Wishing to avoid such a disagreeable intelligent part of the system. The wire-
install remote meter reading systems, situation myself, I set out to find solu- less pulse transmitter seemed attractive,
GPIO36 GPIO39
GPIO25 GPIO16
GPIO26 GPIO4
GPIO8 GPIO0
GPIO11 GPIO2
GPIO7 GPIO14
GPIO6 GPIO12
GPIO13
R1 GPIO15
3V3 GPIO3
GPIO1 Li-ion battery pack 3,7 V
2k2
C1
3V3
1 µF
GND
GND
Pulse generator
at water meter 5 V GND
Battery charger
V in
USB supply
but unfortunately the protocol used is • web server for remote viewing and WROOM-32 System-on-Chip (SoC) and
not published, and in spite of consider- control; a 128 × 64 pixels OLED screen (connec-
able research, I was not able to find any • Text (SMS) alerting system. tions in Figure 3). This board is avail-
useful information on the subject. If you able in several version on the Internet,
have any better knowledge, please let Electronic construction for a few dollars, and also in the Elektor
me know. As my water meter and my These specifications led to the archi- Store. The ESP32 has WiFi and sufficient
telephone line entry are in close prox- tecture illustrated in Figure 2. The memory capacity for practical applica-
imity, I was able to pull a 1-pair cable heart of the circuit is a Lolin module tions. As well as this, it is compatible with
between the transmitter and the inte- made by WeMos, consisting of an ESP- the Arduino IDE, which makes it partic-
rior of my house through the telephone
cable conduit. For other installations, if
the provider has left the telephone cable
in place after the installation of an optical
fibre, I used one pair of that cable and
avoided having to run a new one.
General principles
Before designing the system, it’s nec-
essary to set down the specifications:
ularly simple to use. Power is secured The pulses from the transmitter are of setup() and a main loop loop() . The
with a Li-Ion battery with a 5 V charger open-collector type, with a ground pulse IRAM_ATTR handleInterrupt() handles
from a micro-USB socket. This charger for every litre consumed. Acquiring these the interrupt triggered by the grounding
(Figure 4) is designed for Li-Ion batter- pulses is very simple: a pullup resistor of the data line connected to GPIO 25,
ies and maintains the charge level and between the data line and the 3.3 V pin and its only task is to increment the value
protects against excessive discharge and on the board, and a 1-µF capacitor to fil- of the counter for litres consumed. Soft-
overcharging. It is available from several ter out any interference on the line. The ware filtering takes care of any “bounce”
Internet sites (Search “3.7V Li-ion Bat- data line is connected to pin GPIO 25 of on the line.
tery Mini USB To USB A Power Supply the ESP32, and the earth line to the GND
Module”). In the case of mains power pin. The connection of these two wires, The main loop takes care of the follow-
failure, the battery can power the sys- the resistor and the capacitor, is made ing operations.
tem for at least 36 hours. on a piece of stripboard soldered on the
male pins of the module (Figure 5). • Display on the OLED screen
The OLEDDisplayUi library allows us to
Software implement simply a very elegant display:
The heart of the system is of course the three pages are defined and they cycle
software (available on the article page every five seconds (Figure 6). The first
[2]). Here again, it is not necessary to page displays the date (the time is dis-
reinvent the wheel, because many exam- played at the top right of all three pages),
ples already exist and are made available today’s consumption and the leak detec-
by the community of “makers”. tion status. The second page shows the
The following libraries provide most of value of the counter, the value of the last
the services that we need: reading and the consumption since then.
• Wifi, ESPmDNS, WiFiUdp and Arduino The third page gives the status of the
OTA for Wi-Fi access and wireless WiFi connection and the IP address used.
software updating;
• TimeLib for time setting by NTP • Web Server
(Network Time Protocol); The server listens on a port defined
• ESP32WebServer and WiFiClient for during the initialisation, and you must
the web server; thus ensure redirection on your router.
• Wire, SSD1306 and OLEDDisplayUi to When a user connects through a browser,
drive the OLED display; the server presents one page with three
• and of course the power and func- tabs (Figure 7). The Visualisation
tionality of the ESP32 Arduino Core. (Overview) tab, refreshed every 5 sec-
onds, shows, in addition to the informa-
After the inclusion of all these libraries tion shown on the OLED display, an hour-
and the definition of the structures and by-hour table of consumption over the
constants of the program, we find the last 24 hours. The Saisie (Setup) tab
classic Arduino program architecture, allows the user to define various parame-
Figure 6. the three pages of the OLED screen. that is to say an initialisation routine ters: the initial value of the counter, offi-
Assembly
A 3D printed case was specifically
designed for containing the system
(Figures 8 and 9). Openings have been
placed for the OLED screen, cooling the
SOC, and for the WiFi antenna. A cut-out
Conclusion
The manual reading of our meters every
six months shows a difference with this
system of only a few litres, for consump-
tion of 50 m3 (= 50 000 litres) which is
perfectly satisfactory. several alerts were
triggered and allowed early detection of
leaks before they became serious.
I have installed several of these sys-
tems for my neighbours, and all of them
reported that they used them profitably
to monitor their consumption and even
optimise it by noting the consumption
for a shower, washing machine, dish-
washer, refilling the pool, etc. This is
another interesting application not orig-
inally foreseen! Please share your own
experiences!
(180694-02)
Web Links
[1] The Project at Elektor Labs:
www.elektormagazine.com/labs/waterflow-monitor
[2] Article page: www.elektormagazine.com/180694-02
Web Links
[1] TL431 / TL432 datasheets: www.ti.com/lit/ds/symlink/tl431.pdf
[2] TL431 reverse engineered: www.righto.com/2014/05
[3] TL431 as an amplifier: www.techlib.com/electronics/crystal.html#AudioAmp
an average PoW time of 300 ms, which is not only faster than an VMCCCSBYYXNDEBHJYNEZAM9IXRYFWNYKWFDJCOOYPNAZQMEUJBPZFMPUKOAQK9QIRGFDWYXSTXMNRXOBNM9IJLH9YH9VSN99PVN
O9IZRRGFBGTWXMFEAOMDSHCSNHPVDQNAEQZIBSRDBMEOOKXMUDGDYDYZJOBTQZIGUMWNMKHVAU99CKKOJSOFLTORJ9PBS9VIIJM
UXTOIJPDAPJGMSLLQWLOLNQHUUURFGXIMKOIKBJFCFNLYIHMHVA9SFEOFUNIICXFLSNFURJAFXREJSXVRCNKJCTYQFSKTALTKUG
SSE-optimized multi-threaded library on a Core i5 (about 1.7 s). TMUY9QP9DQAKDPZPJEYRBKZZKNKE9STVFBTCF9SBLVZVJFI9KPKIRXMONS9BIJCQOKHNJQ9OMYMZIPKCXNCJMOIESKAHKSGTYOY
OZSABMHTKGGQTOOQXVRSXLVAQJZDH9TXMMB9PYASKKCYLGLDJXJPKTOTEIOTZKKCFNVTN9LYTNSOOJDFYFSZBSGWTYIHUWJKIWD
steps [1] of the transaction hash must be zero. If a hash does OBTQGOBUHJHWVRZBPXDFBRDOJTMRBIKMVVUDQJMSBSYAKJYUGGR9EADDHOPT9ZCGNATIFKEEBVLVWEBMZKYPKLIMTQRDUQUSYLE
SUUJSUZO9VYUCPWALPQAJERBO9HMYLHRMIXJX9PCCREF9TQNMAFKLURLFQWPDIBPWZARXAWWE9SETHHCEJHVOMSJJEHOQEUNGTC
DV9RFXXJ9DMBNMAPAXRCVCCXQ9SFDNNYEGHGTY9AOTLPWJOOAD9MFTCZ9BCRSIDFQUQOEXBGIXYQUC9NA9ZFTCEHHTZIXEGBNCR
not fulfil this condition, a counter (Nonce, see Figure 1) is SAPYNFGJLE9RDCCRJ99PQHVTLPXVIBEBPCLT9WAJSKLROLIWEGNEA9HTSRXCDZODLHOMNDXCSSVYXJADMUFKNMJMLOQHBDV9IZM
CDIFZIKYCGOLCXJZYDCVFFUZODIUAOBWOP9UPIOYTNRKNYZVMXDOISNZCHGIWMFCIZABQE9BYL9GVZCMBHRTMNYNZWZNPPHVKLW
The idea behind this is that the tangle can be protected from SRXDJTHWBXESFLSXOKSYRSLDETVULSRINQIEUZYBYILTQNSN9OWCKUODFXQOUVAGOVEYPVAFKUJQZ9999
other hand, takes hardly any time because only the hash of 14 Trits = '0'
with a fixed block size (rate) are absorbed into the internal no
state, which has three times the size (capacity) of a block. last
Hash
B33
B2
B1
B32
14 Trits
The entire state is then transformed into the subsequent state zero?
CURL-P81
CURL-P81
CURL-P81
CURL-P81
using a sponge function (Figure 2). Once all blocks have been yes
Mid-State
State 31
State 1
…
0 ...
absorbed, the hash can be squeezed out. Found!
An IOTA transaction consists of 33 blocks of 81 trytes each
(B1–B33 in the diagram). The last block contains the counter absorb absorbing squeezing squeeze
Overview of PiDiver
The PiDiver — the name consists of Raspberry Pi and the ref-
Raspberry Pi GPIO
erence PoW algorithm “Pearl-Diver” [1]) — is a HAT (Hardware
5V Pi
Attached on Top) for Raspberry Pis, which can perform IOTA’s SPI
FPGA Confi g
USB
the relatively new Cyclone family (released 2018), with which FPGA SPI
STM32
BOOT
particular. The FPGAs, which offer a lot of logic resources, are SPI
Flash
not only very inexpensive and power-saving, but also available 10
+5V +5V
1 +5V
VDD 8 L1 R8 +1V2
VIN 6
SW 0 C10 C11
POWER_PI 3 U10 5 C12 U3
2.2 H R10
EN OUT 1 C14
MAX40200 EN +3V3
12k7
10 10
100n BD9D321EFJ
GND
100n
2 3 7 0.1% R7
VREG BOOT C5 C6
+5V
270
4 EXP 2
1 SS FB 47 47
GND R11
VDD D1
C3 C4 C71 C78 C79
5 9
U11
22k
POWER_USB 3 5
EN OUT
1 3n3 47 47 47
MAX40200 0.1%
GND
2
+3V3 +3V3
J2 4
1 2 24 36 48 9
+3V3 +3V3 R22 U7 C70
3 4 RESET 7 5 3
VDDA
VDD
VDD
VDD
NRST PF0/RCC_OSCIN 22
5 6 BOOT0 44 6
+1V2 +1V2 BOOT0 PF1/RCC_OSCOUT 8MHz 100n
7 8 +3V3
+2V5 +2V5 2
PC13 R31 2
3 1
PC14/RCC_OSC32IN VBAT
10K
4
J1 PC15/RCC_OSC32OUT
1 2 USER5 18 10 LED_ARM
PB0 PA0 +3V3
CONF_NCONF 3 4 POWER_PI USER6 19 11 ARM_BUTTON
PB1 PA1
CONF_DATA0 5 6 DISC 20 U5 12 CONF_DONE
PB2 PA2
CONF_DCK 7 8 USER4 39 13 SPI2_SS
PB3 STM32F302CCT6 PA3 C75 C76
9 10 CONF_NSTAT 40 14 USER1
JP1 PB4 PA4
CONF_NSTAT 11 12 FPGA_SEL0 USER3 41 15 SPI2_SCK
PB5 PA5/SPI1_SCK R6 22 100n 100n
13 14 USER2 42 16 SPI2_MISO
JP2 PB6 PA6/SPI1_MISO
15 16 FPGA_SEL1 CONF_DCK 43 17 SPI2_MOSI
PB7 PA7/SPI1_MOSI
17 18 FPGA_SEL2 CONF_DATA0 45 29 USER10
PB8 PA8
PI_MOSI 19 20 CONF_NCONF 46 30 USER9
JP3 PB9 PA9 R27 +3V3
PI_MISO 21 22 USER7 21 31
PB10 PA10 10K
PI_SCK 23 24 USER8 22 32 USB_D–
22 PB11 PA11/USB_DM
25 26 CONF_DONE 25 33 USB_D+
R9 PB12/SPI2_NSS PA12/USB_DP +3V3
27 28 26 34 ARM_SWDIO
R5 +3V3 PB13/SPI2_SCK PA13/SWDIO
PI_SS 29 30 27 37 ARM_SWCLK
10k PB14/SPI2_MISO PA14/SWCLK
R30 31 32 28 38 PI_DETECT
PB15/SPI2_MOSI PA15 C73 C74
33 34 PI_DETECT R16
10k
VSSA
VSS
VSS
VSS
35 36 ARM_NRST
10k
100n 100n
37 38 23 35 47 8
JP4
39 40 ARM_SWDIO +3V3
+3V3
JP7
R29 +3V3
ARM_SWCLK
22
JP5 +3V3
U9 8
P2
J5 VCC 7 R15
5 HOLD 1
MISO MOSI
USER1 1 2 USER2
10k
2 2 ARM_NRST
USER3 3 4 USER4 C7
EEPROM
3 ARM_SWDIO
Array
270 ARM
GPIO8 9 10 GPIO9 D4 SW3
R18
GPIO10 11 12 GPIO11 LED_FOUND ARM_BUTTON
270
GPIO12 13 14 GPIO13 FPGA_BUT
R19 D5 BOOT0 BOOT
15 16 LED_RUN R28
270 SW2 R24
JP6 JP8 JP9
+3V3
10k
R20 D6 FPGA
10k
LED_ARM
270
1k5
10k
1
R1 R25 VBUS
R13
33
2
36k
1k5 D–
USB_D– 3
D+
33
USBLC6-2SC6 5
GND
USB_D+
+5V +3V3 +2V5 C85 C86
LD1117S33TR LD1117S25R L8 4 6
U2 U4 47p 47p R2 L7
C84 C83 C81
100k
C1 C2 C19 C20
4 7 100n 10n
POWER_USB X5R
100n 10 100n 4 7
X5R
+3V3 L1 = 2 2 (SPM4012)
SPI2_MISO 76 L3, L4, L5, L6, L7, L8= ferrite bead 0805
R4 6 IO
+2V5 IO SPI2_MOSI 77 (Würth 74279220181)
7 IO
10K
54
CLK13 10CL025YE144I7G
+3V3 55 128
CLK12 CLK10 POWER
129
GPIO8 58 CLK11
C55 C62 IO
8x GPIO9 59 IC1E 132 +1V2
IO IO IC1I
10 10 GPIO10 60 133
IO IO
GPIO11 65 FPGA_SEL2 135
IO IO
OVERFLOW 66 FPGA_SEL1 136
IO/VREFB4N0 IO/VREFB8N0 L3 L4 L5 L6
+3V3 LED_FOUND 67 FPGA_SEL0 137
IO IO
LED_RUN 68 141
IO
BANK 4 IO BANK 8
GPIO12 69 142
12x IO IO
GPIO13 71 143
IO IO
100n 100n FPGA_BUT 72 144
IO IO
C46 C44 C53 C51
C21, 22, 25, 26, 29, 30, 100n 100n 100n 100n
C33, 34, 37, 38, 41, 42
180361-022
Web Links
[1] First part of the series: www.elektormagazine.com/180361-02
[2] GIT Project Repository: www.gitlab.com/microengineer18/pidiver1.3
[3] DFU Tool: http://dfu-util.sourceforge.net/
[4] GoLang: https://golang.org/
[5] Attach to Tangle: https://iota.readme.io/reference#attachtotangle
[6] PiDiver Documentation: https://ecosystem.iota.org/tutorials/pidiver-usbdiver-documentation
[7] IOTA Ledger: https://github.com/iotaledger
[8] Library dcurl : https://github.com/DLTcollab/dcurl
[9] Library ccurl : https://github.com/iotaledger/ccurl
[10] IOTA Foundation Wallet: https://github.com/iotaledger/wallet
[11] Musical PiDiver: www.youtube.com/watch?v=GhgDCf9oBEo
[12] PearlDiver: https://github.com/Come-from-Beyond/PearlDiver
Musical PiDiver
The PiDiver is basically a versatile FPGA board that provides
Raspberry
unused pins for own applications via additional pin headers. SID-File
For example, a C64 hardware emulation was tested that can - SID file is being loaded
play 8-bit 80s music in stereo via an I2S digital-to-analog
- libsidplayfp generates
converter connected to the board. libsidplayfp RAM/ROM raw image
CIA1
CIA2
SID1
SID2
6510
CPU
*: Mini-VIC does not generate video, but is important for timing.
Elektor breaks the constraints of a magazine. It’s 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
Elektor Academy: Webinars, Seminars, Elektor Books: Arduino, Raspberry Pi, ESP32,
Presentations, Workshops and DVDs ... IoT, Linux and more. Available in our online
Practice-oriented learning. store with a 10% Member discount!
www.elektor-academy.com www.elektor.com/books
The approach to automating more complex manufacturing pro- ciation’ [3], a kind of special interest group. This group holds
cesses can be thought of as a series of layers as illustrated in the rights to the name ‘AS-Interface’ and sells products based
Figure 1. At the bottom level we find the sensors and actu- on the official standard. In case you might be considering join-
ators. For reasons of cost and efficiency, communicating with ing the group, you may wish to bear in mind that membership
these devices requires us to go to the trouble of using Ether- will set you back in the region of €4000 per annum.
net-style cabling: short-range connections using protocols such If you would like just to take a look at the standard there is a
as SPI or I2C are often no match for the harsh environment of more affordable path available: AS-Interface is specified via a
an industrial installation [1]. bundle of industrial standards, of which by far the most popular
is EN 62026-2:2015. This standards document can be obtained
Two widespread techniques for connecting sensors and other through the official channels for a mere €250. Alternatively,
devices are AS-Interface (actuator-sensor interface, also known if you fancy a spot of personal research, it should be possible
as ASi) and the IO-Link protocol, standardized under the name to find the document in the library of a local technical college
SDCI, and promoted for use in PROFIBUS environments. The or university; and failing that, perhaps an inter-library loan or
most significant advantage of AS-Interface is that a master can a suitable institutional library might come to your assistance.
talk to many slaves using a single port. IO-Link, in contrast, One possible complicating factor in getting to grips with all
normally requires a separate port and cable for each slave. In these materials is that currently there are two versions of ASi
the English-speaking world at least, IO-Link is generally con- on the market. Of these, only version 3.0 has a significant level
sidered more suitable for use in systems where large quantities of availability, both in terms of specifications and in terms of
of data must be communicated. hardware. However, version 5.0 has been widely promoted
Note that ASi and IO-Link can to some extent coexist. For exam- since the ‘SPS IPC Drives 2018’ trade show: the new version
ple, the system from Bihl+Wiedemann shown in Figure 2 and improves on the old in several details.
described in detail in [2] uses IO-Link to collect information; the Although such developments are perfectly normal in themselves,
compiled datagrams are then passed to the master using ASi. a sticking point is that the exact specification for version 5.0
of the protocol is, at the time of writing, not available to all
Which version? members of the association. According to insider information
AS-Interface came into existence in 1990 from the formation of the information is only available to those directly involved in
a group of companies under the name ‘AS-International Asso- developing the protocol.
10
drops in cables and connectors. Also, the high level of noise
immunity offered by the ASi system is not carte blanche for
sloppy or disorganized cabling. When an ASi cable is run in the Figure 3: Cross-section of an ASi cable (conductor diameter 1.8 mm). The
same duct as mains cables carrying power-line signalling, it is ‘nose’ shape prevents accidental reverse-polarity connection.
possible in some circumstances for the network to suffer inter- (Image: after Bihl+Wiedemann).
8/16 MHz
DIO-0
If you wish to build an ASi device it is not really practical to
OSC1 DO0
DO1 DIO-1 implement the decoder hardware yourself. The company IDT
DO2 DIO-2
DO3 DIO-3 mentioned above offers the ASI4U transceiver chip, which can
OSC2
1N4001 DSR DSR & Reset
be configured to operate as a master or as a slave. Figure 5
ASI+ ASIP P0 P0
P1 P1 shows the basic circuit, taken from the data sheet.
P2 P2
ZMM 39
P3 P3 Particularly noteworthy are the two light-emitting diodes, which
ASI-
ASIN
PST PST IDT’s data sheet labels as green and red. The ASi bus specifi-
LED red
CAP
47 n
USR LED1 cation requires that these LEDs are present on slave devices,
100 n
LED green and they give information on the current operational state.
LED2
0 V IRD More information on this can be found in the device data sheet.
GND
+
The pins labelled DIx and DOx are input and outputs. If a mod-
100 n
10 µF ule using the transceiver is operating in slave mode, then this
0 V
is where data communicated over the bus will be made avail-
able. The pins labelled Px are used to configure parameters,
and are particularly important in the master mode, which we
Figure 5: The transceiver chip requires very few external components will not go into here.
(source: [6]).
The communications standard
Now that we have understood the underlying electrical prop-
erties of an ASi system, we can turn to the logic behind the
communication format. All communications are strictly under
the control of the master, which carries out a cyclic polling pro-
cess whereby it interrogates each individual slave connected
Master- Slave-
Masteraufruf pause Slaveantwort pause
to the bus in turn. Each slave will normally reply to this with a
0 SB A4 A3 A2 A1 A0 I4 I3 I2 I1 I0 PB 1 0 I3 I2 I1 I0 PB 1
four-bit payload. When a cycle is complete it starts again from
the beginning: see Figure 6.
ST EB ST EB
Q How can you keep the distortion in a load as small as Q Why is there an analogue ground?
possible?
A In a circuit with analogue and digital parts, a separate
Q hat can cause hum in an amplifier? measurements. In both cases, a measurement error can occur,
and with sensitive circuits, touching a probe to the circuit can
Q What is the best way to convey small signals? such as polystyrene, is that the capacity range is small, with
a maximum of several tens of nanofarads in many cases. Con-
180573-D-02
OWON XDS3064E
four-channel ’scope with Touch
Screen
The XDS series oscilloscopes from the Chinese brand OWON has down to 1 mV/div (bandwidth limited). The noise of the input
a number of features that you do not (yet) find in comparable stages remains quite small with this, otherwise such a high
models from other brands, and all that for very sharp pricing. sensitivity would make no sense. With the Auto-set button
Here we take a brief look at the very affordable 4-channel you can automatically search for the appropriate settings for
XDS3064E, which has a whole lot to offer for not even € 400. a clear display of the input signal. The Math button does not
When unpacking this oscilloscope, its large display immediately only allow operations to be performed on the signals, but it is
catches the eye, with a resolution of 800x600 pixels plus touch also possible to enter equations yourself. The XDS3064E also
screen functionality. This is not a common feature in this price has an FFT function.
category. After switching on this first good impression is con- In conclusion we can state that if an input bandwidth of 60 MHz
firmed: a nice screen with a good viewing angle. is sufficient for you then this instrument will give you a great
As already mentioned, this is a 4-channel ‘scope with an input deal of measurement enjoyment.
bandwidth of 60 MHz and with a sampling rate of 1 GS/s. While
it is true that the sampling rate drops to a half or a quarter
when multiple channels are used, this is typical for this price
category. The instrument is supplied with four probes, a mains
Function Generator Kit
power cable, a USB cable and a brief getting-started manual.
A comprehensive manual is available as a PDF. from Pulsar Labs
Becoming familiar with the operation of the XDS3064E goes An oscilloscope (such as the OWON model described above) is
quite quickly. However, a few of the functions require some indispensable for seeing what an electronic circuit is doing, but
further explanation and it is then a good idea to consult the such an instrument becomes really useful when we can apply
full manual. The sensitivity of the input channels can be set a suitably defined signal at the input of a circuit. And that is
where a function generator comes in. Here we take a look at
a function generator that we have to build ourselves first: the
@ www.elektor.com open-source function generator from Pulsar Labs.
The assembly of the function generator (although it is not
ªOWON XDS3064E Four-Channel Oscilloscope explicitly described in the supplied manual) should be straight-
www.elektor.com/18829 forward, even for those who are not yet soldering experts. The
most important thing is to take your time, thoroughly check
@ www.elektor.com @ www.elektor.com
ªPulsar Labs Function Generator Kit Set ªSimo 3D Pen Kit
www.elektor.com/18653 www.elektor.com/18867
In industrial and consumer electronics, the use of thyristors and triacs is known to corrupt the AC
grid voltage to a degree due to harmonics, noise, bursts and transients being superimposed on what
you thought was a clean sinewave from the power outlet. A newly developed composite electronic
device called the baristor can help to keep the line voltage clean yet offer good regulating properties.
This article describes the baristor’s functionality as well as three practical AC-in, DC-out incarnations,
on circuit boards
The barrier-resistor element (barrier + ing zero. Thyristors and triacs allow cut- user requirements;
resistor = Baristor) is a switching ele- ting off almost any part you want of the • you can easily regulate heaters and
ment for power and analogue electron- AC sinewave signal and so control the lamps with thyristor or triac based
ics, whose electrical “input-output” resis- effective power fed to the load. But they circuits;
tance changes abruptly from conducting have some disadvantages: • are suitable for use in power supply
to non-conducting and vice versa. The units to generate different output
desired “state” is obtained when a pre- • low switching performance; voltages.
determined threshold value (“barrier”) of • no turning off without interrupting
the input signal is reached. Symbaristors current through device; As a radical thought, consider that the
are symmetric baristors intended to oper- • distortion of AC line sinewave; switching in thyristors and triacs occurs
ate on alternating current (AC). • power factor reduction; on the “horizontal” axis (i.e. with time)
• low economic efficiency. while with baristors, switching occurs on
Baristor vs. SCR the “vertical” axis (i.e. with voltage). This
In power electronics, SCRs like thyris- The above drawbacks can be overcome feature of the baristor opens fundamen-
tors and triacs are known as commuta- to a large extent by baristors and sym- tally new opportunities for its use in com-
tion elements capable of switching from baristors which: munications equipment and power elec-
a non-conducting state to a conducting tronics. Baristors are intended to sepa-
state when their gate electrode is ener- • enable an AC-current signal to be rate signals whose amplitude is above or
gized. They are switched off when their divided into segments of adjustable below a predetermined threshold value
instantaneous anode voltage is approach- width and using them according to (barrier) set by the user.
680
T1
• AC or DC (asymmetric and symmet- T3
220k
• Switches of type: On/Off/switchover.
680
R3
Here are the names with the family
5k1
picture.
High-level baristor: the voltage at the
output occurs only in the case when the 180533-006
cuit around T1/T2 varies from "thyristor" A positive feedback network R7–C5 was But be careful using a TO92 packaged
to "Zener diode". The problem with this added to suppress erroneous switching device for T3 and T6 — due to the lim-
is… it’s not really a Zener diode. With T1 and to enhance switching of the output ited power dissipation of this housing it’s
and T2 not conducting, current still flows stages. This makes the base of T1 act wiser to use a larger case style. In the
through R2-P1-R1-R3. So if P1 is too low like the input of a Schmitt-trigger. Due end we used the good old BD139 in com-
in value or R3 too high, T3 may switch to the hysteresis, which depends on the bination with a standard BC547C to make
on or off, i.e. there’s no real threshold AC voltage applied to K1, the phase set a discrete Darlington replacement for the
and the output voltage will vary with the on P1 changes with the level of the input originally used BC373. The BD139 has a
AC input voltage. Also, some very low voltage. Depending on the application SOT32 (TO126) case style and allows a
frequency instability can occur at cer- and AC voltage used the values of some maximum power dissipation of 1.25 W
tain settings of P1 in combination with components are subject to tweaking, for without additional cooling (i.e. the junc-
different AC input voltages. Worse, the which simulation software like LTSpice tion will be 150 °C at room temperature,
output impedance of the transformer comes in handy. Using a voltage source 25 °C). Never operate a transistor at a
affects the operation and stability of the instead of a “real” transformer in the junction temperature of 150 °C, keep
circuit. A 10-µF capacitor from the base simulation will give false results. Every it well below 70 °C if you don’t want to
of T4 to ground can improve circuit sta- transformer has a complex output imped- reduce its lifespan. And why not use a
bility. A change in load resistance will ance consisting mainly of a combination BD679 Darlington to reduce the number
change the output voltage. of a resistance and an inductance. As a of parts, you might ask? Well, almost all
Some salient measurement results result, the moment the Baristor switches, Power Darlington’s have internal resis-
obtained with a practical construction of the input voltage changes and can cause tors in parallel with the base-emitter of
the circuit are given in the text box: Per- instability, especially when the gain of both transistors. These inevitably cause
formance, Single-threshold Baristor. T1 is high. the gain of the transistor to vary with
The original circuit found in the book the collector current, while at low cur-
Enhanced Single-threshold used high voltage Darlington transistors rents the gain is much lower than that
Baristor type BC373 which sadly proved hard to of Darlingtons without internal resistors.
The circuit in Figure 2 is again based find. The specifications are: 80 V / 1 A Back to the circuit diagram, the maxi-
on an outline found in the ‘Electronic in a TO92 case style. The parameter hFE mum voltage drop from K1 to K2 or K3
Circuits for All’ book. at 100 mA is quoted as >20000. Fortu- is about 4 V at 100 mA. This is due to
Its purpose and intent isn’t so much a nately there are quite a few replacement D1–D4 and a small voltage drop across
fully working device as a circuit that can types that are still available, including R4 and R6 and the base-emitter volt-
be modified to fit your own applications BCX38C (60 V / 0.8 A); KSP13B (30 V / ages of T2/T3 and T5/T6. Hence with-
or just give new ideas or be part of a 0.5 A); MPSA14, (30 V / 0.5 A); MPSA29 out extra cooling of T3/T6 the maximum
solution for other purposes. Sure, the (100 V / 0.5 A); ZTX603 (80 V / 1 A); output current should be limited to a few
PCB designed by Elktor Labs for this cir- ZTX605 (120 V / 1 A); ZTX614 (100 V 100 mA.
cuit does make testing and experiment- / 0.8 A); BC517-D74Z (30 V / 1.2 A but Removing D5 will increase the range of
ing easier but the circuit is simple enough with its collector and emitter connec- P1 and has more effect at low input volt-
to be tested on a breadboard. tions swapped! ages. To change the range of P1 at high
6k8
4x 1N4007
R4 BD139 T5
P1 K2 K3
6k8
D3 D4 100k
T2
C3 C4
BC547
47n 47n D5
BZX79C3V0
BC547
R2
1M
R7 C5
1M5
T1 1n T4
R5
330k
R1 R3
BCX38C BCX38C
180k
56k
180533-008
Figure 2. This version of the baristor has enhancements and refinements compared to the basic version. It should offer many possibilities for
experimenting and adapting to your requirements.
component list
1k
primary windings of 115 V and two sec-
BZX55C4V7
R1 BC547C
ondary windings of 12 V able to supply
K2
1.25 A each. This way a safe test setup
10k
T1
C1
is guaranteed. But be very careful in this
LOAD
4700 setup. The maximum output voltage of
50V
T2
the autotransformer is typically higher
2x BC547C
than the input voltage. Labs used one
R2 that is still specified for use with the old
220 V mains voltage. The output is spec-
10k
Blockchains,
the Universe, and Travelling Through Time
e. Well,
rough tim
w fo r tr avelling th y
es might al
lo terminolog
eo ri es , wormhol b lo ck . In blockchain
to some th e same
According block to th forked?”
e than one iverse be
ou t w ormholes? in g m or ti on , “C an the Un e
clamour, w
hat ab rbids chai n
er the ques e alternativ
I hear you es to o as nothing fo (H om ew ork: answ n ot h av e to link to th
wormhol forward. er does the
s can have ore paths n. The latt ould create
blockchain e re su lt is two or m ck ea rl ie r in the chai te ri n g th at block w
d th to a blo e past, en
d a fork an loop back block in th
this is calle e paths could o back to a
of th es t yo u g would
ds.) One e would le s exist, we
in 500 wor , ev en if a wormhol ye t ex is ts. (If it doe ture
lock. Howev
er that not wise the fu
previous b en ti on ed above.
en te ri n g a state t n+f re ad y kn own, other
e ones m ld mean s are al t state
lems as th l, that wou l our action the presen
same prob to th e future? Wel w ou ld im ply that al th at at ta ches it to the
g alogy this h the path plies that
out travellin ckchain an gether wit ain. This im
So, what ab g th e b lo st at e to b lo ck ch
the past. Fo
llowin create this as they fo
rm a valid and less en
ergy-
be living in ill have to u, as long uch easier
g , free w ill.) You w u p to yo ld b e a m
n path is ay wou
valid. So lo ake up this reaming aw
would be in e st ates that m u r eyes and d
re th in g yo
u configu ply clos
t n. How yo ination. Sim e future.
your imag
dep en d s on elling to th
future only al te rn at ive for trav
valid
yet equally
consuming
www.elektor.com/owon-ow16b-digital-multimeter-
with-bluetooth
Smoking Really
Is Dangerous
Okay, so you knew that already. Maybe you replaced your traditional tobacco-based cigarettes by a hopefully
safer e-cigarette? The long-term health risks of the e-liquids used by these devices are still unknown, but you
probably knew that too. What you may not know yet is that in the French village of Plougoulm a man got burned
when the battery of his e-cigarette went up in smoke after short-circuiting with his car keys in his trouser pocket.
According to the victim, after hearing an explosive sound, a 40-centimetre long flame shot out of his pants. When
trying to remove the burning (!) e-cigarette, the man injured his hand. (I guess he was lucky to get away with
just that.) Similar incidents involving coins have been reported too.
But there is worse. In Fort Worth, Texas, USA a man got killed when his e-cigarette exploded in his face and cut a
major artery in his neck.
Sometimes an NTP server on your own local network can come in very handy. As well as situations where
your network is cut off from the Internet but various pieces of software need a time reference, there are also
cases where you are developing a project that requires the ability to fetch time data over the Internet, but
you would ideally like to create custom NTP data. As the following guide shows, achieving all this and more is
(relatively) easy.
The executive summary is that an NTP tery-backed real-time clock (RTC). This erence (a quartz crystal). It is therefore
server is a device that sits at a given supplies the time and date information to a good idea for the computer’s operating
Internet address and, when sent a suit- the OS, which in turn provides it to soft- system to calibrate its RTC time periodi-
able request, returns the exact time ware running on the device. The informa- cally against an external reference. And
using the Network Time Protocol (NTP). tion is needed for much more than just that is where NTP comes in.
If you would like to know the details of the calendar app: many of the essen- It is of course possible to calibrate the
how the protocol works, Wikipedia and tial operations of the machine, such as time using the DCF77 or GPS signals, but
the like are your friends. ensuring that files that are created or using a bit of software to interrogate an
In order for PCs and other small com- modified are correctly time-stamped, NTP server is simpler and cheaper than
puters that have an Internet connec- rely on it. specially-designed hardware. And fur-
tion can know the exact time (and date) However, the time needs to remain accu- thermore both these time sources have
immediately that they are switched on, rate over the long term, and not depend their own disadvantages: the DCF77
they almost universally include a bat- on the accuracy of the RTC’s internal ref- transmitter near Frankfurt in Germany
Web Links
[1] ESPNTPServer: https://github.com/liebman/ESPNTPServer
[2] Beat the Elektor Pinball Clock!, ElektorLabs magazine March & April 2019: www.elektormagazine.com/180307-01
[3] Project page accompanying this article: www.elektormagazine.com/180662-01
[4] Firmware on GitHub: https://github.com/ElektorLabs/180662-mini-NTP-ESP32
[5] Arduino setup for ESP32: https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/boards_manager.md
[6] Arduino ESP32 filesystem uploader: https://github.com/me-no-dev/arduino-esp32fs-plugin
[7] Guide to uploading files: https://techtutorialsx.com/2018/08/24/esp32-arduino-spiffs-file-upload-ide-plugin/
• U8G2
• Time
• Ticker
• TinyGPS++
• RTCLib
• ArduinoJson 6.x
• CRC32
Figure 6. The WLAN settings configuration menu page. Note that this list might change for newer versions of the
project. Once the compiled code has been uploaded to the
ESP32 module, it is also necessary to upload the web page it
requires. How that is done is described in various places on the
Internet and in several Elektor projects that use the ESP32.
The Arduino ESP32 filesystem uploader (and documentation)
can be found on GitHub at [6], and a guide to how to upload
files (a web page is just a file) can be found at [7]. When the
device is reset the NTP server will be ready for use as soon as
the boot process is complete.
@ www.elektor.com
ªOPEN SMART GPS
www.elektor.com/open-smart-gps-serial-gps-module-for-arduino-apm2-5-flight-control
ªLolin ESP32 with OLED
www.elektor.com/wemos-lolin-esp32-oled-module-with-wifi
ªAdalogger FeatherWing: RTC + SD add-on
www.elektor.com/adalogger-featherwing-rtc-sd-add-on
ª0.96 inch I2C OLED display (optional)
www.elektor.com/blue-0-96-oled-display-i2c-4-pin
Editor’s note: This article presents a sample chapter from the vention. In regard to IC symbols:
book “Kicad Like a Pro” by Dr Peter Dalmaris, reformatted to match • We arrange pins around a rectangle.
ElektorLabs magazine page layout. The book is available from the • We group pins according to function (like inputs, outputs,
Elektor Store. power etc.).
• We place the Vcc pin on the top of the rectangle.
Most likely, you want to create a custom schematic symbol • We place the GND pin on the bottom of the rectangle.
because you have a physical component but can’t find an • We choose an appropriate name and designator for the
existing symbol to represent it. Perhaps you have searched symbol. Symbol designators are standardized; you can
through the symbols that come with KiCad, and Googled for learn more about them at [1].
suitable third-party symbols, but couldn’t find any.
It is also likely that you will want to associate your new symbol
with a footprint. If your physical component has a standard
package, like DIP, for example, then you will be able to associ-
ate an existing footprint with your custom symbol. If not, you
will also need to create a custom footprint. You can learn how
to do this in the relevant recipe, also available in this book.
In this recipe, you will learn how to create a custom symbol by
creating a symbol for the 555 timer integrated circuit. There
are plenty of libraries for KiCad that contain this symbol, but
for the sake of learning, let’s pretend that we can’t find it.
What we want to create is a symbol like the one in Figure 35.1.
Our objective is to create a symbol that complies with the con-
Figure 35.1: A custom-made Figure 35.2: The physical Figure 35.3: Pin configuration and functions from the IC’s datasheet.
symbol for the 555 IC. component is a type 555 timer in
a DIP package with 8 pins.
gle line and type ‘E’). Under ‘Fill Style’, check the ‘Fill back-
ground’ radio button (Figure 35.9).
Figure 35.10: The Vcc pin properties. Figure 35.13: The input pin attributes.
@ www.elektor.com
ªKicad Like a Pro book (hard copy)
www.elektor.com/18822
ªKicad Like a Pro book (e-book)
Figure 35.15: The datasheet is very useful to have readily available. www.elektor.com/18830
Web Link
[1] Symbol designators:
https://en.wikipedia.org/wiki/Reference_designator
Figure 35.16: Find your new library and symbol.
From Tubes
to Silicon
With an interesting
intermezzo
By Dr Martin Beusekamp, MSc
overheating as a result of increased resis- Hold your nose, open the window, and get out.
tance in the forward conduction direc-
As mentioned in this article, selenium rectifiers can sometimes be dangerous. The
tion. This is accompanied by a pene-
internal resistance of selenium rectifiers rises as they get older, which increases
trating odour and the release of a gas
the voltage drop over the rectifier. This in turn increases the power dissipation,
that can certainly be hazardous in rela-
so the rectifier gets warmer. At some point it will be so hot that the selenium
tively high concentrations (see the inset
spontaneously starts to oxidise and turn into selenium dioxide (SeO2).
‘Hold your nose, open the window,
Selenium dioxide is a solid substance at room temperature, but it escapes from an
and get out’). If you encounter a sele-
overheated selenium rectifier as a greenish gas. This gas is toxic – in fact, highly
nium rectifier that is still working, you
toxic. It’s bad enough that it can make you dizzy, nauseous and tired, but what
are well advised to replace it by a silicon
even worse is that it can cause permanent damage to your liver and spleen.
diode with a series resistor to obtain the
Fortunately, people have a natural defence mechanism against selenium dioxide.
same voltage drop as the original sele-
Most people can smell it at concentrations as low as 200 ng/m³, so they are
nium rectifier.
alerted before the situation becomes truly dangerous. The smell of selenium
dioxide is also so disgusting that everyone wants to get away from the source.
Germanium diodes and
Selenium is located directly below sulphur (S) in the periodic system. This
transistors
means that selenium and sulphur have comparable properties, the same way
The first semiconductor devices that
as germanium and silicon, which are also vertically adjacent as described in this
became available on a large scale were
article. That’s why the odour of selenium dioxide resembles the odour of sulphur
germanium diodes and transistors (see
dioxide. It’s like rotten onions with garlic.
the inset ‘Tube codes for diodes and
See also Barry L. Ornitz, Selenium Rectifier Replacement [7], and ‘Sleepless
transistors’). Germanium (Ge) is an
nights from a pile of onions’ [8].
element that is located directly below sili-
the Philips DC power supplies PE4802 sides in the photo you can clearly see [5],[6] on the NVHR website.
(0–15 V / 6 A) and PE4804 (2 × 0–30 V that this is a dual power supply. These Philips PE4802 and PE 4804 power
/ 2 × 2 A) produced in the early 1960s. The black heat sinks of the germanium supplies are collector’s items — not
Figure 7 shows the internals of a PE4804 power transistors are clearly visible below because they are especially high-tech,
from the Historical Study collection of the the light green blades of the fan. By the but from the historical perspective: no
faculty of Electrical Engineering, Math- way, the motor that drives the fan blades tubes, no silicon.
ematics and Informatics of the Univer- is a standard synchronous motor oper- (180574-D-03)
sity of Twente [4], which also includes ating from the AC power line, which was
a PE4802. The large blue components used in all Philips record players at that
are of course the selenium rectifiers, and time. More details about this device can
from the symmetry of the left and right also be found in the service manuals
More and more attention is being paid to the responsible use of algorithms. How do we ensure
that algorithms do not reproduce prejudices? And how can we guarantee that algorithms reflect
our ethical values?
Cathy O’Neil, data analyst and author of Automating nepotism complaints about, for example, gar-
the book Weapons of Math Destruction However, O’Neil is not only negative bage in the street are automatically
[1], welcomes the increasing attention about the applications of Big Data. On forwarded to the cleaning department.
paid to these issues. “This is an awk- the contrary, they can make a positive But the municipality wants to pre-
ward slow frustrating conversation that contribution to the way in which we make vent that the automation has unin-
we absolutely must have”, O’Neil said decisions if we deal with them in the tended negative consequences. One
in an interview. In mid-April she was in right way. The challenge is to ensure that risk is that it creates inequality [2].
Amsterdam to advise the Municipality on mathematical models reflect our ethical In richer neighbourhoods, citizens
the use of a self-learning algorithm for values. Also, they should no longer be are often more vocal and are more
handling complaints. opaque. People must be held account- likely to complain. If the algorithm
able for any negative consequences. To is not adjusted, it will send sweep-
With her book, O’Neil has made an enor- achieve this, algorithmic applications ers to those neighbourhoods more
mous contribution to raising awareness must be carefully tested. often on the basis of that data. As
about algorithms. Using true exam- a result, areas where there is less
ples, she explains in an understandable “Scrutiny is exactly what people are try- complaining are served less well.
and convincing way how mathematical ing to avoid when they introduced the
models can cause damage. The weap- algorithm”, O’Neil said during the inter- In order to prevent such unintended
ons of math destruction (WMDs) in the view. “ The algorithm was to good to be effects, Amsterdam has decided to trial
title have three characteristics: they are true in a certain sense for a lot of com- the algorithm. Together with the con-
harmful, operate on a large scale and are panies and governments and organisa- sultancy firm KPMG, the municipality is
opaque. She writes about the latter prop- tions because it made things more effi- working on the development of audits for
erty in her book: “verdicts from wmds cient and it made accountability much algorithms [3]. This was the reason for
land like dictates from the algorithmic less. I think of the use of algorithms as O’Neil’s visit to Amsterdam. She advises
gods”. The results are in no way open an automated decision making process. both parties on what such an audit could
to discussion and no one has to account You already had decision making pro- look like. Her company ORCAA is spe-
for any harmful consequences. cesses. And they are made by humans cialised in performing audits on algo-
and they had all kinds of biases, all kinds rithms. They are checked for characteris-
One of the WMD’s in O’Neil’s book is the of unwritten rules, all kinds of secrets tics such as bias, transparency, accuracy
use of solvency for determining the car and like ways of favouring their friends and honesty.
insurance premium. In the mathemat- and stuff like that. Once it’s automated
ical models used by American insurers they thought: ‘Oh, it is like what we did O’Neil emphasises that developing hon-
to determine the price, solvency out- but better because we also don’t have est algorithms is not an easy task. There
weighs driving behaviour. In Florida, to answer for it’.” is no silver bullet solution that can jus-
people with a good score for credit and tify all mathematical models in one fell
a conviction for drink-driving paid more Algorithms scrutinised swoop. To ensure quality, each algo-
than $1,500 less a year than people with But the tide is turning. More and more rithm must be tested within the context
a poor score for credit and impeccable parties are thinking about how we can in which it is applied. If the Amsterdam
driving behaviour. O’Neil shows time and make algorithms fair. One of these par- algorithm works well, it cannot simply be
again that it is mainly the poor and weak ties is the Municipality of Amsterdam. It used in New York because the situation
groups in society who are the victims is in the process of developing an algo- there is different.
of WMDs. rithm to deal with complaints. Citizens’ “That is the biggest gap in people’s
understanding”, says O’Neil. “They think been. Once we scrutinise decision making is sexist, we are going to improve it. And
they can evaluate an algorithm. They processes, it is going to be much more we are going to use it. Because it will be
can’t. They can only evaluate an algo- transparent, much more value-laden.” less sexist than the human process it is
rithm in a context.” replacing. But we haven’t gotten to that
O’Neil illustrates her point with an exam- step yet. But ideally we will. Than you
Clean up human errors ple. “Amazon’s algorithm for hiring, they are actually going to clean up, rather
There is still a lot of work to be done, figured out it was sexist. So they decided than just propagate, the mistakes we
but O’Neil is positive because there is a not to use it. I am glad they checked, humans make.”
movement of people who focus on this okay, that’s progress. But what does it 180572-D-02
issue. “What this movement is going to mean when you codify a human process
eventually create is a way of maintaining and discover that it is sexist? It means
accountability in algorithmic processes. that your human process is sexist. What
In fact, it may even be that accountabil- I would’ve liked to see them do is for
ity will be much stronger than it has ever them to say: we have this algorithm, it (Graphics: https://weaponsofmathdestruction.com )
Web Links
[1] Weapons of Math Destruction: https://weaponsofmathdestructionbook.com
[2] https://fd.nl/ondernemen/1291305/amsterdam-wil-eerlijke-computers-in-de-stad
[3] https://home.kpmg/nl/nl/home/media/press-releases/2018/12/kpmg-ontwikkelt-ai-in-control-om-gebruik-van-algoritmen-
te-toets.html
6. PCBite Kit
www.elektor.com/pcbite-kit
www.elektor.com/wifi-bridge-smartscope
This book is a case study in embedded design including This book will teach you to use KiCad. Whether you are a hobbyist The HiFiBerry DAC+ DSP is a high-resolution digital-to-analog
discussion of the hardware, processor initialization, low‑level or an electronics engineer, this book will help you become converter for the Raspberry Pi. It combines a Burr-Brown DAC
driver development, and application interface design for a productive quickly, and start designing your own boards. This with digital input and output and a powerful Digital Signal
product. Though the author describes this through a specific book takes a practical approach to learning. It consists of four Processor.
application of a Cortex-M3 development board, his mission is projects of incremental difficulty and recipes.
to help the reader build foundational skills critical to being an
excellent product developer.
Member Price: £38.95 • €44.96 • $49.95 Member Price: £30.95 • €35.96 • $39.95 Member Price: £61.95 • €71.96 • $80.95
NEW
OWON SDS1022 The Complete ESP32 Projects Guide PCBite Kit incl. 4 PCBite
2-ch Oscilloscope (20 MHz) Probes and Test Wires
The OWON SDS1022 is a competitively priced oscilloscope The main aim of this book is to teach the Arduino IDE and PCBite is the perfect tool for handling your PCB during
with a sample rate of 1 GSa/s and a bandwidth of 20 MHz. MicroPython programming languages in ESP32 based projects, the design process. Powerful magnets combined with a
Furthermore, with this oscilloscope you have 2 channels using the highly popular ESP32 DevKitC development board. stainless-steel base plate provide flexibility, mobility and
at your disposal and it is possible to store 10 K points per Many simple, basic, and intermediate level projects are user-friendliness. The holder can easily be relocated to deal
measurement. There is a USB connector on the back for provided in the book using the Arduino IDE with ESP32 with printed circuit boards of different shapes and sizes. The
exporting measurement results to the PC, and a USB port on DevKitC. All projects have been tested and work. Block probe is sturdy yet flexible and can be used for immediate
the front for exporting to a USB memory stick. diagrams, circuit diagrams, and complete program listings measurements or totally hands-free operations with your
of all projects are given with explanations. multimeter or another preferred tool.
Member Price: £147.95 • €170.96 • $191.95 Member Price: £30.95 • €35.96 • $39.95 Member Price: £103.95 • €121.46 • $135.95
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 (that’s 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 4×4 boxes (marked by the is send us the numbers in the gray boxes.
Participate!
Ultimately July 1, 2019, supply your name, street address
and the solution (the numbers in the gray boxes) by email to:
[email protected]
Prize Winners
The solution of Hexadoku in edition 3/2019 (May & June) is: 46F7C.
The €50 / £40 / $70 book vouchers have been awarded to: Demierbe Guillaume (Belgium); Alexandr Papazyan (Russia);
Fostiropoulos Michalis (Greece); Sune Johansson (Sweden); Ruth Hanselmann (Germany).
Congratulations everyone!
The competition is not open to employees of Elektor International Media, its subsidiaries, licensees and/or associated publishing houses.
Microchip understands that your design needs are unique. That’s why our products
offer a robust set of integrated peripherals for a wide variety of applications:
Customise your product with built-in peripherals and save on design costs and time.
The Microchip name and logo and the Microchip logo 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.
© 2019 Microchip Technology Inc. All rights reserved. DS30010187A. MEC2287Eng04/19