Anda di halaman 1dari 84

Trust Your Application

Developing embedded systems is a challenge. Higher complexity, better performance

and more connectivity brings a rapid increase of safety and security demands. This creates
needs for secure workflows and full code control, extending the developers’ reach all the
way from design through to production.

We are dedicated to provide you with the superior technology and close-at-hand
support you need to be confident in your code when building the products of today and
the innovations of tomorrow. Using the right tools, you can trust your application and
create for the future.
The Embedded Experts

J-Trace PRO Cortex

The Superspeed Trace Probe

n USB Superspeed and Gigabit Ethernet interfaces

n Real-time streaming at full System Clock
n Tune your application with live profiling  +49 2103 2878 0
n Instruction-level code coverage U.S. East Coast:
 +1 978 874 0299
n Isolate and Identify hard-to-find code defects U.S. West Coast:
n Supports Cortex-A/R/M targets  +1 408 767 4068

n Full J-Link debug functionality

n Included cross-platform Ozone debugger n It simply works!

Issue 339 October 2018 | ISSN 1528-0608

OUR NETWORK CIRCUIT CELLAR® (ISSN 1528-0608) is published monthly by:

KCK Media Corp.

PO Box 417, Chase City, VA 23924

Periodical rates paid at Chase City, VA, and additional offices.

One-year (12 issues) subscription rate US and possessions
$50, Canada $65, Foreign/ ROW $75. All subscription orders
payable in US funds only via Visa, MasterCard, international
postal money order, or check drawn on US bank.


Online Account Management:

Renew | Change Address/E-mail | Check Status


Accutrace, Inc. C3 Phone: 800.269.6301 | 760-738-4970 ext. 124

All Electronics Corp. 77 Mail: Circuit Cellar, PO Box 417, Chase City, VA 23924

Avnet 49 Postmaster: Send address changes to

Circuit Cellar, PO Box 417, Chase City, VA 23924
CCS, Inc. 77
EzPCB 37
Gateworks Corp. 31

IAR Systems, Inc. C2 Contact: Hugh Heinsohn

Phone: 757-525-3677
Ikalogic 65 Fax: 888-980-1303
Lauterbach, Inc. 47 Advertising rates and terms available on request.

Mentor, A Siemens Business 43 NEW PRODUCTS

RISC-V Foundation 57 E-mail:

SEGGER Microcontroller Systems, LLC 1 HEAD OFFICE

SoC Conference 2018 25 KCK Media Corp.

PO Box 417
Technologic Systems, Inc. C4, 77 Chase City, VA 23924
Phone: 434-533-0246
VersaLogic Corp. 37
NOT A SUPPORTING COMPANY YET? Entire contents copyright © 2018 by KCK Media Corp.
Contact Hugh Heinsohn All rights reserved. Circuit Cellar is a registered trademark
(, Phone: 757-525-3677, Fax: 888-980-1303) of KCK Media Corp. Reproduction of this publication in
whole or in part without written consent from
to reserve space in the next issue of Circuit Cellar.
KCK Media Corp. is prohibited.


KCK Media Corp. makes no warranties and assumes no

PRESIDENT EDITOR-IN-CHIEF GR APHICS responsibility or liability of any kind for errors in these
KC Prescott Jeff Child Grace Chen programs or schematics or for the consequences of any such
errors printed in Circuit Cellar®. Furthermore, because of
possible variation in the quality and condition of materials and
CONTROLLER ADVERTISING PROJECT EDITORS workmanship of reader-assembled projects, KCK Media Corp.
Chuck Fellows COORDINATOR Chris Coulston disclaims any responsibility for the safe and proper function
of reader-assembled projects based upon or from plans,
Nathaniel Black Ken Davidson descriptions, or information published in Circuit Cellar®.
FOUNDER David Tweed
Steve Ciarcia ADVERTISING SALES REP. The information provided in Circuit Cellar® by KCK Media
Corp. is for educational purposes. KCK Media Corp. makes
Hugh Heinsohn
no claims or warrants that readers have a right to build
things based upon these ideas under patent or other
relevant intellectual property law in their jurisdiction, or
Jeff Bachiochi (From the Bench), Bob Japenga (Embedded in Thin Slices), that readers have a right to construct or operate any of
the devices described herein under the relevant patent or
Robert Lacoste (The Darker Side), Ed Nisley (Above the Ground Plane), other intellectual property law of the reader’s jurisdiction.
The reader assumes any risk of infringement liability for
George Novacek (The Consummate Engineer), and Colin O’Flynn constructing or operating such devices.
(Embedded Systems Essentials) © KCK Media Corp. 2018 Printed in the United States 3

Drones and The Wright Stuff

C ommercial and consumer drones are among

the most dynamic areas of embedded
system design today. The industry that
Circuit Cellar covers—and is a part of—is a
vital enabler of these markets. Drone designs continue to
leverage advances in processor/chip technologies, sensor
low-risk small drone flights, and created a performance-
based waiver and exemption process to allow more
advanced operations.”
Another key effort is the Unmanned Aircraft Systems
(UAS) Integration Pilot Program launched last October by
US Secretary of Transportation Elaine Chao. The initiative
innovations and power solutions that make up the heart partners the FAA with local, state and tribal governments,
of a drone’s electronics. which then partner with private sector participants to safely
More than most areas of embedded system design, explore the further integration of drone operations. In May
drones must be looked at within the broader perspective of this year, the USDOT selected 10 state, local and tribal
of issues beyond technology—in particular the many governments as participants in the UAS Integration Pilot
safety and regulatory issues surrounding them. After Program. Data gathered from these pilot projects will form
all, drones have to operate within the same air space the basis of a new regulatory framework to safely integrate
as manned aircraft. And unlike the automobile industry, drones into the national airspace.
for example, the drone industry is relatively new with a According to the USDOT, the 10 final selectees will work
regulatory landscape that’s still evolving and with many with the FAA to refine their operational concepts. Over the
safety issues still to be resolved. next two and a half years, the selectees will collect drone
Acting FAA Administrator Daniel K. Elwell offered data involving night operations, flights over people and
some insights on these subjects in his keynote address beyond the pilot’s line of sight, package delivery, detect-
at this year’s InterDrone show early last month. He drew and-avoid technologies and the reliability and security of
parallels to the high-level of safety that’s been achieved in data links between pilot and aircraft. The data collected
commercial aviation to what the goal should be for drone from these operations will help the USDOT and FAA craft
safety. “Aviation is the gold standard,” said Elwell, “The new enabling rules. These will include rules for complex
safest form of transportation in the world. That’s not a low-altitude operations and improving communications
position we’re about to take a step back on. I’ve heard this and addressing security and privacy risks.
argument a few times: Back in Orville and Wilbur Wright's In Elwell’s keynote he cited a fun story about the pilot
era, people were willing to risk their lives for the birth of a program’s first test that happened just recently in
new form of transportation. Now that we’re on the cusp of Blacksburg, Virginia. A Project Wing drone delivered a
aviation’s next great era (drones), shouldn’t we be willing popsicle to a two-year-old boy, just six minutes after the
to accept some of the same risks in the name of progress? order was placed. “It was historic—the first beyond visual
Folks, there’s a really simple answer to that question: No.” line-of-sight residential drone delivery in the United
“Manned aviation already learned those lessons. We States,” said Elwell, “It was the ‘Mr. Watson, I want to see
paid that price. We’re not going to do it again. And the you’ for the 21st century. But to little Jack, it was just
public wouldn’t let us, anyway.” Elwell made the point cool. In his words: ‘Airplane brought me a Popsicle!’ These
that with drones, you’re not starting from scratch like the are important steps forward—steps that bring drones
Wright brothers. “The FAA has spent six decades working closer to just being a routine operator in our airspace.”
with airlines, manufacturers and countless others to get
where we are now. And we’re ready to use everything
we’ve learned so that the drone industry can reach its full
potential as quickly as possible.”
Elwell went on to list some of the progress along these
lines in the FAA and Department of Transportation. “We’re
building flexible, responsive regulatory processes that can
keep up with all your creativity while ensuring safety isn’t
compromised,” he said, “We’ve automated how drone
operators get permission to fly in controlled airspace.
We’re laying the groundwork for a comprehensive
Unmanned Traffic Management System. We’ve authorized

Jeff Child


54 Internet of Things Security

8- 8-/
Embedded in Thin Slices
,#6 8-#490+ 8-#490+
'-576 46) 46)
406) 406)

(Part 5)
Identifying Assests "(*:%
- -0
By Bob Japenga ( (

58 Hybrid Couplers 101

The Darker Side 8-0

Elegant Simplicity
By Robert Lacoste
Vac (

PG. 58

64 Humidity SensorsThe Consummate Engineer

From Vapor to Voltage

By George Novacek

68 Fog-Detection Audio Project

From the Bench

Using Arduino UNO

By Jeff Bachiochi


79 How RISC-V Enables the

The Future of Computing
PG. 64
       !"#$%&  '$ () *"+*
Next Era
By Ted Speers


@circuitcellar circuitcellar
PG. 68 5



Making a Chess-Playing

Using Python and Raspberry Pi
 By Christopher Martin-Rebneris

16 Building
an Autopilot
(Part 1)
Accelerometers in Action
-( .)
By Pedro Bertoleti

26 Power Line Communications

( Vac

PG. 6
Using a Cypress PSoC
By Aubrey Kagan

32 Build a Persistence-of-Vision
Using LEDs and PIC32
By Han Li and Emily Sun


&  '$ ( 1
38 Security
for MCUs
Takes Center Stage

Enabling Secure IoT

By Jeff Child
PG. 16

44 MCU Dev Kits Meet Diverse

Application Needs
Rich Resources
By Jeff Child


50 8- and 16-bit MCUs

Right-Sized Solutions
By Jeff Child

PG. 38

Making a Chess-Playing Robot

Using Python and Raspberry Pi

Playing chess versus a computer is

one thing, but how about playing
against a robot that can move the
pieces around? Learn how a team
of Camosun College students built a
4-axis servo-powered chess-playing
robotic arm. The project uses a
Raspberry Pi 3 board running a
custom Python robotic control

Christopher Martin-Rebneris

Project Chess Bot is a 4-axis chess-playing robotic arm that is controlled either by the user or by chess engine artificial intelligence. The main pieces of the project are a modified
Lynxmotion robotic arm and a Raspberry Pi 3 and 16-Channel Servo HAT kit for Raspberry Pi combination running a custom Python robotic control program.

T his article describes the creation,

components and functions of
our Camosun College student
team’s electronics and computer
engineering project concept: Project Chess
Bot. The intention of this article is to inspire
artificial intelligence. The bot is comprised
of a modified Lynxmotion AL5B 4 Degrees of
Freedom Robotic Arm (Hardware Only) kit
with five servos (waist, shoulder, elbow, wrist
and claw), a Raspberry Pi 3 and 16-Channel
Servo HAT Kit for Raspberry Pi combination
other electronics enthusiasts to re-create running a custom Python robotic control
and build on the concepts implemented in program, and a household computer running
this project. There are several alternative a custom C++ user interface and chess-
methods and additional ideas that were engine artificial intelligence that is connected
considered but not implemented in this to the Raspberry Pi 3 via USB.
current version of Project Chess Bot due While under user control (selected in the
to time constraints. I discuss those briefly user interface), the user only has to type in
in this article in order to inspire further the coordinates of the chess piece move they
exploration. desire (“e2 to e4” would be “e2e4”) into the
installed project user interface on the user’s
CHESS BOT computer. The command is transmitted
Project Chess Bot (Figure 1) is a 4-axis via serial USB to the Raspberry Pi 3 and
chess-playing robotic arm that is controlled 16-Channel Servo HAT Kit for Raspberry Pi
either by the user or by chess engine combination, which translates the command 7

into moving the robot arm’s servos to pick the dynamic torque requirements on the
up and move the desired chess piece to the shoulder and elbow servos, the aluminum
desired destination. tube, which would be mounted between the
When Chess-Bot is under chess-engine elbow and wrist joints and the foam pads
control (selected in the user interface), which would be attached to the claw fingers.
the user types in the chess move that the In addition to the Lynxmotion robotic arm

opponent (human or robot) has made into kit, another Lynxmotion Aluminum Tubing
the user interface, which is inputted into Connector Hub (pair) HUB-08 set is required
the chess-engine. The chess-engine then for the shoulder to elbow tube extension.
calculates its best desired move, which is Servos: The servos that are used in the
then translated to the robot arm servos in the current version of Project Chess Bot are
same manner as when under user control. HS-5585MH for the waist, HS-5765MH for
Regardless of whether the robotic the shoulder, HS-755MG for the elbow, HS-
arm is under user control or chess-engine 311 for the wrist and HS-311 for the claw.
control, the user interface software and the Our project team overcompensated for our
Raspberry Pi 3 and 16-Channel Servo HAT Kit servos to guarantee function, so it is possible
for Raspberry Pi combination software will to use less powerful servos to achieve the
work together to determine if a chess piece same functionality of the robotic arm.
is to be captured. And if so, it will execute Note: For several of the components
grabbing and “disposing” of the chess piece discussed in the next couple paragraphs, there
to be captured before moving the capturer’s are mechanical drawings available—referred
chess piece to replace it appropriately. to as “Design X” in each case. Because it’s
not practical to include them in the magazine
PROJECT HARDWARE article, these drawings are available on the
Aside from the Lynxmotion robotic Circuit Cellar article materials webpage.
arm, the project’s hardware also includes Aluminum Tube Extensions: The original
aluminum tube extensions, a raised-base Lynxmotion robotic arm kit has a maximum
platform, counterweights, chessboard, horizontal reach of 22.225 cm, and Project
plywood main base and claw extensions. Chess Bot required a maximum horizontal
Blue medium-strength Loctite was applied reach of at least 60 cm to be capable of
to any screws that required it, in other reaching the entirety of the chessboard. The
words, screws that didn’t have nuts or were original aluminum tube extension included
screwed into metal threads. Here’s a detailed in the Lynxmotion robotic arm kit was used
breakdown of the hardware components. as a blueprint for the new aluminum tube
Robotic Arm Kit: All components included extensions. Tubing that had the correct outer
in the Lynxmotion AL5B 4 Degrees of diameter, but a too small inner diameter, was
Freedom Robotic Arm kit (Figure 2) are used cut into two pieces to extend the shoulder to
except for the plastic platform intended elbow and elbow to wrist lengths, with each
for mounting additional (but not included) of the tube ends drilled and counter-bored
Lynxmotion circuit hardware to the plastic as specified in Design 1. With these new tube
base, the two springs intended to decrease extensions, the final design is capable of

Shown there is the Lynxmotion AL5B
4 Degrees of Freedom Robotic Arm
kit. It has additional Lynxmotion
circuit hardware mounted to a plastic
platform, which is mounted to the
plastic base. The two springs are
intended to decrease the dynamic
torque requirements on the shoulder
and elbow servos, which Project Chess
Bot does not use.

platform. As well, four wood screws are

required to mount the raised-base platform
to the plywood main base.
Counterweight Arms & Weights: The
original Lynxmotion robotic arm kit is
not specified to use the modified reach

and thus extended and increased weight

of the robotic arm without using a very
expensive and powerful shoulder servo, and
so our team designed counterweights to
significantly reduce the power requirement
of the shoulder servo and thus reduce its
cost and eliminate unnecessary stress on it.
The required counterweight was estimated
to be 1 kg at a distance of 19 cm parallel and
opposite of the shoulder to elbow axis, and
the resulting design met this requirement
and allowed for an adjustable weight bias for
the shoulder servo if desired.
Two counterweight arms are machined
from mild steel to the specifications
in Design 3 and Design 4, and a center
brace was also machined from mild steel
to the specifications in Design 5. These
counterweight arms and center brace
FIGURE 3 components are zinc anodized to resist
Counterweight arms and center brace sandwich both extrusions of the shoulder C-bracket. This enables rusting, which also gave them an interesting
the heavy counterweights to effectively act as levers without bending and breaking the flimsy aluminum surface finish.
shoulder C-bracket. The weights that are mounted to
the counterweight arms are plates of
matching our required minimum horizontal 0.25 cm thick lead cut and stacked to fit
reach of 60 cm from the waist servo axis to the specifications in Design 6. To allow for
the wrist servo axis. versatility, additional plates are cut to either
Raised-Base Platform: The original allow additional plates to be added to give a
Lynxmotion AL5B 4 Degrees of Freedom raise bias to the shoulder servo pivot point,
Robotic Arm (Hardware Only) kit has a or to allow plates to be removed to give a
ground-to-shoulder servo axis height of lower bias to the shoulder servo pivot point.
6.6 cm, and the project required a height of To mount the counterweight arms to the
20 cm to reach over the chess pieces easily. shoulder C-bracket and center bracket, eight
The raised-base platform face to mount holes are drilled in the C-bracket attached to
the plastic base to is designed as specified the shoulder servo as specified in Design 7 to
in Design 2, with a height of 13.4 cm to bring allow eight screws to hold the counterweight
the final ground to shoulder pivot height arms and center bracket as shown in
to 20 cm. The bottom face of the raised- Figure 3. To mount each lead weight pack
base platform has holes drilled to the same to the counterweight arms as illustrated in
specifications as in Design 2, but instead with Figure 4, two screws and nuts are required.
larger hole diameters to fit the wood screws Chessboard & Chess Pieces: The
for mounting the raised-base platform to chessboard that is used in Project Chess Bot
the plywood main base. Our team opted to is a custom-made chessboard painted to fit
have the raised-base platform manufactured US tournament standard specifications of an
out of aluminum for strength in resisting 18" × 18" playing area with 2.25" × 2.25"
the inertia generated by the robotic arm’s chess squares. This chessboard’s material
movements. However, wood or stronger thickness is 0.25 cm, and is mounted to the
material can easily be used instead as long plywood main base using scotch tape on the
as the maximum diameter of the raised-base underside of the chessboard.
platform does not exceed 12.5 cm, because The plastic felt-bottomed chess piece
the low hanging counterweights need to have set has a king height of 3.75", which was
free space to move without catching on the purchased from
raised-base platform. Plywood Main Base: To ensure that the
To mount the raised-base platform, four robotic control chessboard coordinates
screws, lock nuts, and washers are required arrays remain accurate, the chessboard,
to mount the plastic base to the raised-base raised-base platform (with the robot arm 9

mounted on top), and the robotic controller

hardware is all mounted to one solid base.
This plywood main base is 94 cm × 50 cm
to ensure that everything is comfortably
mounted as specified in Design 8.
Claw Extensions: The original Lynxmotion

robotic arm kit’s plastic claw apparatus is
ideal for tightly gripping small objects such
as our project’s plastic chess pieces when
given precisely programmed instructions.
However, to simplify programming we
opted to make and mount additional claw
extensions to allow the claw servo to be set
to one “grab” position to grip any of the chess
pieces reliably without having to determine
the unique radius of the chess piece to be
grabbed, which would require separate
claw servo “grab” positions for each unique
chess piece, as well as having to program
a separate set of shoulder, elbow, and wrist
servo positions for each unique chess piece
height over each individual square on the
With that in mind, we handmade claw
extensions using aluminum sheeting that
are cut as specified in Design 9, with foam FIGURE 4
blocks that are cut as specified in Design 10 A lead counterweight stack mounted to the bottom tip of a counterweight arm. The extra length of each
and attached to the aluminum using double- mounting screw allows for additional lead plates to be added if desired.
sided sticky tape. The thicker, softer foam
allows the claw to smother each chess piece
using the same “grab” servo positions for all
servos thus avoiding having to compensate ROBOTIC CONTROLLER
for the unique radius and height of each The original Lynxmotion robotic arm
chess piece. kit is compatible with Lynxmotion robotic
It’s certainly possible to implement the controller hardware and software, but we
additional programming required to use the chose to use a Raspberry Pi 3 and 16-Channel
claw without modified claw extensions, but Servo HAT Kit for Raspberry Pi combination
we opted not to as building claw extensions for our robotic controller because we wanted
was much less time-consuming (in our to work from scratch with what we are most
situation) than increasing 450 hard-coded experienced with and is easy to expand
array positions between each of the five further. To replicate the exact functionality in
servos to 1158 hard-coded positions between which Project Chess Bot’s robotic controller is
each of the five servos. Pressure sensors with capable of right now, an Arduino model would
appropriate deterministic programming was have been a good choice as well. However,
briefly considered, but in our time-stricken using a Raspberry Pi 3 instead has allowed
situation it was deemed inappropriate as for greater computerized expandability of a
we would still have to hard-code additional more complex robot than an Arduino model
servo positions for the shoulder, elbow, and would, which is one of the fundamentals of
wrist servos. Pressure sensors are certainly this project concept. Implementations such
on the list of upgrades for version two, and as pressure sensors on the claw, running
is certainly an opportunity for others to build all programs on only the robotic controller,
on if so desired. implementing machine learning image
We had predicted—and confirmed during recognition artificial intelligence, and more
testing—that the claw extension aluminum prompts using a Raspberry Pi over an
plates specified in Design 9 would have to be Arduino model.
improved if we intended to continue to use The 16-Channel Servo HAT Kit for
them as over time the aluminum was not strong Raspberry Pi is used in this project to
enough to resist being bent out of shape. This provide an excluded power supply capable of
issue could be remedied with additional ribbing powering the high-power servos separately
in the next version, but most likely will be from the Raspberry Pi 3 because it is only
remedied with the additional hard-coded array capable of powering a couple of low-power
positions as originally intended. servos under its own power supply without

negatively affecting its computing ability. The through a series of hard-coded coordinates
16-Channel Servo HAT Kit for the Raspberry to execute the chess move. We used Python
Pi uses its own 7.4 V, 2 A power supply of because at the beginning of the project our
which our team used a variable power supply team determined that it would be easier
placeholder. to implement existing image recognition
To interface the robotic controller artificial intelligence, which was written in

hardware with the user interface on a home Python, later in the project. However, as the
computer via USB, a USB to TTL Serial Cable project was being fleshed out, we realized
- Debug/Console Cable for Raspberry Pi is that we were unable to implement image
used. The USB plug is plugged into the home recognition artificial intelligence in the time
computer running the user interface, and that we had remaining in our semester.
the TTL serial cable transmitting (TX) and The robotic controller software begins
receiving (RX) plugs are plugged into the by importing appropriate library modules,
Raspberry Pi 3 through the 16-Channel Servo defining the time delay variables that reduce
HAT Kit for the Raspberry Pi header pins the servos’ speeds, defining four functions
labeled “TX” and “RX”. The remaining input/ that together move the servos, setting up
output (I/O) connections to the Raspberry the Raspberry Pi 3’s serial port, defining
Pi 3 are the servo plugs, with the claw servo the “trans” and “grab” arrays that contain
plugged into PWM0, wrist servo into PWM1, the hard-coded servo coordinates for each
elbow servo into PWM2, shoulder servo into chessboard coordinate, and defining each
PWM3 and waist servo into PWM4 (Figure 5). servo’s default “rest” position.
As for the PC specifications for the project, The first function move() is used to
the Arena 3.5.1 GUI that the Stockfish 8 chess move the servos by translating an angle (in
engine uses is capable of running on Windows degrees) to the appropriate pulse-width-
XP or better on a 64-bit system, however modulation for the servos, and is called by
there are no clear hardware specifications on both the main program loop and the other
the Arena website or the Stockfish website. servo movement functions.
During this project, our team ran Arena 3.5.1 The second function move_waist_
with Stockfish 8 using a PC which ran an Intel slowly() is used to move only the waist
Core i7-3770 processor at 3.40 GHz, 16 GB of servo, which accepts a desired chessboard
RAM with a Windows 10 64-bit OS, and was coordinate to move the servo to, extracts the
also tested to run smoothly on a PC with an waist servo angle, and then moves the waist
Intel Core i3-6100 CPU at 2.30 GHz with 4 GB servo one degree at a time with a small time
of RAM running a 64-bit Windows 10 OS. delay between each degree of movement to
prevent inertial forces from stressing the
CHESS BOT SOFTWARE waist servo. The waist servo’s movement is
The software of Project Chess Bot consists excluded from the other servos as initially
of the robotic controller program running on we wished to avoid stressing the waist servo
the Raspberry Pi 3 and 16-Channel Servo with additional movements from the other
HAT Kit for Raspberry Pi combination, the servos. Once the other movement functions
user interface, the robotic controller, and the had been completed and the program tested,
chess engine to achieve either user control we now believe that the waist servo is capable
or chess engine control of the robotic arm. of moving with the other servos without
Written in Python, the robotic controller causing significant stress to the waist servo,
software is executed in the Raspberry Pi 3’s and is a next step to making this program
operating system and awaits the command more code efficient in the next version.
string from the user interface, which is The third function move_arm _slowly()
translated into moving the robot arm’s servos is used to move the shoulder, elbow, and
wrist servos all at the same time, which
is used for moving the robot arm’s claw
between the “trans” plane and the “grab”
ABOUT THE AUTHOR plane. This function accepts a desired
chessboard coordinate to move the claw to,
Christopher Martin-Rebneris ( is a
extracts the servo angles for the shoulder,
graduate of Camosun College’s “Electronics & Computer Engineering Technology–
elbow, and wrist servos, and moves all servos
Renewable Energy” program, and is currently enrolled in Camosun College’s one degree at a time at the same time with
“Electrical & Computer Engineering Bridge” to the University of Victoria. a small time delay per degree to decrease
After completion of the bridge program, he hopes to complement his studies inertial stress on each servo until all servos
with biomedical engineering, artificial intelligence, and machine learning. have reached their final positions.
He is the founder of Project Chess Bot, and hopes to continue with its future The fourth and final function move_
development. arm _slowly_reach() is used to move
the shoulder, elbow, and wrist servos while 11

/. /.

5# 6  6 
3  A
00* 0 00* 0
<0# B
 57 2 A
2 507 2
! B* B 00*  00* 
,- A
 5 3 A
 50 3

00*  00* 
53 A
2 5 * A
0 50 *
1 0
* 0  
)68# '. 00* 00*
# 0 0
1  0  A
. A
3 A

)68#0  A

#0 )# 03  A
0 ,- ,-
)# A
1 2 ): 0  A

*+ ): A

* A
)68# A
# !9 0  A
 /. /.
@!9 A

1  ,- 0 A


0  A
3 6 0 6 
)68#2 9;1:> A
3 5#
#2 #*   A
#* A

1  # 0  A
 00* 0 00* 0
# A

,- #0  3 A
)68# #0 A
* 57
# # 2  A
0 2 A
* 527 2
# A

#2   A
0 00*  00* 
#2 A
# 02 0* A
# A
 5 52
52# 527 52 52 529 52& 0 A
2 A
 3 A
* * * * * * A
2 00 A
 00*  00* 
,- A

* 5 * A
 52 *
,- ,- ,- ,- ,- ,- ,- # 00*  00* 
0 0
/. ,- ,-

:9 = /.
5* ,-
,  .<- / 0

,- 0
'44 4

moving the robot arm’s claw between take to program it and that it would be easy FIGURE 5
coordinates on the “trans” plane. This to troubleshoot if required. Given more time, This shows the I/O schematic details
function is similar to move_arm _slowly() X-Y-Z vectoring is the way to go to 
achieve for the 16-Channel Servo HAT Kit for
in that it accepts a desired chessboard accurate and graceful movements of this the Raspberry Pi headers. The TX and
coordinate to move the claw to and in that project’s robotic arm, and will be implemented RX header pins are not included

&$  > as
they are in direct connection with the
the shoulder, elbow, and wrist servos are in a future version. )( 
Raspberry Pi 3’s TX and RX pins, and
moved slowly, but also determines if the The definitions for the “trans” and
are labeled on the silk screen of the Pi
elbow servo should move before or after the “grab” plane coordinates are within HAT itself.

shoulder and wrist servos to prevent driving !"#$%
&$ ' (")( %
the chessboard_trans[][] and
the robot arm’s claw into the chessboard. chessboard_grab[][] arrays, with the
While increasing the reach of the robot arm, chessboard_trans[][] array containing
the elbow moves first as this raises the claw hard-coded servo positions that position the
up before the shoulder servo lowers the robotic arm such that the claw is positioned
whole arm. While decreasing the reach of the over each chessboard coordinate on the
robot arm, the elbow moves second as this “trans” plane (4" above the chessboard),
allows the shoulder servo to raise the arm and the chessboard_grab[][] array
before the elbow servo lowers the claw. containing the hard-coded servo positions
The second, third and fourth servo that position the robotic arm such that the
movement functions were planned to be simple claw is positioned over each chessboard
based on our team’s previous servo control coordinate on the “grab” plane (on the
experiences, as we knew that it would be the chessboard). The format of each chessboard
most efficient use of our time to guarantee array coordinate is a string such as “64-53-
movement controls over the robot arm’s 40-13”, with “64” referring to the desired
servos. We had considered exploring X-Y-Z final position of 64 degrees for the waist
vectoring calculations for our servos, in which servo, “53” as 53 degrees for the shoulder
the wrist pivot point is moved along set paths servo, “40” as 40 degrees for the elbow servo,
that calculate dynamic servo movements. But and “13” as 13 degrees for the wrist servo.
since we had no experience with this method These chessboard arrays are referenced by
we decided that it would be a risk to our the main program loop and their contents
schedule in that we may spend more time referenced by the servo movement functions
than expected teaching ourselves and thus to move the servos.
endanger achieving a working project result
by our deadline. With our chosen method, the SERVO MOVEMENT
robot arm’s movements are not as graceful as Now that the program definitions and
X-Y-Z vectoring, but we knew how long it would setup is complete, each of the servos are

moved to hard-coded “rest” positions such remaining element variable capture_

that the robotic arm is folded up and turned required is left alone as a “0” or a “1”.
away from the chessboard to allow for free Next, an if(captured_required)
movement of the opponent’s arm over the statement is used to determine if an
chessboard. With this setup, it is impossible opponent’s chess piece is to be captured. If a
to determine the servos’ positions before capture is required (capture_required is

the program moves the servos to “rest” a “1”), then the if(captured_required)
without using potentiometers or other forms statement executes capturing the opponent’s
of position/angle sensing to read from to be chess piece before moving the chess piece
able to move the servos slowly to their “rest” from the starting chessboard coordinate
positions, so each servo will snap to position to the destination chessboard coordinate.
at their highest capable speed. With this in If a capture is not required (capture_
mind, it is best to ensure that the robotic required is a “0”), then the if(captured_
arm is already positioned as close as possible required) statement is skipped and moving
to the “rest” position so that the servos are the chess piece from the starting chessboard
not under extreme stress during this high coordinate to the destination coordinate is
velocity movement. Our team did consider executed immediately.
adding potentiometers to read the servo’s Upon the execution of the if(captured_
current positions, however time constraints required) statement, the move_waist_
did not allow this to be implemented, so it slowly() function is called and passed
was added to the list of upgrades for the the chessboard_trans[][] array’s
next version of this project. coordinate value based on the destination
coordinate’s X and Y variables to move the
THE MAIN LOOP waist in line with the destination coordinate.
After the servos are first put to “rest,” Next, the move_arm _slowly_reach()
the program enters its main loop and waits function is called and passed the same array
for a command from either the user or the value to move the claw over the destination
chess-engine artificial intelligence, which is coordinate by moving the shoulder, elbow,
sent to the robotic controller program from and wrist servos while considering whether
the user interface program via serial USB. the elbow servo must move before or after
This command is a string that represents the shoulder servo to prevent driving the
the first chessboard coordinate (start) and claw into the chessboard.
second chessboard coordinate (destination) Now, over the destination coordinate, the
that make up one chess move, as well as a move_arm _slowly() function is called and
“1” or a “0”, which represents whether an passed the chessboard_grab[][] array
opponent’s chess piece is to be captured. value to move the shoulder, elbow, and wrist
An example of the format of the command servos at the same time to move the claw
is “5,2-5,4-0”, with “5,2” translated from onto the chessboard destination coordinate.
the starting chessboard coordinate “e2” The claw servo is driven to close the claw
(fifth column, second row) that the user on the chess piece, and is raised back to
would have inputted into the user interface the transportation plane by calling move_
program, and “5,4” translated from the arm _slowly() function and passing it the
destination chessboard coordinate “e4” (fifth chessboard_trans[][] array value used
column, fourth row). The “0” indicates that to position the claw on the transportation
there is not an opponent’s chess piece to be plane destination coordinate.
captured at the destination coordinate. If it This trend continues by calling and
were a “1” then it would indicate that there loading move_waist_slowly() and then
is an opponent’s chess piece to be captured. move_arm _slowly_reach() to move the
After accepting the command from the captured piece on the transportation plane
user interface program via the serial port, to the hard-coded “capture” location outside
these chessboard coordinates are split into of the chessboard playing area, calling and
separate variables that each contain one loading move_arm _slowly() to lower the
of the three elements of the command: captured chess piece, driving the claw to
starting chessboard coordinate, destination open and thus release the captured chess
chessboard coordinate, and whether an piece, and calling and loading move_arm _
opponent’s chess piece is to be captured. slowly() to move the claw back to the
These first two elements are then split transportation plane. The if(capture_
again to result in the X and Y values for required) statement is now exited, and
the starting and destination chessboard the program is ready to move the claw to
coordinates, which will be referenced the capturer’s chess piece using the same
by the chessboard_trans[][] and functions as before: moving the claw on the
chessboard_grab[][] arrays, and the transportation plane to over the starting 13

coordinate, lowering the claw, grabbing piece to the destination coordinate, and
the capturer’s chess piece, raising it back then returning to the “rest” position. After
to the transportation plane, moved on the either chess move is complete (capturing or
transportation plane to over the destination not capturing), then the program loops back
coordinate, lowering the claw, releasing the to awaiting a new command from the user
capturer’s chess piece, raising the empty interface program via the serial port.

claw back to the transportation plane, and
finally moving the claw on the transportation THE USER INTERFACE
plane back to the “rest” position. User control is activated by toggling
What has just been explained is the initial the “Manual Control” radio button on the
movement of the robotic arm from the “rest” user interface (Figure 6), which allows the
position to capture the opponent’s chess piece user to control the robot arm to move their
before moving the capturer’s chess piece. own chess piece and potentially capture an
If there is not an opponent’s chess piece opponent’s chess piece occupying a chosen
to be captured during a chess move, then destination chess square. With the robotic
the if(capture_required) statement controller software running and awaiting
is ignored and thus the robotic arm begins the user’s command, the user types in
instead by moving from the “rest” position the starting chessboard coordinate and
on the transportation plane to over the destination chessboard coordinate into the
starting coordinate, then moving that chess text box to the left of the “Send” button in

Shown here is the user interface for Project Chess Bot. The user will mainly interact by toggling between the “Auto control” and “Manual control” radio buttons, setting the “Engine
think time,” and issuing commands to the robot arm or chess engine via the text box to the left of the “Send” button.

a format such as “e2e4”, with “e2” being the chess move that is the only two-piece move
starting chessboard coordinate, and “e4” allowed in the game as well as the only time
being the destination chessboard coordinate. that a King piece can move two squares
Next, the user either clicks this “Send” rather than one), en passant potential target
button or presses the “Enter” key on their square (a less common chess move that
keyboard. This takes the command and gives the pawn pieces an additional ability

converts it from a string to a character array to capture another pawn whom has moved
(for individual character comparing and two squares), half-move clock (the total
calculation purposes), which then converts combined number of moves that both players
all letters into numbers, then converts the have made), and the game’s round number
character array back to a single string, and (the total number of times that both players
then sends the string through the USB serial have made a move).
port to the robotic controller program.
Meanwhile, chess engine control is THINKING AHEAD
activated by toggling the “Auto Control” radio After the FEN string has been converted and
button on the user interface (Figure 6), which written to the chess engine, the chess engine
allows the chess engine artificial intelligence will begin predicting future potential game-
to play as the black chess pieces for a chess play moves for as long as the chess engine is
game. The current project version can only allowed. The chess engine’s default thinking
play as the black chess pieces (starting the time is one second before it forces itself to
game waiting for the opponent to go first), choose its best determined move based on
and hopefully future versions will allow the the future potential game-play data that it
choice of playing as either the white or the has analyzed in that time period. The chess
black chess pieces. As with user control, engine “thinks” by referencing a downloaded
the user types in the starting chessboard database of table files of previously played
coordinate and destination chessboard games to compare and predict the outcome
coordinate into the text box to the left of the of the current game based on potential moves
“Send” button in a format such as “e2e4” and that it can make next.
activates the “Send” button. However, while This best move is read from the chess
under chess engine control, the command engine in the same format as the user’s
is instead inputted into the chess engine command with a starting chessboard
while the program awaits the chess engine’s coordinate and a destination chessboard
desired move output before sending the new coordinate (example: “e2e4”). This chess
command to the robotic controller program engine command is used to update the FEN
via the serial port. string, which will be passed to the chess
Once the “Send” button is activated, engine again after the user’s next move is
the command is converted and written to made, and is converted and sent through the
the chess engine as a Forsyth–Edwards serial port to the robotic controller program
Notation (FEN) string, which is a standard like when under user control. The current
notation used to describe the current state version of Project Chess Bot’s user interface
of a standard chess game, and can be used is capable of setting the chess engine’s
to recreate or resume a chess game when allowed thinking time period from 1 ms to
each move’s FEN string of a game is analyzed infinity, but is set to a default of one second.
in chronological order. A FEN string contains The chess engine that our team used
multiple pieces of information to record the for this version of Project Chess Bot is
current state of a standard chess game: the StockFish 8, an open-source chess engine
current state of each of the 64 squares on a of which has an ELO rating of 3390. ELO
chessboard, which player’s turn it currently rating is a rating system which rates a
is (white or black), castling ability (a common player’s game ability level compared to other
players of that game, and serves to predict
the outcome of a game match of chess or
other multiplayer competition games where
For detailed article references and additional resources go to:
opponents play against each other one-
on-one, free-for-all in a larger group, or in
teams. A higher ELO rating indicates that
RESOURCES a player or team stands a better chance in
Adafruit | winning a game match against lower ELO
players or teams, and winning a game match
Lynxmotion | transfers points from the loser’s ELO rating |
to the winner’s ELO rating (a draw results in
the lower ELO rated player or team gaining | points from the higher ELO rated player(s) 15

FPGA Boards from JAPAN

SAVING COST=TIME with readily available FPGA boards
or team). With regard to chess, the greatest chess master to Basic and simple features, single power supply operation
be measured by this system, Magnus Carlsen, achieved an Quality and reliability is provided by years of sales
ELO rating of 2882 in May 2014, which on paper draws the All stocked items are ready to be shipped immediately
conclusion that with StockFish 8’s ELO rating of 3390, humans High quality and highly reliable FPGA/CPLD boards from Japan
stand very little chance of defeating it. Typically, StockFish 8
is run via the command line interface, in which a series of ACM-308 is a compact size FPGA board.

commands are inputted to set up the virtual chess game, to
give it your move, and to accept it’s chosen move.
The current version of Project Chess Bot’s user interface is . Intel FPGA Cyclone10 LP
capable of setting the chess engine’s ELO rating to “hard mode” . Configuration Device: EPCS16
at its maximum ELO rating of 3390 or to “easy” mode at its . On-board Oscillator : 30MHz
minimum ELO rating of one. Setting the ELO rating anywhere . 56 I/O (100 mil / 2.54 mm grid)
between these values will be implemented in future versions. . 3.3 V single power supply operation
. JTAG port (10 pin socket)
. Size 2.087" x 2.126" (53 x 54 mm)
Also used in the programming of the robotic controller
software is our custom testing program ProjectChessBot_ EDX-303 is a compact size USB-FPGA board. When executed, this
problem allows for manual control over the angle (degrees)
positions of the waist, shoulder, elbow, and wrist servos all at . XILINX FPGA Spartan-7
once. This was used to move the robot arm exactly to where . 5.0 V single power supply operation
we wanted so that we could record the current positions of . USB Controller: FT2232H (FTDI)
the servos and hard-code them into the robotic controller . Configuration Device: N25Q064
software’s chessboard_trans[][] and chessboard_ . 4Mbit MRAM: MR2A16AMA35
grab[][] arrays. . On-board Oscillator : 50MHz
To use this testing software, only the Raspberry Pi 3 is . Size 2.087" x 2.126" (53 x 54 mm)
RoHS compliant
accessed by plugging in an USB keyboard and mouse, as well as
a monitor into the Raspberry Pi 3’s HDMI port. This allows access
the Raspberry Pi 3’s desktop, and thus allows the execution of and
PLCC68 Series
control over the exact positions of the waist, shoulder, elbow, Stamp size FPGA/CPLD Module
and wrist servos. This is especially useful for modifying the
chessboard_trans[][] and chessboard_grab[][] arrays Designed for 68-pin IC socket
to compensate for other chessboard and chess piece sets if it's Very small size (25.3 x 25.3 [mm])
significantly different from the original specifications. 50 I/Os(External clock inputs are available)
Sadly however, in the very short time that our team was 3.3V single power supply operation
able to test and troubleshoot Project Chess Bot’s user interface
chess engine control software before the end of our semester, INTEL Series RoHS compliant

we were unable to address several major bugs. While running . AP68-09 Series (Cyclone 10 LP)
the user interface user control software, there seems to be . AP68-08 Series (MAX 10)
no bugs present. The bugs related to the user interface chess . AP68-07/AP68-06Z Series (Cyclone V)
engine control software resulted in non-dangerous unusual . AP68-04/AP68-03 Series (Cyclone III)
behavior regarding the chess engine’s move choices, in which
the chess engine will occasionally decide to move the opponent’s XILINX Series RoHS compliant
. XP68-04 Series (Spartan-6)
pieces as if they were its own, will occasionally move chess
. XP68-03 Series (Spartan-6)
pieces as if an opponent’s chess piece is not present, and will
. XP68-01 Series (Spartan-6)
not act to defend its King when it is placed in “check.” From our
. XP68-02 Series (Spartan-3AN)
troubleshooting efforts, we know that the StockFish 8 chess
engine is not at fault as when the chess engine is downloaded
and run in a pre-existing GUI software (such as Arena 3.5.1),
Universal Board for AP/XP PLCC68 Series
none of these bugs are present. We have narrowed down that ZKB-092 . JTAG-BUFFER circuit / JTAG Connecter
the bugs have to do with either the chess engine’s internal FEN . Power input:
string not being updated properly or the chess engine’s desired DC5V/2.1[mm] Jack / Terminal Block
move not being translated correctly. . 3.3V Power Circuit
On the positive side, we plan to continue working on these . Power Switch / Power LED
bugs in the future. This will hopefully prepare Project Chess Bot . Board size : 4.528″x6.102″ (115 x155 mm)
RoHS compliant
for enhanced implementations such as pressure sensors, audio
responses, image recognition artificial intelligence and more.
See all our products, A/D D/A conversion board,
boards with USB chip from FTDI and accessories at :
Author's Note: I would like to thank my fellow Camosun College
graduates, Sol Morris-Janzen and Yi Peng for their assistance on
this project.

Building an
Autopilot Robot (Part 1)

in Action

In this first part of his two-part article

series, Pedro lays the groundwork for his
autopiloted four-wheeled robot project. Here,
he shows the complete path in digital signal
processing (DSP) to go to from raw acceleration
measurements—obtained from a BeagleBone
Blue IMU—to reliable speed estimation using
accelerometer data.

Pedro Bertoleti

A t some point in their projects,

almost all embedded system
designers have to deal with
sensing environment variables.
Reading from sensors and turning those
readings into reliable data requires DSP
repository, the link to which is provided on
the Circuit Cellar article materials webpage.
Table 1 shows the project’s parts list. This
project uses a BeagleBone Blue board as its
logical unit, sensor unit and motor driver
unit. I chose this board because of its rich
and some special mathematical approaches. set of resources, including on-board sensors,
These tools are especially helpful for sensor interfaces, LiPo battery, motor
getting proper data from accelerometers. control, wireless connectivity and powerful
Measurements from accelerometers SiP. This enabled me to minimize the use of
are usually too noisy to use directly, for external and auxiliary circuits, and create
estimating speed, for example. With that a full robotics solution that’s compact and
in mind, this article series looks at how to simple. Figure 1 shows BeagleBone Blue
employ DSP and mathematical solutions board and its list of features and peripherals.
when using accelerometer data to estimate— For the software part of this project, the
as close as possible—speed in a practical following are used:
project. And the practical project we’ll use
is a four-wheeled robot containing four DC Operating System: Debian Linux
motors. This article shows how to apply Programming language: C
these approaches to robot speed control Compiler: GCC
using PID control when crafting the robot’s Sensors and drivers API: Robotics Cape
autopilot system. Additional libraries: Paho MQTT
This project is completely open-source. for Internet control and monitoring
Its source code is hosted in a Github 17

Octavo OSD3358 SiP with TI Sitara AM3358 at 1 GHz with

2x 32-bit 200 MHz PRU MCUs

512 MB DDR3 RAM (on SiP); 4 GB eMMC flash; microSD slot

802.11bgn (2.4 GHz) and Bluetooth 4.1 BLE via TI WiLink
1835; ext. antennas; GPS and DSM2 radio interfaces
8x 6 V servo out (4 A reg.)
Motor control 4x DC motor out (4 A reg.)
\ 4x quad encoder inputs
Sensors 9 axis IMU; barometer
Micro-USB 2.0 client port with power support
USB 2.0 host port
6x UARTs
Other I/O 8x GPIOs
2x SPI
4x ADC
Other Power, reset, boot and 2x user buttons; 11x configurable
features LEDs; power and charger LEDs; JTAG
2-cell (2S) LiPo battery JST-XH connector with balancing;
9-18 VDC jack; micro-USB
Operating Debian with real-time kernel; optional Ubuntu Core;
system supports ROS, ArduPilot, Cloud9 IDE on NodeJS

BeagleBone Blue and its features and peripherals

Links to more information about those integration in a computing system. All the
software elements are provided on the software has to do is calculate a trapezoidal
Circuit Cellar article materials webpage. area, considering current acceleration and
the previous one. For better understanding,
MATHEMATICAL OVERVIEW refer to Figure 2. This equation shows the
This project focuses on estimating speed
using only accelerometer as a source of Acceleration
data. Mathematically, the variation of speed
in accelerated movement can be achieved by
integration of the acceleration over time, as
shown in this formula: acc(t1)
∆Vt 0→ t1 = ∫ acc( t )dt

t0 (1)

Also, the instant speed can be calculated

by the sum between acceleration integration
over time and initial speed, as shown here:

Vinstant =Vinitial +∆Vt 0→ t1 (2)

Geometrically, integrating a function t0 t1
curve produces the same result as the
graph area between function curve and FIGURE 2
the X-axis. This enables easy acceleration Geometric equivalence of acceleration function integration (from t0 to t1)

geometric area calculation (acceleration adjusted, depending on the desired software

function integration, from t0 to t1) is: complexity. The main equations for every
PID control system are shown here:
acc( t 0) + acc( t1)
∆Vt 0→ t1 = ( t1 − t 0) × e( t1) = PV − setpoint
2 (3) (4)

PID = K P × e( t1) + K I ×

Finally, once speed based on accelerometer

data is calculated, the speed control tasks can de( t1)

do their work. To control speed, this project e( t1)dt + K D ×
uses PID control. PID control is among the t0 dt (5)
most commonly used control techniques in
automation and industrial systems. Briefly, where:
here’s how it works: A PID block controls
a variable (called “process variable” or PV) t0: time instant of a previous measure of
using periodic error comparison between process variable
a current measurement and what value t1: time instant of a current measure of
you desire for a variable (called “setpoint”) process variable
This takes into consideration three terms:
P- proportional term, I - integral term Although, it isn’t explicit in Equation 5,
and D - derivative term—and the gains the derivative term also considers t0 and t1
(K P, K I and K D), in a closed-loop system. for its calculation.
The gains can be automatically or manually
An accelerometer is a device that allows
to get acceleration in one, two or three axes
Acceleration – Y – Axis (x, y and/or z). Because they’re so widely
used, accelerometers are often part of an
Inertial Measurement Unit (IMU). In the
0.95 case of this project, the IMU chip contains
an accelerometer that measures three-axis
0.9 acceleration, meaning that it can measure
acceleration in every spatial direction. In
Acceleration – Y – Axis
(m/s2) 0.85 fact, the acceleration measured equals
the acceleration that is applied to the
accelerometer IC. Accelerometers provide
0.8 communication interfaces that enable them
to be used in computing systems—I²C
0.75 interface being the most common of these.
0 0.2 0.4 0.6 0.8 1 1.2 1.4
Getting deeper into microelectronics,
Time (s)
an accelerometer can be part of a group
(a) of systems called MEMS (Micro Electro
Mechanical Systems). MEMS combine
Acceleration – Y – Axis mechanical and electrical micrometric scale
6 systems to get measurements that depend
on inertial/mechanical stimulus. Popular
4 examples of MEMS are accelerometers and
gyroscopes. These technologies are used
for sensors in drones, remote controlled
vehicles and portable healthcare equipment.
Acceleration – Y – Axis In short, MEMS make is possible to acquire
(m/s2) 0 mechanical and/or inertial measurements
that computing systems can process. This
−2 makes them vital tools for sensing the
“outside world” of embedded systems.
One drawback to accelerometers is that
0 0.5 1 1.5 2 the raw measurements they produce aren’t
Time (s) so reliable. The data can consist of a very
(b) noisy signal that contains a lot of spikes.
The graphs in Figure 3 provide an example
of noise present in raw accelerometer
measurements. Figure 3a shows raw
Y-axis acceleration data: no movement (a) and harsh movement (b) accelerometer data (Y-axis) when an 19

Acceleration Discrimination window and valid signal
Valid positive signal zone


Time window

Valid negative signal zone

accelerometer is standing still. And Figure acceleration means speed variation over
3b shows raw accelerometer (Y-axis) data time, so these tiny values of acceleration
when accelerometer is submitted to harsh don’t make sense because the accelerometer
movements. From observing these graphs, is standing still (no movement condition).
it's possible to infer that raw accelerometer This fact brings us to the conclusion that
measurements are very noisy and require “too low” acceleration values must be
DSP techniques to generate useful data. ignored from further calculations that
By Figure 3 analysis it’s possible to require reliable accelerometer data. In DSP
infer that, even standing still, acceleration terms, “ignoring tiny values” means applying
measurements rarely tend to produce a zero the discrimination window technique. This
value. At a closer look, there’s a tiny offset technique consists of setting to zero every
in these measurements (systematic error). measurement that fits in a zone called the
Although these acceleration distortions are discrimination window. The discrimination
tiny, they are relevant enough to ruin the window and valid signal zones are shown in
speed estimations in further calculations. Figure 4.
One way to minimize this tiny offset in Based on Figure 4, all measurements in
accelerometer measurements is to perform both valid signal zones (valid positive signal
accelerometer calibration before any other zone and valid negative signal zone) will
acceleration usage and/or manipulation. remain unmodified and all measurements
Calibration consists of these steps, which must that fit in discrimination window will be set to
be done for every accelerometer axis used: zero. This discrimination window technique
ensures that low-amplitude noises are
1. Several consecutive measurements are completely filtered. That makes the resulting
made and summed. signal more reliable for further calculations.
2. After the reading process, the Getting deeper into coding this technique,
measurements’ mean is determined. This the discrimination window technique code is
mean corresponds to an acceleration offset. shown in Listing 1 (extracted of the current
3. Once this offset is calculated, it must project’s code).
be subtracted from every raw acceleration
measure, what minimizes the systematic
#define DISCRIMINATION_WINDOW 0.3 //m/s²
Most accelerometers available on .
market support sensibility adjustment. .
Sensibility adjustment means configuring .
the acceleration range, usually in “G” units
(1 G = 9.8 m/s 2). The greater the range,
the lower the sensibility. The sensibility float verify_discrimination_window(float sample)
adjustment must fit the acceleration limits {
of your project. In the particular case of if ( abs(sample) <= DISCRIMINATION_WINDOW )
this project, the maximum acceleration per return 0.0;
axis is about 0.6 g. The options available for else
accelerometer sensibility range are: ±2 G, return sample;
±4 G, ±8 G and ±16 G. Therefore, the ±2 G } }
range fits best for this project. }
Based on Figure 3, it can be inferred that
even when the accelerometer is standing still, LISTING 1
its measurements are very noisy. Physically, The discrimination window technique code corresponds to the code snippet shown here.

The majority of accelerometers available Also keep in mind that the accelerometer
on the market offer some options for measurements MUST be processed in regular
configuring sample rate. Sample rate in period/time intervals. Being sloppy here
an accelerometer means the number of can lead to incorrect speed estimations.
measurements that can be acquired per Every accelerometer sample matters and
second. This sample rate is represented in every single calculation error will be carried

Hertz units: Hz. on every speed calculation, ruining all

When estimating speed by using calculated speed estimations. To ensure that
accelerometer data, every single the accelerometer data is being processed
measurement acquired matters, because exactly when it’s ready (in 5 ms time
speed will be calculated by integrating intervals), like an IRQ-oriented calculation,
acceleration over time. Therefore, to ensure the Robotics Cape API provides a very
better results, the sample rate should interesting resource called DMP mode.
be set as the maximum value allowed by In DMP mode, a software interrupt is
the accelerometer. In this project’s case, triggered every time a sample is ready to
the maximum sample rate allowed in be read, and every measure is stored in a
accelerometer is 200 Hz. That means that FIFO queue (this ensures no accelerometer
one new accelerometer measurement sample data is lost). Also, it allows the programmer
is available every 5 ms. to set a function to be called when this
interruption comes up (very similar to
IRQ-function determination on bare-metal
firmware development). Therefore, the DMP
mode ensures regularity on processing
accelerometer data.
Acceleration – Y – Axis (raw and filtered)
Now let’s look at filtering accelerometer
data. This is one of the most crucial steps
5 for speed estimation by accelerometer data.
Even if all previous steps have been done
well, if this step fails the speed estimation
Acceleration – Y – Axis 0 is ruined. To filter accelerometer data, two
(m/s2) filters can be applied consecutively: a native
accelerometer filter and a filter based on
consecutive sampling;
Most of accelerometers offer native
−10 filtering—for example, low-pass filters. In
0 0.5 1 1.5 2 this project, the accelerometer offers low-
Time (s) pass filters, with the following options:
(a) 184 Hz, 92 Hz, 41 Hz, 20 Hz, 10 Hz and 5 Hz.
In the particular case of this project, the best
results were achieved using the 41 Hz low-
Acceleration – Y – Axis (raw and filtered) pass filter according to results determined
by empirical tests.
For the filter based on consecutive
4 sampling (no-native accelerometer filter),
there are a lot of options. Every project
2 can use different filters here, depending on
Acceleration – Y – Axis project’s requirements. That said, there are
(m/s2) 0 two filters that deserve special attention
when talking about filter acceleration
measurements: the Kalman filter and the
−2 Moving Average filter.
The Kalman filter works great for
−4 accelerometer filtering, due to two particular
0 0.5 1 1.5 2
characteristics. First, it provides automatic
Time (s)
adjustment during use—the more it’s
(b) used, the more accurate it becomes. And,
second, it has to capability to predict states.
That means it can restore accelerometer
These graphs show the acceleration raw and filtered data from harsh movement for the X-axis (a) and the
measurements even with transients on
Y-axis (b). Raw measurements are represented in blue and handled measurements are represented in red. measurements. 21

Even thought it’s a great filter, the Therefore, the speed calculation (for each
Kalman filter is very complex to implement axis) can assume one of these possibilities:
and requires a lot of CPU usage, which isn’t
good for very high sample rate systems. In Ascending acceleration (acc(t0) < acc(t1)):
contrast, the Moving Average Filter is perhaps Equation 6
too simple. Its calculation is very intuitive Descending acceleration (acc(t0) > acc(t1)):

and doesn’t require high CPU usage. Despite Equation 7
its simplicity, the Moving Average Filter Both accelerations measurements are the
works well for acceleration measurement same (acc(t0) = acc(t1)): Equation 8
filtering and can be easily implemented and
monitored. With this project, the Moving It’s important to remember that all
Average Filter results were satisfactory these calculations must be made on every
and the performance was very good, so it’s acceleration sample acquired. Therefore,
a good choice. Figure 5a and Figure 5b following the calculations above, it’s possible
show how effective all the signal handling to determine the instant speed in X-axis and
applied has been so far for X- and Y-axis. Y-axis. Here, we’re assuming the Z-axis is
Raw measurements are represented in blue measuring gravity acceleration, which isn’t
and handled measurements are represented relevant on this project. As these instant
in red. speeds are modules of X- and Y-axis velocity,
the module of the resulting velocity can be
SPEED CALCULATION determined as shown in Equation 9.
Finally, after all the DSP steps we’ve Even with all the care and handling with
discussed so far are done, the accelerometer DSP so far, something else can still ruin
data is now reliable for further calculations. speed estimation: accelerometer hysteresis.
To calculate speed based on accelerometer Unfortunately, acceleration measurements
measurements, the formulas shown in hardly get back to zero acceleration when
Equations 3, 4 and 5 are required. The accelerometers are submitted to a cycle of
initial speed is defined as zero—naturally, increasing and decreasing accelerations and
because when powered on, the robot will be that shows clearly as hysteresis.
standing still. The consequences of ignoring this
Considering two consecutive acceleration behavior are bad. Because speed is
measurements acquired, consider these calculated strictly based on accelerometer
formulas to calculate speed based on data, the residual acceleration effect
acceleration in two consecutive times (t0 will cause significant errors on speed
and t1): calculation—mainly when the accelerometer
is standing still (no-movement condition).
Vinstant (t1) = In this case, this residual acceleration will
acc( t 0) + acc( t1)  be part of an integration calculus of speed,

Vinstant (t0) + ( t1 − t 0) ×  so each residual acceleration measurement
 2 (6) will increase the calculated speed a little
Vinstant (t1) =
bit. For better understanding, observe
 acc( t 0) + acc( t1)  Equations 1 and 2. Therefore, even with
Vinstant (t0) − ( t1 − t 0) ×  the accelerometer standing still, there are
 2 (7) plenty of chances of speed being above zero
Vinstant (t1) = and getting higher and higher continuously.
To handle accelerometer hysteresis,
Vinstant (t0) + [ ( t1 − t 0) × acc( t 0) ] (8) a very simple technique can be applied:
the movement end check. This technique
consists of counting how many times

Vinstant − xy = Vinstant − x 2 + Vinstant − y 2 acceleration (in each axis) is equal to zero
(9) and, if this counter reaches a predetermined
limit, the speed of forced to zero. The code

Acceleration Configuration Configuration Value

Sensibility (or accelerometer range) ±2 G
Sample rate 200 Hz
Native filter frequency (LDFP) 41 Hz
Sample handling mode DMP
Accelerometer configuration

in Listing 2 (extracted from the current the native IMU from BeagleBone Blue board,
project’s code) implements the movement the configurations (and values) must be set
check end feature. as shown in Table 2.
So now all the DSP techniques and Once the IMU accelerometer is configured,
approaches to estimate speed using now accelerometer calibration must be
accelerometer data are known and reliable made. Reminder: for calibration ONLY,

speed estimated data can be calculated. But accelerometer samples must be acquired in
in what order must these DSP concepts be normal (no-DMP) mode. After accelerometer
applied? First of all, before using any DSP calibration, the acceleration sampling begins
techniques, the accelerometer must be (in DMP mode). Before any action on DSP, the
configured correctly. Therefore, considering moving average filter buffer must be filled.



void refresh_movement_end_check_counter(float acc_t0, float acc_t1, unsigned int *

if ( (acc_t0 == 0.0) && (acc_t1 == 0.0) )
*ptrCounter = (*ptrCounter) + 1;

if (*ptrCounter == UINT_MAX)
*ptrCounter = 0;


void instant_speed_calculation(float accX_t0, float accY_t0, float accX_t1, float accY_t1)


refresh_movement_end_check_counter(accX_t0, accX_t1, &accx_movement_end_check_counter);

refresh_movement_end_check_counter(accY_t0, accY_t1, &accy_movement_end_check_counter);

instant_speed_x_axis = 0.0;
if (accx_movement_end_check_counter < THRESHOLD_MOVEMENT_END_CHECK)
instant_speed_x_axis = speed_x_axis + calculate_delta_speed(accX_t0, accX_t1,

instant_speed_y_axis = 0.0;
if (accy_movement_end_check_counter < THRESHOLD_MOVEMENT_END_CHECK)
instant_speed_y_axis = speed_y_axis + calculate_delta_speed(accY_t0, accY_t1,

speed_y_axis = instant_speed_x_axis;
speed_y_axis = instant_speed_y_axis;


This code implements the movement check end feature. 23

Finally, after this moving average buffer effects on speed calculation, the “movement
filling, the full DSP handling starts. For every end check” technique must be applied.
sample acquired from now, the following
steps must be done: Important: these steps must be applied to
X- and Y-axis accelerations simultaneously.
1. The acquired acceleration sample is

applied to a discrimination window, resulting
in a sample called “window discriminated Once speed is calculated, it can be
sample.” controlled. To control speed, one of the best
2. The window discriminated sample is choices is using PID control—a widely used
applied to a moving average filter, resulting control solution in automation and industrial
in a sample called “filtered sample.” systems. PID control allows short-time and
3. After two filtered samples, it’s time for smooth reaching to a desired value of a
speed calculation. variable—in this case, speed. This means
4. To avoid accelerometer hysteresis side- that, even if a robot’s mass varies during


typedef struct {
float setpoint_pid;
float last_error;
float integral_acum;

static TPIDController PIDController;


float calc_PID(float process_variable, float time_step)

float current_error;
float p_factor;
float i_factor;
float d_factor;
float pid_final_result;

current_error = PIDController.setpoint_pid - process_variable;

p_factor = KP_CONSTANT * current_error;

i_factor = PIDController.integral_acum + (KI_CONSTANT * current_error * time_step);

PIDController.integral_acum = i_factor;

d_factor = KD_CONSTANT * ( (PIDController.last_error - current_error) / time_step );

PIDController.last_error = current_error;

pid_final_result = p_factor + i_factor + f_factor;

if (pid_final_result > PID_MAX_LIMIT)

pid_final_result = PID_MAX_LIMIT;

if (pid_final_result < PID_MIN_LIMIT)

pid_final_result = PID_MIN_LIMIT;

return pid_final_result;

This shows how to code a PID control in C language.

next to it again) produced by integral term.

ABOUT THE AUTHOR The gain of derivative term must be empiric
set in most of cases.
Pedro Bertoleti is a Brazilian embedded system engineer and publisher on a
Brazilian embedded systems website called Embarcados at www.embarca- Like any control technique, PID control He has strong experience in development with PIC, ARM Cortex has some interesting practical “tricks.”

M0 and M3 and Rabbit RCM22xx microcontrollers. Bertoleti also has knowl- When applying PID control you normalize
edge in IoT projects and Embedded Linux Embedded Systems development. the process variable when process variable
controller allows normalized values. This is a
good trick because it allows direct application
of the PID final result to the controller. I
adopted this trick is in this project, making
the PID final result the input for the motor
its movement and/or pavement conditions PWM controller.
change, its speed will reach the desired At the end of the PID value calculation,
value. It’s like having someone controlling a you should check if its value is above the
robot’s gas pedal to keep constant speed. maximum allowed. Mainly on the first PID
As shown in Equations 4 and 5, PID control calculations (when process variable is far
consists of a combination of three distinct from setpoint value), the PID result may
terms: a proportional term (gain: K P), an assume values that are too large, so this
integral term (gain: K I ) and a derivative verification ensures valid results of PID
term (gain: K D). Simply put, a PID controller controller.
works by continuously minimizing the error: While you might not expect so, the
process variable (what you want to monitor calculation of a PID term in a computer
/ want to control) minus setpoint (process program isn’t that complex to code. All
variable desired value). In few words, each you need as inputs are the current error
term of PID has a distinct purpose on PID and previous error results. The code in
control action, as follows: Listing 3 (extracted of the current project’s
code) shows how to code a PID control in C
Proportional term: This term is language.
responsible for approximate the process
variable from setpoint value quickly. The WHAT’S NEXT?
gain of proportional must be big enough to By now, doing speed estimation using
ensure quick approximation to setpoint value accelerometer data and speed control using
and precise enough to ensure the process PID concepts should be clear in your mind. To
variable doesn’t go too far from set point. directly apply these concepts and bring them
Integral term: This term is responsible to the real world, we’ll tackle an interesting
for minimizing the error produced by project in the second part this article’s
proportional term. The gain of integral series: an autopilot electrical robot.
should be much smaller than proportional In this article, we presented (and solved)
term gain, otherwise the time for process a challenging task that every embedded
variable achieve setpoint value will be very systems designer will face at least once
large. when designing embedded systems projects:
Derivative term: This term is the most How to get reliable data from inertial
peculiar one. Its purpose is related to sensor measurements—in particular, an
minimize error in process variables that accelerometer—and how to do speed
has highly increase or decrease over time. estimation using the reliable accelerometer
Also, derivative term can reduce overshoot data. This task requires non-intuitive DSP
(overshoot: when a process variable goes too techniques and mathematical approaches
far from setpoint and has a big delay to get that must be carefully analyzed in order to
get relevant accelerometers samples in real-
world situations. We also discussed briefly
how PID control works in speed control and
provided some tips on using PID control.
By understanding these two concepts—
For detailed article references and additional resources go to: speed estimation and speed control—we've laid the groundwork for building an autopilot
electrical robot. In part 2 of this article
RESOURCES series, we’ll dive into the actual building of |
this robot." |
Early Bird Registration Is Now Open!
16th International System-on-Chip (SoC)
Conference & Exhibit
October 17 & 18, 2018 - University of California, Irvine - Calit2
Five Enlightening Keynotes on Emerging SoC Technologies
Keynote Speakers

Intel Corporation ON Semiconductor LG Electronics NXP Semiconductor University of California,

Dr. Naser Adas, Dr. Hans Stork, Senior Dr. Yasser Nafei, Dr. Robert Oshana, Vice Irvine (UCI)
General Manager Vice President and Chief Sr. Vice President LG President Software Dr. Nader Bagherzadeh
Edge & IOT Technology Officer Electronics Mobile Engineering Research Professor, Electrical
Infrastructure. (CTO). Communications. and Development, Engineering and
Microcontroller Group. Computer Science.

Platinum Sponsors

Farhad Mafie, SoC Conference Chairman, Moderating two Informative Panels:

“AI and Machine Learning driving the Intelligent Machines:

Will the Technological Singularity Happen?"

“Are you ready for the Blockchain of Things? Blockchain & Semiconductors
Economy – Hypes, Realities, and Opportunities."

Selected Presenting Companies & Universities

For More Information or Questions, Please Contact the SoC Conference Organizing Committee at: or (949) 981-1837 & (949) 356-2399


Power Line Communications

Using a Cypress PSoC

In this project article,

Aubrey guides us through
his efforts to build a power
line communications
solution based on Cypress
Semiconductor’s PSoC
technology. The design
involves a central controller
linked to a maximum of
100 outstations linked by
14 AWG cable over a distance
of 1,000 feet, and a network The PCB measures about 6.5" x 4". There are a significant number of inductors that
voltage of 24 VDC. you can see. Some are for isolating the PLC communications signals from the internal
power supply. Other inductors are for 3 switch-mode power supplies on board—two
of which provide 5 V to the MCU and 10 V to the transmission power amplifier.

Aubrey Kagan

M e and my big mouth! Several

years ago, I penned a two-part
blog titled “Combining power
and data wires.” In it I was
rather flippant about transmitting data over
a power line. In retribution, the universe
the CY8CPLC20, along with development kits
for AC (CY3274) and for DC (CY3275, now
obsolete). I contacted Cypress about the
CY8CPLC20, but they encouraged me to look
at the port of CY8CPLC20 to the PSoC5, as
detailed in their application note “AN76458
saw fit for me to receive a phone call several - PSoC5LP High-Voltage (120-240 VAC)
months later asking if I would design a PLC. Powerline Communication Solution.”
Now, in my field a PLC is a Programmable It is no secret that I am a PSoC aficionado.
Logic Controller. I wondered why someone And given that the PLC in the application note
would want to try to compete with the likes of is largely a software configuration loaded
Allen Bradley at the upper end of the market onto a standard chip, that would leave me
or Automation Direct at the lower end. Well, the rest of the device’s resources all in a
it turns out that PLC can also stand for Power single chip. So that’s the way I decided to go.
Line Communication—and for the purposes This article is not intended to be stand-alone.
of this article that’s what PLC means. You will need to have read AN76458—the
There are several systems-on-chip (SoCs) link is provided on the Circuit Cellar article
aimed at this market—or at least aimed at AC materials webpage. For proprietary reasons
(alternating current) PLC. Among them are I cannot show my complete circuitry, but I’ll
a product line from STMicroelectronics, the detail the changes that you need to make to
On Semiconductor NCN49597, the Microchip/ the circuits in AN76458.
Atmel ATPL230A and more—including one Our customer had previous negative
from Cypress Semiconductor. Let me make experience with communications over RS-485
full disclosure that my employer is Cypress and fiber-optic cable, and so his consultant
Design Partner, and therefore, the Cypress insisted on PLC. The design involves a
offering looked rather attractive. Cypress central controller linked to a maximum of
produces a PSoC1 pre-programmed device, 100 outstations linked by 14 AWG cable over 27

a distance of 1,000 feet (300 meters). The ."

voltage to be used over the PLC network was
24 VDC. 32

The Cypress PLC offering is basically peer


to peer, but conceptually I’ve molded it to a

master-slave arrangement. It also had some ." 2

bells and whistles such as frequency hopping (+

to improve communication reliability, but I’ll

discuss that later.
3 3'
& 5 .**" 1( (
/ 1-
899 /0
' ''

(+ 1-
To help with the marketing, Cypress had
created a development board to demonstrate 3
the system‘s operation. Unfortunately for me, 

these are no longer in production. So instead 3'-

I had to use the schematics in the application


note as a basis for creating our own board—

this was an intermediary step to prove the
concept. You can see the result in Figure 1. FIGURE 2
I have to admit that establishing Shown here is Fig. 12 from AN 76458 with my addition of two resistors circled in red. This reduced a problem
communications proved quite difficult, and I I was having with spurious oscillations during transmission. The oscillations were later traced to a missing
actually had to modify the configuration of component so I am not entirely sure the resistors are necessary, but they have remained (Source: Cypress
the microcontroller to generate continuous Semiconductor).
transmission signals to follow the signal
through the circuit. But again, I will get had developed many years ago to the circuit.
to that later. I had followed the circuit in It did not go well! Being pressed for time, I
AN76458 very closely, and in the end found I opted to take a simple approach and used     #4
only had to modify it slightly (Figure 2). a 3.9 mH 1.8 A inductor in series with the
The only major difference in my design is power supply. The Bourns 1140-392K-RC %#&# '
the interface to the DC line. That’s because was highest inductance/DC current I could
the application note deals with coupling to find ex-stock for the approximately 150 kHz
carrier frequency of the !"#$%#&# '( )!*) $
an AC line. Fig. 18  
in AN76458 describes the PLC. It worked
connection to the AC power line. I replaced it perfectly, so I never returned to try and
with the circuit shown in Figure 3. resolve the gyrator problem. All that said, I
One of the problems with superimposing did add circuitry for my own project.
an analog waveform onto a DC power line is
the DC power supply presents an AC short PSOC CONFIGURATION
circuit. In my aforementioned blog, I spoke For those of you unfamiliar with the
about using a gyrator as a low-pass filter for architecture of the PSoC5, it consists of an Arm
the DC power. I connected a gyrator that I M3 core and, more importantly, an FPGA-like

@2 @+
), )*A )*A
694 !1)18@6 !1)18@6

B ;

9@$ 4 69

.A6 1 

The PLC network connects to the
“POWER IN” connector (TB2). The
&)* 0R resistors between “POWER IN”
/+2 and “POWER OUT” connectors were
@< @
removed during development so
that the power to the MCU would be
= ?4)4()!6 )<241<1
%01! 2 1<)*A

&)* isolated and communications could be

(78 attempted without the complication
0.1* ( !34!55% of cross-talk problems. There is a
glimpse of Cypress’ power transmitter
on the left. The point at the junction
(78 of C35, CR7, R67 and L7 corresponds
to the “To Coupling Circuit” in Fig. 14
and “From Coupling Circuit” in Fig. 16
of the application note.

Shown here is the base schematic of Cypress’ implementation of the PLC. I have indicated (circled in red) the reconfiguration that I added to send a continuous signal when
desired. It is possible to send a continuous logic one or zero or a continuous switching waveform at 2,400 Hz. Turning on the FSK Modulator (via API) will also activate the external
transmission circuit. I use external DIL switches to invoke this test.

fabric to enable the creation of peripherals. ways. When you download the project, you will
There is a wide variety of peripherals such as find Cypress has termed one as “NoComponent”,
serial port, analog-to-digital converter and made up of individual components—and the
so forth. Each peripheral comprises a bunch other as Component in which the smaller
of logic and analog circuitry—conceptually components are encapsulated in larger
encapsulated as a “component.” PSoC components and not directly accessible. All
Creator is the tool that allows you to place of these Cypress components come with a
these components into the configuration that datasheet so you know how to use them. I
you want. All components that are directly don’t want to get too deep into that or this will
included in Creator are tested in the extreme become a really lengthy article.
to eradicate internal bugs. It is possible, I had initial problems starting both project
however, to create your own components or approaches because of version changes in
collection of components in various degrees Creator, but these were quickly resolved.
of encapsulation. Working with the Component version while
The PLC was developed using that method. I was simultaneously struggling with the
In fact, it’s possible to implement the PLC in two hardware was difficult because of the
lack of control of the interior parts of the
component. Therefore, I developed the proof
of concept using the NoComponent version.
As I progressed with the design, Cypress
suggested I change to the Component
version. The reason that frequency
hopping (stay tuned) is not available on the
NoComponent version, and many useful API
calls in Component would ease development.
So, I made the change.
I found several issues with the PLC
implementation (and I have to repeat myself
by saying we will get there). One issue
was how to test the system in production.
If there is some problem, how would you
trace the signal? The beauty of the PSoC is
that it allowed me to add some additional
circuitry internally to produce a continuous
This photo shows the timing relationships. The leading edge of analog trace “A1” represents when the “TX_
transmission (Figure 4).
COMPLETE” flag indicates that the transmission is complete. Analog trace “A2” represents the transmission
on the PLC bus. The greater amplitude of the burst is the outgoing signal and the lesser is the return
Principal features of the Cypress PLC
handshake from the destination. As you can see the delay before the message starts is 100 ms and is only are listed as protocol collision detection,
completed after about 280 ms. Digital trace “2” represents the “manufactured” internal flag. frequency hopping, one of two center 29

communications frequencies, adjustable

baud rate, logical and physical addressing, void PLC_Demo_Process(void)
individual and group addressing and {
adjustable receiver gain. Frequency hopping uint8 txStatus;
is a bit of a misnomer in my mind. The PLC static uint8 transmitDelayEnabled = 0;
will switch between the two possible center static uint16 transmitDelayTime = 0;

frequencies to optimize communications. //volatile uint8 cTemp1[8];
But, to me, frequency hopping implies //uint8 cTemp2[8];
multiple frequencies. /* Process any new received messages */
The resultant hardware uses quite a if (Network_Protocol_ReadRxStatus() &
lot more real estate than a simple serial
interface. Admittedly, I didn’t push the PCB

designer to be compact. In fact, the board
only has components on one side, and we

only used 0805 components (or larger) to if (txStatus & Network_Protocol_TX_COMPLETE)
allow for component replacement by an aged {
engineer (pause to take a bow). However, it
is something to be considered. //SUCCESSFUL TRANSMISSION DETECTED HERE
SOFTWARE plc_demo_mode=0;
As I mentioned previously, this article is
not intended to be stand-alone. You will need //turn off flag when successful
to have read the Cypress Application Note //transmission recieved
AN76458 and I want to get into the changes TP6_Write(0);
to the software necessary to implement a iStatus &= ~SINGLE_TRANSMISSION_STARTED; //B
real-world system. My remarks would be //flag to indicate transmission is over
true for both DC and AC PLCs. //used to determine next step in
It can be really hard to follow software //overall transmission
written by someone else, especially when
you have been self-trained over the years. Network_Protocol_DisableTxLineLoading();
So, it took a while to adapt the sample }

program. There is a generic flow chart in

the application note (page 6) showing how to
if ((plc_demo_mode & 0x01) && (Network_Protocol_
implement the Network Protocol. But since I
ReadTxStatus()==0x00) && (transmitDelayEnabled == 0))
was trying to get the Cypress program to work
without proven hardware, I stayed mostly // PLC_DEMO_MODE set to 1 initiates communication
with the original. The Cypress software was if (cGroupSend)
developed purely for two modules talking to {
one another as a closed system. In my world Network_Protocol_SetDestinationAddress(Network_
I had to expand beyond that. Protocol_DA_TYPE_GROUP,(uint8*)&cGroupAddress);
It appears that the frequency hopping is Network_Protocol_LoadTxData(Network_Protocol_
not entirely handled by the network protocol CMD_DATA, (uint8 *)&cTransmitData[0],
component, based on the software example. cNumberOfTransmitBytes);
And that was another reason to stay with the }
tried and true example. I slowly stripped out else {
the different parts as I analyzed and decided Network_Protocol_SetDestinationAddress
they were irrelevant to my needs. (Network_Protocol_DA_TYPE_PHYSICAL,
During development, I found that (uint8 *)&cPhysicalDestination);
some messages were not being received. Network_Protocol_LoadTxData(Network_Protocol_
On investigation, I found a deficiency in CMD_DATA, (uint8 *)&cTransmitData[0],
the Network Protocol. The deficiency was cNumberOfTransmitBytes);
allowing me to write a new message before
the existing message and its handshake //set flag that individual tranmisson starts
had been completed. I was expecting the
Network _ Protocol_ ReadTxStatus()
function would return the TX_COMPLETE
flag as true when it was OK to send the next
byte, but it did not function as I expected.
I had to create an internal flag to identify
when the transmission is in progress.
Figure 5 shows the timing relationships— Manufacturing a transmission busy bit. Code, indicated by the ellipsis in the middle, has been omitted for
please forgive the picture, my scope is a 20+ clarity.

extern uint8 rxDestinationAddress[8];

//declare external global variable (declaration is in Network Protocol)

//The group address is found as follows after the group message has been received
cTemp1 = rxDestinationAddress[0];

LISTING 2 years-old Hewlett Packard 564645D and no listing (Commented as //B). Because I am
Acquiring the group message address longer has a PC connection. going to discuss group transmission shortly,
Looking at Listing 1 you can see how I you can see where the differentiation occurs
managed to add the transmission busy between group and individual transmission
bit indicated as a status bit SINGLE_ (indicated by the code in blue text).
start of the transmission and cleared at the GROUP MESSAGING
end. So, testing for this bit in software once Although the Network Protocol component
the transmission has started will indicate is remarkably comprehensive, it seems that
when the transmission is complete. it is a little remiss when it comes to group
The software in Listing 1 was lifted messaging. Group messaging is the method
entirely from the source module PLC_ that Network Protocol uses for broadcast
Demo.c of the application note. The messages. A module can belong to up to 9
only significant changes to the code are groups, but the incoming group message
shown highlighted. The balance is omitted. does not provide an API to distinguish one
Transmission is initiated at the bottom of the from another. The way to do this is shown in
module, where the line of code sets the bit Listing 2.
that transmission has started (commented The individual messaging has handshaking
as //A). The sequence of operation in this and error correction, so that the to and fro may
program is to look for incoming messages go on several times—the frequency hopping
so the clearance of the transmission busy bit and error detection refine the communication.
happens at the line of code at the top of the However, group messaging is unidirectional,
and if the frequency selected by the hopping
algorithm previously does not match the
ABOUT THE AUTHOR reception frequency of the module, the
Aubrey Kagan has worked in electronics for message is often lost. Accordingly, I disabled
more years than he cares to remember. He is the frequency hopping (there, I finally got to
currently Engineering Manager at Emphatec, an the point!). I am unaware of any tools or test
industrial electronics design house in Markham, equipment that could have helped me prove
Ontario. He has written many articles for this, only that it didn’t seem to lose messages
Circuit Cellar over the past 25 years as well when frequency hopping was disabled.
The group transmission is subject to
as a book Excel by Example based on three of
similar overrun issues as the individual
those articles. Aubrey was one of the “notable
message, but we can’t use the same method
contributors” interviewed in Circuit Cellar’s 25th
to detect transmission activity. In reception,
Anniversary issue. He has also published several
the external transmission circuitry is turned
design ideas as well as numerous blogs covering off by the TX_Disable output from the FSK
many aspects of electronic design. You can find Modulator. This signal goes inactive when the
a list and links to more of his publications on the Circuit Cellar article materials unit is transmitting, so the process is to initiate
webpage. He can be contacted at the group transmission, and then wait for the
TX_Disable pin (TX_Disable_Read()) to
go inactive. Subsequently, wait until the TX_
For detailed article references and additional resources go to:
Disable pin goes active when the transmission
is complete. Unfortunately, this cannot work
for individual transmission because of the
transmission and response.
RESOURCES Addressing in the PLC can be logical
Bourns | based (a selectable 8-bit or 16-bit address)
or physical (8 bytes) based. Until now, I had
Cypress Semiconductor |
no idea that every PSoC chip has an almost
ON Semiconductor | unique 7-byte ID number. It is based on some
die parameters, lot number, year and work
Microchip Technology | week. (For more on that, see pages 1718-1724
STMicroelectronics |
of the PSoC 5LP Registers Technical Reference 31

Manual—link available on the Circuit Cellar repeaters. Cypress had an application note
article materials webpage.) I say, “almost (AN62487, still available on special request) on
unique” because Cypress tells me that it using the CY8CPLC20 in this way. Because the
may loop over in 10 years. Since that’s an CY8CPLC20 and the PLC implementation on
unlikely set of circumstances for this kind of the PSoC5 are compatible, I am sure it would
application, the Network Protocol uses it as the be possible to port the repeater configuration.

physical address in the communications.
The physical address is actually maintained SUMMARY
in RAM and can be changed to any address you I hope to have provided enough
like, for example, a MAC address. The logical information to alleviate some of the pain that
address is defined as part of the application, I went through in developing my application.
and a group address is an 8-bit logical address. Communication over the powerline is slow,
But because different messages are used for but has some benefits. Only one pair (not
group transmissions, the address spaces can even a twisted pair) of wires is needed.
overlap. It is also possible to mix and match— I have operated the application well over
sending to a logical address and responding to 1,000 feet of cable, but the testing has
a physical one, for example. been restricted (financially) to only five
In the datasheet for the Network Protocol, outstations. I anticipate, with some dread,
there are an awful lot of APIs that look like they testing 100 more units.
could be beneficial to the performance of the Since the time that I wrote this article,
PLC—for instance EnableTxLineLoading. development has continued and we have
But I am really puzzled about how to make managed to shrink the PCB with all its
a systematic approach to evaluate all the project related hardware to about 4" square.
features, let alone find the tools to measure We have also increased the testing to 15
the performance. outstations.

EXTENDING THE RANGE Author's Note: I am heavily indebted to

One of the interesting possibilities for Cypress Semiconductor's Technical Support
extending the range of communications for holding my hand as I worked through
is to configure one or many units to act as these issues. Many thanks.

Rugged SBCs
for Video & Networking Solutions

Access Points ● IoT ● UAV-Aero-Auto-Rail

Asset Tracking ● Digital Signage

Low Power 32 & 64-bit ARM SoC’s

Video Interfaces include HDMI / LVDS / Composite
Multiple Mini-PCIe for WiFi, Cellular, BLE, mSATA, etc.
10+ Year Product Availability
Industrial Rated
Configurable & Customizable

Build a Persistence-of-Vision
Using LEDs and PIC32

Learn how these two Cornell

University students created
a persistence-of-vision (POV)
display. They found a way to fit an
LED strip onto the mechanically
rigid base of a box window fan.
The POV display creates the
illusion of an image and show
anything from an analog clock to
ASCII text and complex images.

Han Li and Emily Sun

V isual feedback is a key aspect of

human interaction in everyday
life. With technology, the beauty
of the visual world can be
preserved with images and videos. We set
out to create a persistence-of-vision (POV)
shows anything from an analog clock to
ASCII text and complex images.
In designing our POV fan display, the first
thing we measured was the fan’s speed of
rotation. This was calculated by flashing a
blinking strobe light through the fan blades.
display that is both multifunctional and easy On the slowest setting, the fan rotates at
to use, through the use of a large box fan. approximately 7 Hz, which is equivalent to
Box fans are often found by the window on 143 ms per rotation around the circular radius
hot summer days, and can be quite unique of the spinning fan. The angle resolution of
with the integration of a “cool” POV display. the image generator of the POV display is
For our project, we found a way to fit a limited by time constraints, so we defined
DotStar LED strip onto the mechanically 100 tick locations around the peripheral of
rigid box base of a box fan. As such, the box the fan. Since the LEDs are programmed to
fan serves as an ideal platform for a POV light up twice per rotation, the images can
display, without needing to construct a well- be rendered twice as fast, thus increasing
calibrated rotating setup with a DC motor. the refresh rate of the display to around
The box fan also has preset settings for 14 Hz—each pixel is blinking 14 times per
speed which is convenient for testing. second. For the human eye, the POV effect is
The novelty of this POV display makes achieved around 15 Hz, which means we are
it a good conversation starter, and it can getting a decent result with our setup.
be easily assembled and customized. The With an interrupt time of approximately
display creates an illusion of an image and 1 ms, and through the use of the Hall 33

Hardware setup with a closeup of Hall effect sensor and magnet placement

effect sensor that updates the period on that secure the front facing grills are bent
each rotation, the positioning of displayed outward to allow for smooth rotation of the
elements on the fan varies to at most mounted plywood piece.
2.5 degrees. During testing, there are no The centerpiece on the fan contains the
observations of rotational jittering greater protoboard with the 5 V battery pack using a
than 2.5 degrees with 100 display angles. 9 V battery to minimize the moment of inertia
and increase balance. A neodymium magnet
HARDWARE DESIGN is secured onto an L-bracket, which is then
The hardware components are a box fan, mounted on the edge of the box (Figure 1).
DotStar LED strip, tri-state buffer, Hall effect The US5881LUA Hall effect sensor, which
sensor, 5 V battery bank, 9 V battery, a piece has a digital output to an applied magnetic
of 0.635 cm × 2.54 cm × 50 cm plywood and a field, is mounted onto a small (2 cm × 2 cm)
Microchip Technology PIC32 microcontroller protoboard with a 10 kΩ pull up resistor.
on a custom PCB [1]. This is then connected to the 5 V rail to the
The custom PCB with the mounted PIC32 protoboard with a 0.25 m length of stranded
is secured onto the protoboard above a piece
of Styrofoam to prevent short-circuiting
(Figure 1). The protoboard itself contains /


the necessary power distribution and level *8 !


shifting required for the LED strip. The 98

DotStar LED strip must be driven at 5 V and 
takes about 60 mA per LED at full intensity. /
Because of the PIC32’s 3.3 V output, an ON 2
Semiconductor 74LS125 tri-state buffer

[2] is used as a level shifter. This is done 

5 12 #/

by shorting the gate on the tri-state buffer 
6 98

to ground and powering the buffer with

2-, 2-0
2- 2-
the 5 V rail (Figure 2). The 9 V battery is (/ 6
2- /

2- 2- /
then connected directly to the custom 

/&& 2-,


& #; 
PCB with the adapter, and the 5 V battery
 2# /#
,  .01&
2# /&& 0
pack is connected to the power rail on the ,,


protoboard (Figure 1).

/ 2-.
0  0
2- 2-6 98
In terms of mechanical setup, the front-  
facing grill on the box fan is removed for * +,'- 

easy access. A piece of plywood is mounted

onto the fan with two wood screws on the
opposite side of the fan’s plastic centerpiece.
The DotStar LED strip is secured to the
plywood with zip ties. The metal ridges Schematic of hardware setup

done by the hardware Timer3. This ISR

Polar coordinate system Our coordinate system manages the drawing of the POV display and
drives the LED strip through the simplified
SPI interface. It also keeps track of the real
time that has elapsed to generate human-
readable time in an analog clock display.

A separate external interrupt on an

I/O pin is used for interfacing with the
Hall effect sensor. Through the PIC32’s
convenient Peripheral Pin Select function,
the output pin gets triggered by the falling
edge of the active-low Hall effect sensor on
each fan rotation. The Hall effect sensor
is critical in the correct operation of the
POV display, because it enables the PIC32
FIGURE 3 to calculate the period of the fan. Having
Custom coordinate system visualization a dynamic measure of the fan’s rotation
period allows the display to be stable when
the fan period changes, for example, when
the fan is turning on during startup. Every
time the Hall effect sensor passes by the
wire. This allows the Hall effect sensor to magnet, the previous rotation’s period is
be placed at the edge of the fan blade, so it recorded. Then the arm’s position in space
can be near the neodymium magnet on each can be calculated as follows:
% from top=
All programming was completed through time elapsed since hall effect sensor
the MPLABX/XC32 environment provided last known period of arm
by Microchip. The Peripheral Libraries with
register abstractions were used exclusively. Visual Rendering: To draw objects on the
Hardware Interface: The DotStar LED strip POV display, it is important to understand
uses a simplified communication protocol how it is different from a conventional
based on SPI. SPI, which is a synchronous display, such as a computer screen, both
data bus communication protocol, has a in terms of pixel layout and coordinate
clock line that indicates at which intervals systems. A standard computer screen uses
information on the SPI data line should be a grid of pixels to display an image. This
sampled for interpretation. Typically, SPI grid comprises multiple rows of multiple
requires a chip select line. However, the pixels that simultaneously display colors. It
protocol used by the DotStar LEDs does not is typically represented with the cartesian
require one. The code referenced in [3] is coordinate system, which uses a point
used as a basis for controlling the LED strip. denoted by x and y to represent a point/pixel
Interrupts with interrupt service routines with a length and height from the origin.
(ISRs) are utilized extensively, so images can In contrast, a POV display only contains
be rendered in real time on the POV display. a single row of pixels. In this case, the
The main timing ISR is triggered once every DotStar LED strip is composed of 75
40,000 cycles, or a period of 1 ms. This is separately controllable LEDs, where each
LED can be considered a separate pixel. The
row of pixels can then rotate to simulate the
effect of a whole screen of pixels. Thus, a
ABOUT THE AUTHORS POV display is inherently radial, and can be
Han Li is an undergraduate student at Cornell University, majoring in naturally represented by a polar coordinate
system. Instead of x and y, this system
Computer Science and Electrical and Computer Engineering. His primary
uses r and θ, which represents a point with
interests are artificial intelligence and computer graphics. Outside classes,
a length from the origin, and an angle of
he enjoys swimming and video games.
offset going counter clockwise from the
positive X-axis. For the purposes of this
A native of Taipei, Taiwan, Emily Sun is an undergraduate student at Cornell project, a polar coordinate system with
University, majoring in Electrical and Computer Engineering. Her primary slightly different units was chosen to better
interests are autonomous vehicles and machine learning. Outside of classes, suit the implementation details (Figure 3).
she enjoys food, board games and projects involving mobile robots. Specifically, a coordinate or an LED position
would be represented by r and p, where r 35

is the LED number from the center of the

axis of rotation and p is the angle the LED
is offset from the top of the fan going
clockwise (where the magnet is located)
when viewed from above.


A simple thing that can be shown on
the POV display is an analog clock. This
visualization is an intuitive choice for the
POV display, as drawing the straight hour
and minute clock hands serves as a good
starting point for visual rendering. As the
strip rotates, we can selectively light up
LEDs during certain arm positions to create
specific effects. For example, to draw the
outer edge of the clock, the first and last LED
are always lit up. To draw the hour hand,
ASCII character representation and simulated deformation on POV display
the LED strip lights up in a line when the
percentage from the top of the fan is equal to
the percentage of the hour. With the existing
percentage, it is also possible to calculate readable, as you’ll see in the photos later on
the opposite side of the arm. in the article. Finally, the POV display can
When one side of the LED strip (top) is at draw any arbitrary image.
a position, we know the other would simply The resolution on the POV display is
be at +0.5 range of the top half of the strip. limited by 36 LEDs on each half of the
For example, a second hand at the 9 o’clock DotStar LED strip. As shown in Figure 5, the
position would first be drawn when the arm fan can only display images with a maximum
is at 0.25 by the bottom portion of the LED side length of 50.911 pixels. For simplicity,
strip. Then it will be drawn when the arm is the images are limited to square formats, so
at 0.75 by the top portion of the LED strip. each pixel corresponds to a single LED. The
This creates the double refresh illusion as
previously mentioned. In addition, there are
12 separate hour ticks drawn on the analog
clock. We do this by first rounding the arm’s
percentage to its nearest whole percentage.
If the whole percentage is equal to any of
the twelve-hour tick percentages, we render
the hour tick.
Text can also be drawn on the POV display, 36
but rendering it well is slightly tricky, due
to the nature of the ASCII characters.
All the ASCII character require multiple
“ticks” of the fan arm to draw, as all letters
have width. A 7× 5 pixel ASCII character
representation was chosen. That’s because
it is the least number of pixels required
for an ASCII character to be rendered
clearly. This character representation was
preprocessed from [4], in which the array
was rotated 90 degrees clockwise to allow
drawing from bottom up and left to right,
instead of top down and left to right. With
this setup, any text can be drawn starting
at an arbitrary percentage position on
the display. The letter spacing also can be
customized to avoid crowding. One problem
with this implementation is that there is no
Cartesian-to-polar transformation, leading
to slight letter deformation due to the nature
of a circular display (Figure 4). Despite the FIGURE 5
distortion, the characters are still clear and Visual aid for square image display

Shown here is rendered sample image
on the POV display. The artifacts are
due to camera limitations.

side length is also rounded down to 49 × 49

pixels, so that there can be a pixel in the
exact center of the image, thus facilitating
the conversion from any image file to a
49 × 49 pixel array.
With a coordinate system and image
dimension established, a conversion for any
desired image can be performed easily. A
custom Python script was written so any
image can be scaled and converted to a
Cartesian relative coordinate system based
on the middle pixel. This allows for easy
transition into the modified polar coordinate
system used for the POV display. The final
result is then formatted and output to a
C header file as an array containing the
appropriate LED position and color to light
up for each separate percentage around
the clock. During operation of the display,
the ISR can simply read from the array and
use the real-time percentage position of the
arm to set LEDs accordingly.

Overall, the construction of the POV
display is mechanically sound. The
FIGURE 7 level-shifter circuitry, PIC32 PCB, and
Shown here is a rendered clock face on the POV fan display. The slight smearing is due to camera limitations. corresponding batteries are firmly mounted
on the fan‘s centerpiece with little room for
movement. The 0.50 m DotStar LED strip
For detailed article references and additional resources go to: lies flat against a plywood strip that is mounted on the fan‘s centerpiece with a few
small wood screws. The robust construction
References [1] through [4] as marked in the article can be found there.
of the peripheral hardware strongly reduces
the room for error with the LED display as
RESOURCES the fan rotates, and also allows for safety
Adafruit | during operation.
In terms of the visual display, the POV
Digikey | fan demonstrates consistent persistence of
vision along with options for customizability.
Microchip Technology |
A user can select between a clock face and a
ON Semiconductor | custom image to display on the fan. A sample 37

image of a PacMan ghost rendered by the DISCUSSION

image display option on our POV display is The overall usability of the POV fan display
shown in Figure 6. The loss of pixels shown is simple and intuitive. The fan allows the
in the image—a result of the camera’s user to select from among three different
relatively fast shutter speed—cannot be speeds. With minor code modifications, the
seen with the naked eye. Given that the display can work properly at any speed. If

DotStar LEDs can refresh up to 32 MHz, and a user wishes to change the custom image
each pixel on the POV fan display blinks 14 that is displayed on the fan, the Python
times per second (14 Hz), the PacMan ghost script is able to convert any image into
is perceived as a continuous image by the a 49 × 49 pixel image. Furthermore, the
human eye. DotStar LED strip has a wide range of color
Similarly, an image of the clock display selection and intensities, providing additional FIGURE 8
with the ASCII characters is shown in customizability. QR code for YouTube video
Figure 7. In the image, the hour numbers The POV fan display demonstrates that it demonstration
on the clock face are slightly blurred out. is feasible to create an inexpensive yet
This again is due to the fast shutter speed multipurpose POV display from scratch. The
of the camera that captured the image. mechanical robustness of the system is
We can see that the display for both the important in the maintenance of performance
image and clock on the POV fan provides under the high-speed rotation of the fan. The
a mesmerizing illusion that showcases the relatively low cost is also great for hobbyists.
beauty of persistence of vision. The many capabilities of a POV fan display
To see a video of the persistence-of-vision include showing an analog clock, text or
fan in action, scan the QR code in Figure 8 images. This makes it extremely customizable
or go to the YouTube video provided on the for fans of cool DIY projects.
Circuit Cellar article materials webpage.
QR codes can be accessed directly with an
iPhone camera or by downloading a QR code
reader app on Android.


PC/104 Embedded Computers

Very High Performance

Kaby Lake!

Call or Visit Today!


Security Takes Center Stage

for MCUs
Secure IoT
Embedded systems face security challenges unlike those
in the IT realm. To meet those needs, microcontroller
vendors continue to add ever-more sophisticated
security features to their devices—both on their own

and via partnerships with security specialists.

By Jeff Child,
Editor-in-Chief The SAM L10 and SAM L11 MCU families provide TrustZone for Armv8-M hardware
isolation between certified libraries, IP and application code. The MCUs also feature
tamper resistance, secure boot and secure key storage.

F or embedded systems, there is no

one piece of technology that can take
on all the security responsibilities
of a system on their own. Indeed,
everything from application software to
firmware to data storage has a role to play
variety of ways—some on their own and some
by teaming up with hardware and software
security specialists.


Exemplifying these trends, Microchip
in security. That said, microcontollers have Technology in June released its SAM L10 and
been trending toward assuming a central role SAM L11 MCU families (Figure 1). The devices
in embedded security. One driving factor for were designed to address the increasing risks
this is the Internet-of-Things (IoT). As the IoT of exposing intellectual property (IP) and
era moves into full gear, all kinds of devices sensitive information in IoT-based embedded
are getting more connected. And because systems. The MCU families are based on the
MCUs are a key component in those connected Arm Cortex-M23 core, with the SAM L11
systems, MCUs have evolved in recent years featuring Arm TrustZone for Armv8-M, a
to include more robust security features on programmable environment that provides
chip. hardware isolation between certified libraries,
That trend has continued over the last 12 IP and application code. Security features on
months, with the leading MCU vendors ramping the MCUs include tamper resistance, secure
up those embedded security capabilities in a boot and secure key storage. These, combined 39

with TrustZone technology, protect applications dual-core architecture and embedded multi-
from both remote and physical attacks. protocol radio. It provides a solution for
In addition to TrustZone technology, the miniaturizing sophisticated applications that
SAM L11 security features include an on-board typically require a larger, more costly two-
cryptographic module supporting Advanced chip solution. Examples include consumer
Encryption Standard (AES), Galois Counter devices such as wearables, smart door locks,
Mode (GCM) and Secure Hash Algorithm (SHA). thermostats and other smart home devices.
The secure boot and secure key storage with The K32W0x embeds a dual-core
tamper detection capabilities establish a architecture comprised of an Arm Cortex-M4
hardware root of trust. It also offers a secure core for high performance application
bootloader for secure firmware upgrades. processing and a Cortex-M0+ core for low-
Microchip has partnered with Trustonic, power connectivity and sensor processing.
a member of Microchip’s Security Design Memory on chip includes 1.25 MB of flash

Partner Program, to offer a comprehensive and 384 KB of SRAM. Its multi-protocol radio
security solution framework that simplifies supports Bluetooth 5 and IEEE 802.15.4
implementation of security and enables including the Thread IP-based mesh
customers to introduce end products faster. networking stack and the Zigbee 3.0 mesh
Microchip has also partnered with Secure networking stack.
Thingz and Data I/O Corporation to offer secure Features of the K32W0x’s security system
provisioning services for SAM L11 customers include a cryptographic sub-system that has
that have a proven security framework. a dedicated core, dedicated instruction and
data memory for encryption, signing and
WIRELESS MCU hashing algorithms including AES, DES, SHA,
Likewise focusing on IoT security, NXP RSA and ECC. Secure key management is
Semiconductor in February announced its provided for storing and protecting sensitive
K32W0x wireless MCU platform. According security keys (Figure 2). Support is enabled
to NXP, it’s the first single-chip device with a for erasing the cryptographic sub-system

Security features of the K32W0x MCU include a cryptographic sub-system that has a dedicated core, dedicated instruction and data memory for encryption, signing and hashing
algorithms including AES, DES, SHA, RSA and ECC.

those needs by offering integrated Trusted

Secure IP, enhanced flash protection, and
other technology advancements to create a
secure and stable integrated solution that’s
proven by Cryptographic Algorithm Validation
(CAVP) certification (Figure 3). In turn, these
security advancements enable seamless flash
firmware updates in the field through secure
network communications.
The new MCUs with enhanced security
features are based on the high-performance
RXv2 core and a 40 nm process, which provide
strong power efficiency for CPU operation at

4.55 Core Mark/MHz. Integrating the Trusted

Secure IP into the new MCUs enables system
control engineers to realize high root-of-trust
levels for device operation.
The Renesas Trusted Secure IP driver
provides several critical security capabilities.
This driver controls AES, AES-GCM, AES-CMAC
encryption and decryption and the generation
RX65N/RX651 MCUs provide security by offering integrated Trusted Secure IP, enhanced flash protection and
of random numbers through high-speed
other technology advancements. These enable you to create a secure and stable integrated solution that’s hardware calculation by the Trusted Secure
proven by Cryptographic Algorithm Validation (CAVP) certification. IP modules embedded in the RX231 Group,
RX65N, RX651 Group MCUs. It also helps in the
memory, including security keys, upon sensing safe management of user keys by the Trusted
a security breach or physical tamper event. Secure IP module. These functions allow
The device has a Resource Domain Controller secure updating of flash ROM embedded in
for access control, system memory protection MCUs and in preventing illicit firmware being
and peripheral isolation. Built-in secure boot booted up (secure booting). As a result, this
and secure over-the-air programming is driver can help system developers protect IoT
supported to assure only authorized and embedded devices from viral infections and
authenticated code runs in the device. eavesdropping.
To extend the on-chip security features
of the K32W0x MCU platform, NXP has ARM PLATFORM SECURITY
collaborated with B-Secur, an expert in ARCHITECTURE
biometric authentication, to develop a system Because Arm CPU cores are so pervasive
that uses an individual’s unique heart pattern in today’s MCUs, Arm itself has been playing
(electrocardiogram/ECG) to validate identity, a role in the embedded security landscape.
making systems more secure than using an Illustrating just that, Cypress Semiconductor
individual’s fingerprint or voice. earlier this year announced the availability
of the Platform Security Architecture (PSA)
IP BOOSTS SECURITY Trusted Firmware-M reference example
For its part, Renesas Electronics addressed from Arm for its PSoC 6 MCUs. By leveraging
the IoT security challenge late last year when PSA’s holistic set of threat models, security
it expanded its RX65N/RX651 Group MCU analyses, hardware and firmware architecture
lineup. The MCUs serve advanced security specifications, and Trusted Firmware-M
needs for connected devices operating in reference implementation, IoT system
industrial automation, building automation designers can quickly and easily implement
and smart metering systems. secure designs with PSoC 6 MCUs.
According to the company, the expansion of According to Cypress, its PSoC 6 MCUs
devices operating at the edge of the Industrial achieve the highest level of protection defined
Internet of Things (IIoT) has increased by the PSA using dual Arm Corte-M cores
embedded system manufacturers’ need for combined with configurable memory and
secure network connectivity and reliability, peripheral protection units. The MCUs provide
including secure on-the-go firmware updates. three levels of hardware-based isolation:
The expanded RX65N/RX651 devices support 1) an isolated execution environment for 41

trusted applications using a dedicated 4.2 mm x 4.0 mm UDFN8 package.

Arm Cortex-M0+ core; 2) secure element Running on this improved hardware,
functionality that hosts root of trust operations the latest JavaCard secure OS, Version
and system services; and 3) isolation for each 3.0.4 Classic with GlobalPlatform provides
trusted application. These three levels of advanced security features, including support
isolation together reduce the attack surface for Password Authenticated Connection
for threats. The system is augmented with a Establishment (PACE) protocol. Leveraging ST’s
true random number generator (TRNG) and crypto library including DES/3DES, RSA, ECC
cryptographic accelerators. and AES, SHA- 1, SHA-256, SHA-512, CRC32
Aligned with Arm’s current version for v8- and CRC16, the STSAFE-J100 is certified to
M, the Trusted Firmware-M reference example Common Criteria (CC) EAL5+—the highest level
for PSoC 6 MCUs allows designers to easily for commercial electronic-security equipment.
implement hardware-based isolation between Middleware complying with the latest Public-

secure and unsecure execution environments Key Cryptography Standards (PKCS #11)
via configuration of the protection units. Users further underlines the new chip’s adherence to
can also use Mbed OS secure services. Future best-in-class security technologies.
versions are expected to include trusted
boot with multiple images and full PSA API OPEN SOURCE TPM
support, including Root of Trust installation MCU vendors these days are often looking
with secure element functionality. beyond their MCU devices when it comes to
developing embedded security technologies.
SECURITY FOR SMART THINGS This even includes middleware. In an example
Among the latest security themed offerings along those lines, Infineon Technologies
from STMicroelectronics is its STSAFE chip that in August announced a new open source
combines digital security features in a single software stack aimed at making work
chip to protect Smart Things and networks easier for developers who want to use the
—including those for utility infrastructure— Trusted Platform Module (TPM) 2.0. TPM 2.0
against cyber threats. Focused on providing is a standardized hardware-based security
state-of-the-art security for connected objects, solution for securing industrial, automotive
the STSAFE-J100 (Figure 4) gives the object an and other applications such as network
unalterable identity that can be authenticated. equipment. This is the first open source
It also handles encrypted communications TPM middleware that complies with the TCG
and provides secure storage. It is easily Software Stack (TSS) Enhanced System API
integrated in IoT devices like smart meters, (ESAPI) specification of the Trusted Computing
data concentrators and utility gateways. Group (TCG), providing significant value to the
The chip is customizable with market- open source community.
specific applets. The STSAFE-J100 secure According to the company, making the
element combines CC EAL5+ certified TSS ESAPI layer available to everyone is
hardware and a CC EAL5+ certified secure
operating system. Device designers can
create their own security profiles, or get to
market faster using ST’s pre-certified profiles
such as German BSI and French Enedis smart
utility specifications.
ST provides a secure device-
personalization service by which each device
gets its unique identity and cryptographic
keys. This is a fundamental part of the
secure-element philosophy to create trusted
hardware resistant to cloning or hacking. ST’s
service relieves embedded system developers
of responsibility for secure programming,
preventing exposure of keys and secrets
and distributing programmed devices. The
STSAFE-J100 occupies minimal real estate on FIGURE 4
the main system board, in either a 5 mm x To provide state-of-the-art security for connected objects, the STSAFE-J100 gives the object an unalterable
5 mm VFQFPN32, 6.0 mm x 4.9 mm SO8N, or identity that can be authenticated. It also handles encrypted communications and provides secure storage.

the TPM and authorization using hash-based

message authentication codes (HMAC).
Based on the ESAPI layer, the stack includes
support for OpenSSL. It can use the Infineon
OPTIGA TPM to protect device communication
secured with SSL/TLS via a standardized
interface by deploying TPM 2.0 as a secured
key store for OpenSSL (Figure 5). In this way
it protects the keys from vulnerabilities like
the famous Heartbleed bug.
The TSS stack and ESAPI layer are
published under the permissive 2-clause
BSD license, which provides high flexibility

and increases adoption. The ESAPI has been

designed and validated by a wide community
to achieve a high level of quality and stability,
as is required in modern embedded and IoT
systems. With industrial and automotive
customers in mind, the code was developed
using industry standards, continuous
integration and testing, a thorough two-
Infineon’s open source TPM software stack was tested and evaluated on the Infineon OPTIGA TPM SLB 9670
with the latest TPM specifications.
person review process, and static code
analyzers like Clang and Coverity.
In addition, the stack was tested and
evaluated on Infineon OPTIGA TPM SLB
9670 with the latest TPM specifications.
Future enhancements will include support
part of Infineon´s commitment to ease the for Cryptsetup/LUKS disk encryption and
integration and wide adoption of strong a version featuring ESAPI support for TPM
security. This is further supported by security tools. Application developers can use the
experts and industry leaders of the Infineon OPTIGA TPM SLB 9670 Iridium boards offered
Security Partner Network (ISPN). The ISPN by Infineon and download the TSS code via
offers a variety of software libraries meeting Github to get started right away. Infineon
the requirements of different applications and says source code packages for the Infineon
target platforms. AURIX MCU as well as for Arduino MCUs will
Infineon funded the development of the be released in due course.
ESAPI by Fraunhofer Institute for Secure It’s clear that today’s MCUs are practically
Information Technology (SIT), a long- complete systems-on-chips in their own right.
term partner of Infineon in this field. The And with those system capabilities have come
Infineon-funded ESAPI layer is based on the increased system-level responsibilities—and
SAPI layer developed by Intel. It includes security is among those. MCU vendors have
a new layer of API functions to simplify stepped up by continuing to add new
the use and integration of the TPM. It embedded security functions to their device
facilitates establishing a connection with families and developing ways to help
the TPM through an application, secured embedded system developers create secure,
communication between the host CPU and connected products.

Cypress Semiconductor |
Infineon Technologies |
Microchip Technology |
NXP Semiconductors |
Renesas Electronics |
STMicroelectronics |
I I o T E v o l uti o n: An A pproach To Re use An d
S cal e Yo Discover Unknown
ur IIo T Technology I nve stme n t
PCB Design
Learn Issues
More in this withPaper
This white paper introduces an IoT framework that complements and
extends the massive investments made by cloud vendors to provide

Learn More in this White Paper

comprehensive IIoT features that can be implemented down to the
hardware of the edge or end node devices – and can be ported across
platforms and clouds. The benefits of using a framework such as MEIF are
abundantly clear: minimize learning curves, simplify implementations,
increase code reuse, reduce porting costs, and reduce testing.

MCU Development Kits

Meet Diverse Application Needs
Rich Resources

As microcontrollers get more

complex and powerful, so too have
their development kits. Besides
the basics of a development

board and software tools, today’s

crop of MCU development kits
often include extras like displays
and antennas as well detailed
reference design resources.

MCUs play a key role in interfacing with sensors in real time. Shown here, UNAVCO's
station in Akhiok relays seismic data from Earthquake Center stations on Sitkinak and
By Jeff Child, Chirikof islands (Photo courtsey of University of Alaska Fairbanks)

I t clearly could not be a better time

to be a developer of microcontroller-
based embedded systems. The leading
MCU vendors all provide outstanding
development kits that include everything you
need to get a prototype design up and running.
Coinciding with the launch of its
MSP430FR2355 ferroelectric
access memory (FRAM) MCUs in June,

Texas Instruments (TI) rolled out the MSP-

EXP430FR2355 LaunchPad Development Kit
These development kits are often released (Figure 1). The kit provides an evaluation
alongside a new MCU device family launch, but module based on the MSP430FR2355 Value
others emerge providing various application- Line MCU. It contains an on-board debug
or market-specific components—like antennas probe for programming, debugging and
for wireless systems for example. energy measurements. The board includes two
To support their broad MCU product lines, buttons and two LEDs for creating a simple user
MCU vendors all have an enormous variety interface. It also has an ambient light sensor
of development kits categorized not only by and connector for external analog sources.
MCU, but by application—or even subsets The MSP430FR2355 MCU includes a smart
of markets like the powertrain electronics analog combo of configurable signal chain
in automotive systems, for instance. With elements including options for multiple 12- bit
that in mind, this article focuses on some digital-to-analog converters (DACs) and
representative MCU development kits— programmable gain amplifiers (PGAs) along
released over the last 12 months—that with a 12-bit analog-to-digital converter (ADC)
exemplify today’s state of the technology. and two enhanced comparators (eCOMPs). 45

One of the out-of-box demos includes a GUI FIGURE 1

to showcase some of the smart analog combo Aside from the eval board, the MSP-
configurations. EXP430FR2355 LaunchPad Development
Kit contains an on-board debug probe
The 24 MHz MSP430FR2355 device
for programming, debugging and
features 32 KB of embedded FRAM. FRAM is
energy measurements. It also has an
a non-volatile memory known for its ultra- ambient light sensor and connector for
low power, high endurance and high-speed external analog sources.
write access. Combined with the 4 KB of on-
chip SRAM, users have access to 32 KB of
memory to split between their program and
data as required. For example, a data logging
application may require a large data memory
with a relatively small program memory, so
the memory may be allocated as required
between program and data memory.


A good example of the application-

focused development kit is one from
STMicroelectronics (ST) that targets motor
control design. Released in March, the kit
harmonizes the latest STM32 PMSM FOC
Software Development Kit with the ST’s
STM32Cube ecosystem. According to the quickly by automatically detecting the electrical
company, the kit helps engineers build parameters—stator resistance (Rs), inductance
sophisticated drives for equipment such as (Ls), and motor-voltage constant (Ke)—as well
air conditioners, home appliances, drones, as mechanical friction and inertia. A variety
building automation, industrial machinery, of flexible motor-control strategies are also
medical devices, e-bikes and many others, supported, including current sensing with
without needing specialized experience. single- or triple-shunt or isolated current
Building on previous generations of ST’s sensors (ICS), rotor-position detection using
Field-Oriented Control (FOC) of Permanent encoder or Hall effect sensors, or sensorless
Magnet Synchronous Motors (PMSM) SDK, control. The SDK also supports dual-motor
the new version 5.0 firmware libraries align applications, leveraging the rich analog features
with the STM32Cube Hardware Abstraction and multiple motor-control timers integrated in
Layer (HAL) and Low Level (LL) architectures many STM32 MCU variants.
(Figure 2). This eases development,
customization and debugging. In addition, AUTOMOTIVE GATEWAY
free access to source code gives developers An interesting development kit from
extra flexibility, control, and customizability. Infineon Technologies is its Automotive
New with MC-Workbench version 5.0, the Gateway board for its AURIX TC3xx MCUs. As
GUI leverages the STM32CubeMX workflow to a host controller in gateway and telematics
set up the project, configure MCU peripherals, applications, AURIX TC3xx MCUs support
and automatically generate initialization code. the latest communications interfaces and
It also lets users monitor and change control feature a Gbit Ethernet interface, up to 12
loop parameters in real time, as they develop ISO 11898- 1 compliant CAN FD channels and,
or debug their projects. A rich selection of
algorithms is included, implementing popular
PMSM-control techniques such as Maximum
Torque Per Ampere (MTPA) to maximize
efficiency and handle varying load conditions.
Flux-Weakening control for extended speed
range and feed-forward control for enhanced
stability at high speeds are also included.
Further features include “start-on-the-fly” to
ensure smooth drive insertion when the rotor
is already turning, which is often needed for
outdoor fans such as in air conditioners or
smoke extractors.
Users can also take advantage of SDK FIGURE 2
features including the Motor Profiler, which The STM32 PMSM FOC version 5.0 firmware libraries align with the STM32Cube Hardware Abstraction Layer
helps characterize most aspects of a motor (HAL) and Low Level (LL) architectures.

infotainment and telematics systems.

The Automotive Gateway offers a wide
range of application use cases. By using the
AURIX TC397XX B Step in combination with
Realtek’s RTL9047AA Switch future in-vehicle
networks can be addressed and evaluated. The
TC397XX B Step is connected with a 1 Gbps
RGMII port to the switch for data transfer and
one SPI channel for managing the switch. The
RTL9047AA's five 100Base-T1 ports together
with the MATEnet connector set provide the
right feature set to connect the Automotive
Gateway Board to an in-vehicle network.
The 12 CAN-FD, 4 LIN and 4 Flexray
channels enable bridging of different network
topologies. AURIX TC3xx does not compromise
on security. The second generation of the
programmable Hardware Security Module

FIGURE 3 (HSM) is available across the family for secure

The Rapid IoT prototyping kit combines optimized hardware design and trusted security with pre- on-board communications and to prevent
programmed applications that help get users up and running within minutes of opening the box.
hardware manipulation such as tuning.
Infineon’s Trusted Platform Module (TPM)
SLB9670 is the latest product featuring a
up to 24 LIN channels. An additional eMMC fully TCG TPM 2.0 standard-compliant module
interface for external flash interfacing enables connected via SPI to the AURIX.
local data storage supporting software-over-
the-air update concepts. IOT SYSTEM PROTOTYPING
The gateway is based on Realtek’s The Internet-of-Things (IoT) is among
RTL9047AA, an automotive Ethernet switch the fastest growing of today’s MCU-based
controller with five integrated 100Base-T1 PHY market segments. Facilitating that space, NXP
transceivers, one fast Ethernet PHY and up to Semiconductors in February announced its
two full featured xMII inter faces to provide Rapid IoT prototyping kit. The power-optimized
access via an external CPU or to a cascade prototyping solution is designed to simplify
switch. The RTL9047AA switch is AEC grade the development of Proof-of-Concept (PoC) IoT
1 qualified. It is ideal for various automotive edge nodes for a variety of markets including
applications such as Advanced Driver consumer, commercial and industrial.
Assistance Systems (ADAS), the gateway or According to NXP, Rapid IoT accelerates
the three phases of a typical PoC development
to help even non-traditional technology
innovators take an IoT idea to PoC quickly
and easily (Figure 3). It combines optimized
hardware design and trusted security with pre-
programmed applications that help get users
up and running within minutes of opening the
box. The kit is extendable through a docking
station and the MikroElektronika Click board
range. The Rapid IoT prototyping kit’s drag-
and-drop-style GUI-based programming
from Atmosphere IoT enables innovators to
easily create their applications, even without
embedded coding experience.
Rapid IoT has been designed to ease the
transition from prototype to development with
certified wireless stacks, drivers, middleware,
embedded application examples and iOS/
Android mobile apps. Automatic source
code generation for NXP’s MCUXpresso, a
comprehensive and cohesive set of software
development tools including an SDK, IDE and
FIGURE 4 Config Tools, further helps to provide a fast
The CryptoAutomotive TA/BSD development kit emulates a secure node in an automotive network and and easy transition for embedded systems
provides system designers with an intuitive starting point for implementing security. developers. 47


The RZ/N1L Solution Kit includes a
In one of its latest development kit
RZ/N1L development board and a
offerings, Microchip Technology focuses on
comprehensive software package,
automotive security. which enable engineers to jump
Announced in August, the start evaluation of industrial Ethernet
CryptoAutomotive In-Vehicle Network (IVN) protocols including EtherCAT,
TrustAnchor/Border Security Device (TA/ PROFINET and EtherNet/IP.
BSD) development kit was created to enable
OEMs and Tier 1 suppliers to introduce
security to networked vehicle systems,
starting in areas of priority, with the highest
level of protection and without disruption
elsewhere. Claiming it as the only security-
specific automotive tool in the industry,
Microchip says the CryptoAutomotive TA/BSD
development kit emulates a secure node in
an automotive network and provides system
designers with an intuitive starting point for

implementing security (Figure 4).
The tool accommodates each OEM’s
implementation by allowing manufacturers INDUSTRIAL NETWORKING
to configure the node to conform to various Like all the leading MCU vendors, Renesas
specifications and industry standards. It also Electronics makes development kits for a wide
demonstrates secure key storage, Electronic variety of market and sub-market segments.
Control Unit (ECU) authentication, hardware- One example is its latest solution kit based on
based crypto accelerators and other the RZ/N1L Group of MPUs serving industrial
cryptographic elements. When used with a networking system designs. In addition to
host MCU, it enables designers to implement the RZ/N1D Group for high-end processors
functions such as secure boot and Controller for master devices including Programmable
Area Network (CAN) message authentication,
including conversion of CAN 2.0 messages
to CAN Flexible Data rate (CAN-FD) with

TRACE 32 ®
appended Message Authentication Codes
(MAC) when appropriate.
The TA/BSD emulation kit enables OEMs to
continue using their existing MCUs—and, more
importantly, existing MCU firmware—certified
to required safety standards by later adding
Debugger for RH850
the companion chip the kit emulates. These from the automotive specialists
companion chips will come to the customer
preprogrammed and include built-in security
measures to provide true hardware-based DEBUGGING
key protection. This add-on approach can
deliver significant cost and time-to-market RH850, ICU-M and NEXUS TRACING
advantages, compared to the alternative GTM Debugging
of redesigning the system with a high-
end secure MCU. That can entail significant
Code Coverage
AUTOSAR / (ISO 26262)
re-architecture of the MCU firmware to Multicore Debugging
implement secure zones with hardware and
software domains. Multicore
The tool can be used with any ECU, Runtime Measurement Tracing
architecture, configuration or bus, providing (Performance Counter)
the flexibility to implement security in existing Onchip, Parallel and
systems without large-scale redesigns. The Aurora Tracing
companion chip solution requires minimal
MCU code updates, resulting in minimal to no
impact to existing host MCU functional safety
ratings. This approach also removes the
requirement for in-house security expertise.
The tool provides an online GUI program
with pre-configured options to simplify and
facilitate implementation.

Logic Controller (PLC) and the RZ/N1S Group different protocols with their applications. For
for mid-range devices including Human example, the remote IO reference, as well as
Machine Interface (HMI), the RZ/N Series the EtherCAT sample reference provide easy
includes the RZ/N1L Group, which is optimized frameworks for building a wide range of
for slave devices including remote IO and networking functionalities.
communication modules, and networked
drives. Solution kits for RZ/N1D and RZ/N1S WIRELESS IOT CONNECTIVITY
are already available. For its part, Cypress Semiconductor offers
With the release of the RZ/N1L solution kit, a unified software tool suite that streamlines
evaluation kits for all groups of the RZ/N Series product designs for the IoT. The ModusToolbox
are available, enabling evaluation of network suite provides the design resources of
functions for a wide range of industrial Cypress’ WICED IoT connectivity libraries and
equipment. The RZ/N1L Solution Kit includes a the analog and digital peripherals libraries of
highly integrated RZ/N1L development board its PSoC MCUs. This is implemented within
and a comprehensive software package, which the familiar, widely-deployed open-source
enable engineers to jump start evaluation Eclipse Integrated Design Environments
of industry-leading industrial Ethernet (IDEs). Developers can personalize their user
protocols including EtherCAT, PROFINET, and experience in the software to meet the unique

EtherNet/IP without any upfront costs or requirements of their specific development

complexity (Figure 5). The RZ/N1L Solution with plug-ins, libraries and solutions from
Kit also includes a general software API Cypress partners, as well as from the open
that simplifies application development and source community.
mitigates design risk. These features allow The Cypress’ WICED (Wireless Internet
system manufacturers to shorten evaluation Connectivity for Embedded Devices) is
time of their application up to three months. an integrated and interoperable wireless
The integrated RZ/N1L development board software development kit (SDK) supported in
provides system developers with access to ModusToolbox. The SDK includes the industry’s
the resources of the RZ/N1L MPU, including most broadly deployed and rigorously tested
a two-channel Ethernet port for use in daisy- Wi-Fi and Bluetooth protocol stacks, as well
chain topologies or as an end-node slave as simplified APIs that free developers from
with system monitoring. The board includes needing to learn complex wireless technologies.
32 MB external flash memory for code and In line with the IoT trend toward dual-
data, a debug port, push buttons and LEDs mode connectivity, the WICED SDK supports
and is USB powered. The stand-alone RZ/ N1L Cypress’ Wi-Fi and Bluetooth combo solutions
development board acts as a reference design and its Bluetooth and Bluetooth Low Energy
for component selection and layout that applies (BLE) devices. Cypress’ wireless connectivity
to hardware design guidelines associated with solutions integrate an advanced coexistence
the different protocol requirements. engine that enables optimal combined
The RZ/N1L Solution Kit leverages the performance for dual-band 2.4- and 5-GHz
general API that acts as a generic open Wi-Fi and dual-mode Bluetooth/BLE 5.0
abstraction layer and provides unified support applications simultaneously.
for different network protocols from leading ModusToolbox supports Cypress’ PSoC 6
stack partners in addition to compiler and OS MCU, which is purpose-built for the IoT. PSoC 6
environments. System developers can easily leverages an ultra-low power 40-nm process,
switch between protocols as needed, with low-power design techniques, a dual-core Arm
minimal impact on the application software. Cortex-M4 and Cortex-M0+ architecture and
Sample code and protocol stacks are provided configurable analog and digital resources.
with the solution kit with no additional ModusToolbox also enables developers to
costs, allowing developers to easily evaluate protect sensitive data in their applications with
the PSoC 6 MCU’s hardware-based security
features such as its isolated execution
RESOURCES environment, integrated secure element
functionality and crypto accelerators.
Cypress Semiconductor |
Infineon Technologies |
Microchip Technology |
NXP Semiconductors |
Renesas Electronics |
STMicroelectronics |
Texas Instruments |
Myth: Embedded vision
can be complex.
Fact: It doesn’t
have to be.
Speed past this and other myths as Avnet and
Xilinx move you from complexity to clarity.

Watch now at


Product Focus:
8- and 16-bit MCUs
Right-Sized Solutions

This blood pressure monitoring
evaluation kit includes a pressure
sensor, arm cuff, pump, electronically
controlled valve, LCD panel and a
reference board that incorporates an
RL78 MCU-based ASSP.

Demand continues to be strong for microcontroller solutions of the 8- and 16-bit

variety. MCU vendors are keeping pace by developing smaller, lower power MCU
chips as well as MCUs tailored to meet specific application requirements.

By Jeff Child,

Y ou’d think with the proliferation of today’s 32-

bit microcontrollers, that smaller 8- and 16-
bit MCUs would be obsolete. That’s far from
the case for two reasons. On the one hand,
8- and 16-bit are just the right level of functionalitly
for systems where the cost, power and size of 32-bit
those trends, both 8-bit and 16-bit MCUs are expanding
their product lines to include application-specific MCUs
of all types for a variety of markets. And instead of just
generic automotive MCUs, for example, MCUs are now
available for very specific subsystems within a vehicle
such the powertrain or braking system.
MCUs aren’t practical. Meanwhile, a growing set of new In some cases, MCU vendors are integrating these
applications—particularly for the IoT—have emerged application-focused MCUs into complete development kit
that previously never used MCUs. solutions. One example along those lines is a blood
The product gallery in this article shows a mix of pressure monitoring evaluation kit from Renesas
8-bit and 16-bit MCUs chosen primarily based on their Electronics (Figure 1). The kit includes a pressure sensor,
newness—most were announced within the past 12 to arm cuff, pump, electronically controlled valve, LCD
18 months. Semiconductor companies don’t seem to panel, and a reference board that incorporates an RL78
be adding new 8-bit and 16-bit products at the same MCU-based ASSP (application specific standard product).
high rate that they release 32-bit MCUs. See April Circuit Reference software is included that provides the
Cellar 333 issue for a Product Focus on 32-bit MCUs. algorithms required for blood pressure measurement
The major trend among 8-bit MCUs has been toward and that can be easily modified. The software includes a
pushing the boundaries of small size and low power. This GUI tool and access to smartphone applications. Also
entails smaller footprints—as small as 3 mm wide—and provided in the evaluation kit is a Bluetooth Low Energy
low pin count, but we’re also seeing greater processing (BLE) module that enables the measured data to be
capability and functionality being squeezed into transmitted to a smartphone under the Continua
traditional 8-bit MCU package sizes. Side by side with standard blood pressure monitoring (BPM) profile. 51

8-bit MCU Family Features 8-bit MCUs Operate at 8-bit MCU Optimized for
Rich Peripheral Set Temperatures up to 150°C Sensor Node Designs
Cypress Semiconductor’s (formerly The XC800 150°C family of MCUs Microchip Technology’s ATtiny3217
Fujitsu’s) F2MC NEW 8FX MCU is a from Infineon Technologies is specified family of microcontrollers incorporates
high-performance, 8-bit MCU family without limitations for the temperature several innovative features including
with different sizes of embedded slash range from -40°C up to 150°C. The high-accuracy analog, the Peripheral
memory and a rich set of on-chip series expands Infineon’s 8-bit XC800 Touch Controller (PTC), the Event
peripheral resources. The most recent portfolio to provide a complete high System and Core Independent
devices use the F2MC-8FX CISC CPU that temperature family for automotive Peripherals (CIPs) to enable you to
enables more instructions to be executed applications at AECQ-100-Grade 0. create highly responsive sensor nodes.
per cycle. Applications include system
control and MCUs. • 20 MHz 8-bit 8051 core • Internal 20 MHz oscillator
• Ambient Temperature Range: • Up to 32 KB of flash memory
• 8-bit 8FX CISC CPU with max 40°C to 150°C • 8-bit DAC, Up to two 10-bit ADCs
frequency of 16.25 MHz • Meets AECQ-100-Grade 0 • Peripheral Touch Controller (PTC)
• Built-in composite timer • From 4 KB to 32 KB flash • Cyclic Redundancy Check (CRC) scan
• Composite timer has selectable • 10-bit ADC with 8-channels • 16-bit RTC and periodic interrupt
functions • Flexible PWM signal generation timer
• Selectable functions include PWM, • Multi CAN up to 2 CAN nodes • 12-bit timer/counter for control
PWC, interval timer and input • Background EEPROM emulation applications
capture • 16-bit Vector Computer • Configurable Custom Logic (CCL)
• Variety of flash, ROM and RAM (MDU+CORDIC) peripheral
configurations • 6-channel Peripheral Event System
• 20-year 100,000 write/erase cycle Infineon Technologies
flash Microchip Technology
• Local Interconnect Network (LIN),
UART, SPI, I 2C interfaces
• Oscillator, reset IC and EEPROM all
built in
• Available in 8- to 80-pin packages

Cypress Semiconductor

8-bit and 16-bit MCUs


16-bit MCU Features 8-bit MCU Boasts 16-bit MCU Serves

Dual-Core Architecture Tiny Form Factor Medical Device Needs
The dsPIC33CH from Microchip NXP Semiconductors’ current Renesas Electronics’ RL78 MCU-based
Technology embeds two dsPIC Digital smallest 8-bit S08 MCU is the ASSP (application specific standard
Signal Controller cores in a single chip MC9S08PA4AVDC. Measuring just 3 mm product) includes high precision analog
enabling easier software integration. × 3 mm × 0.9 mm, this new package functions such as Delta-Sigma ADC, SAR
One core is a master while the other is helps address the growing challenge ADC, Programmable Gain amplifiers, op
a slave. The slave core is for executing of shrinking PCB space for tomorrow’s amp and 8-bit/12-bit DAC. It also has
dedicated, time-critical control code technologies, without increasing BOM a built-in LCD controller/driver, which
while the master core is busy running costs. makes the RL78/H1D well suited for
the user interface, system monitoring healthcare devices, especially blood
and communications functions. • 3 mm × 3 mm × 0.9 mm pressure monitors.
• Enhanced HCS08 CPU
• Master Core 90 MIPS and Slave Core • 20 MHz bus at 2.7 V to 5.5 V • Program memory 128 KB Flash
100 MIPS operation • Up to 4 KB flash, 128 byte EEPROM memory
• Independent peripherals for Master and 512 byte RAM • RAM 8 KB, data flash 4 KB
Core and Slave Core • Supported by CodeWarrior IDE • CPU RL78 (16-bit)
• 4x 12-bit 3.5 MSPS ADCs • Watchdog with independent clock • Max. frequency 24 MHz
• High speed PWMs with 250 ps source • On-chip oscillator, real-time clock
resolution, 12 channels • Peripherals: ACMP, ADC, FTM, RTC (RTC)
• Low-power management modes and SCI • Power-On Reset, Low voltage
(Sleep, Idle, Doze) • Up to 18 GPIOs detection
• Simultaneous debugging support for • 63 I/O ports
Master and Slave Cores NXP Semiconductors • Watchdog timers • Other I/O: 1x SPI, 4x UART, 1x I 2C,
Microchip Technology 1x LIN
Renesas Electronics 53

8-bit MCU Features 16-bit MCUs Offer
Compact 8-Pin Package Configurable Signal Chain
STMicroelectronics’ STM8S001 MCU
in an 8-bit SO-8 package sports the Texas Instruments’ MSP430FR235x
STM8 core operating at 16 MHz, and MCUs integrate four configurable
is well suited for industrial devices like signal-chain modules called smart
smart sensors and lighting controls, as analog combos, each of which can be
well as consumer products such as toys, used as a 12-bit DAC or a configurable
small appliances, personal electronics, programmable-gain op amp to meet
PC peripherals, battery chargers and the specific needs of a system while
many others. reducing the BOM and PCB size.

• 16 MHz STM8 core • 16-bit RISC architecture up to

• I 2C, UART and SPI interfaces 24 MHz
• 8 KB Flash memory, 1 KB RAM, • Extended temperature:
128-byte EEPROM –40°C to 105°C
• 3-channel 10-bit ADC • 3.6 V down to 1.8 V voltage range
• 5x GPIOs, 1x 8-bit and 2x 16-bit • Optimized low-power modes (at 3 V)
timers • Active, Standby and Shutdown power
• Internal RC oscillator modes
• Operating temperature: • Up to 32 KB of FRAM
-40°C to 125°C • 20 KB ROM library for drivers and
• 8-pin SO-8 package FFTs
• 12-channel 12-bit ADC
STMicroelectronics Texas Instruments

Embedded in Thin Slices

Internet of Things Security (Part 5)

Identifying Assests

In this next part of his article series on IoT security, Bob looks at how
checklists and the common criteria framework can help us create
more secure IoT devices. He explains how to create a list of security
assets and to establish threat checklists that identify all the threats
to your security assets.

Bob Japenga

A few weeks ago, I sat through a

webinar by a large player in the
cell modem market. It was a well
thought out presentation but I
was surprised at the proposed methodology
it presented for approaching IoT security.
to protect. Once identified, we need to assign
a risk factor to the asset for this particular
So, what is an asset? According to ISO
27001, an asset is “anything that has value
to the organization” (Figure 2). Is that broad
What surprised me was that it didn’t address enough for you? Not completely for me. Okay,
the need for identifying and assessing those I hear my readers saying: “Bob, there you go
assets that you want to protect. That’s what I again, you old curmudgeon. Disagreeing with
want to talk about in this article. an international standard!” I want to make
The problem with failing to identify and sure we use “value” as broad as possible.
quantify the assets that you want to protect For a given device, an asset that needs to be
right up front is that you may expend valuable protected by my design may not have value to
resources in securing something that does not my organization. But it might have value to the
need to be secured. Adding security features organization that owns the wireless network
costs time and resources. Sometimes as that the device is connected to. Although
engineers we get excited about applying new you could argue that the 27001 definition
technologies even if they aren’t needed. The encapsulates this, I want to make sure that
new microprocessors are coming out with our definition includes not just things that are
a lot of bells and whistles to help make our of value to our organization, but things that
IoT devices more secure. Okay, maybe you are of value to our customers and the public
don’t do that. But I’ve been known to apply a network that we are dependent upon. I would
technology or two before its time. say an asset is “anything that has value to the
Let me give you one example. Many of the organizations involved.”
new chips provide tamper detection logic to
notify the processor and take action if the IDENTIFYING THE ASSETS
chip has been tampered with (Figure 1). As Let’s look at some of the assets that I think
designers we need to ask the question: “If need to be considered to be protected. I would
someone could obtain the complete binary love to hear from you if you can add to this
image of the software contained in my device, list. I will include them in a future article.
what assets would be at risk?” In some cases, Intellectual property: At the beginning
none. But it is important to ask the question. of the design of a product it’s important to
I contend that one of our first tasks in identify what is the intellectual property
designing secure IoT devices is to identify the that you want to protect? For example, the
tangible and intangible assets that you want electronic design might be something that 55

you want to protect as a whole. We have seen

entire projects that we designed copied chip
for chip and manufactured and marketed in
another country. We have even seen drawings
copied and crudely erased drawing numbers
replaced with the thief’s own drawing number.
Sometimes, we may not be concerned with
the entire electronic design, but we want to
protect a particular proprietary circuit. On
the other hand, perhaps the electronic design
doesn’t need to be protected because it would
be of very little use without the software.
The binary or executable of the software
is another piece of intellectual property.
Is that something you want to protect? We
have worked with some customers who have
Figure 1
said: “No. We don’t need to protect against
Many new chips provide tamper detection logic to notify the processor and take action if the chip has been
someone stealing the binary of the software
tampered with.
since we are continually innovating. By the
time they reverse engineer the software, we
will have greatly enhanced the product and
their binary will be worthless in the market can destroy your reputation as a company or
place.” Not all of us have that luxury. at least destroy it as a company in a particular
Certain proprietary algorithms may be field. Comcast may continue to sell cable
the “secret sauce” that makes a product services but will have a harder time selling

successful. If the algorithm was discovered the security systems after this security flaw
by a competitor, would the organization suffer was uncovered.
significant harm? Loss of functionality of an individual
With the advent of interpretive languages, product: This is an obvious asset. The
many products embed the source code— device must function as advertised for the
script files, Python code, Basic code, PHP, customer. But what functionality can be lost
Javascript and so on—in the device. Does any without compromising the primary function
of the source code embedded in the device of the device? For example, we designed two
need to be protected? different portable oxygen concentrators for a
The IoT device may store other information customer. Both have a cell modem in them
of a proprietary nature that needs protection. for reporting data to the customer’s server. If
For example, the device may store a history a Denial of Service attack were to take place,
of the device soft-failures that were corrected the delivery of oxygen to the patient should
or worked around that could be exploited by not be affected. So, for our checklist, the
a competitor. This is not an easy item to drill functionality of the device should be placed on
into. We have to think like a crook. Is there a hierarchical list and a determination made
any data that, if it got into the wrong hands, as to what functionality cannot be lost under
could cause harm to your company, your a security attack.
client or someone else? Changed functionality of an individual
The entire file system may be another product: Another take on the above concern
asset that you may want to protect. Certainly, is the question: “If someone could completely
if stored on a removable device without reprogram one device to do whatever they
encryption, the file system is important to
Company reputation: This is not a very
useful asset on our checklist. It is both
intangible and hard to place a value on. And
of course, we want to protect the company’s
reputation. In this day and age however, it
seems like there are more security experts Figure 2
looking to uncover security breaches than According to ISO 27001 an asset
there are true security breaches. This is very is “anything that has value to the
significant. How was Comcast’s reputation organization.” But it’s important
to view that as encompassing not
harmed by Rapid7’s discovery of a security
just things that are of value to your
breach? No one actually has to break into
organization, but things that are of
your system to damage your reputation. Be value to your customers and the public
forewarned: Designing an insecure IoT device network that you are dependent upon.

Figure 3 addresses, phone numbers, social security

Even though it doesn’t belong to your numbers, age and so on—all may be of value
organization, the wireless network you
to some malevolent hacker. But there may be
use is an asset. Those networks can be
indirect assets available for sale by those who
vulnerable to various kinds of attacks.
would hack into your system. For example, a
device with a GPS could be used for tracking
the user if not protected. A smart meter
that provides energy usage could be of use
to those persistent telemarketers who are
trying to get me to switch energy carriers.
You get the idea. You have to take time to ask
the question: “Is there personal information,
direct or indirect, available in our device that
needs to be protected?”
Password, keys and certificates: Certainly,
assets that need to be protected are the
passwords, keys and certificates used for
signing and encrypting the data both used
in transport and in storage. A couple weeks
wanted, would that bring any harm to the ago I was sitting in on a conference call
company?” “What if they could reprogram the and a company was considering having one
entire fleet?” set of symmetrical keys used for the life of
Loss of functionality of product line: As the product across an entire fleet of more
more and more of our designs are being than 300,000 units spread across 3,000
deployed in large scale fleets, identifying the locations. Those keys would require some

risk of losing the functionality of the entire pretty secure methods and mechanizations to
fleet is extremely important. In assessing protect throughout the 20-year lifetime of the
assets, shutting down one product may be product. Cooler heads prevailed thankfully.
embarrassing and affect the organization’s But how many keys are there, how often are
reputation, but shutting down the entire line is they refreshed and how many devices are
much more serious. Most if not all of us would they used on, affects how much protection we
put this as an asset that must be protected at need for the keys. For example, if the keys
all reasonable costs. This asset can then be are different at each site, reverse engineering
translated into a high-level requirement like: one box would only provide a security breach
“The system shall be designed such that a at that site. If the keys are refreshed each
security breach on one device cannot be used day, then reverse engineering one box would
to shut down the entire fleet.” only give you access for one day to one site.
Loss of functionality of entire portfolio of This may not be pretty to think about but if
products: With the advent of re-use in both the mechanism exists for refreshing a whole
software and hardware, potential security subnet of devices keys on a regular basis, why
flaws do not just affect a particular product not use it?
line but could permeate a whole portfolio of Wireless network: Clearly, the wireless
products. As you design a new device in the network, even though it doesn’t belong to your
portfolio—hopefully armed with all of this organization, is an asset (Figure 3). Not all
good advice from this article—keep in mind wireless carriers have the same requirements
legacy devices that potentially could do things for what it takes to put your IoT device on
that the new design could not do, potentially their network. For example, one carrier puts a
even to the new device. limit on the number of times you can put your
Personal Information: Personal information device into and out of airplane mode. If your
is a big deal today. Companies are mining our device were to violate the requirements of
personal information for everything that it the wireless network provider they have the
is worth. We need to think of any personal power to shut your device down and perhaps
information (direct or indirect) in our devices even the entire fleet until you fix whatever
as an asset to consider protecting. In terms they consider wrong. A hacker could find out
of direct personal information—names, what causes your device to go in and out of
airplane mode, do it on one device and cause
the wireless carrier to shut down your entire
For detailed article references and additional resources go to: fleet. Customer wired network: Many of our
devices hang off a customer’s network.
A link to Bob’s IoT Checklist is available there. Typically, these networks are local but they
could be wide area networks. This network 57

must be considered an asset to be protected can see the complication. But that’s why our
in the same way that the wireless network managers pay us the big bucks. We make
does. the best guess that we can and, so far, this
method has worked for us.
ASSIGNING RISK TO ASSETS To see our IoT Checklist, go to the Circuit
Finally, I want to briefly mention how we Cellar article materials webpage. We will add
have assigned risk to these assets. It is both to this with each new article in this series.
simple and complicated at the same time. It In my last article I closed with: “Security
is simple because you just have to assign the is complicated.” But identifying the assets
cost to the company if you lose all or part of with a checklist is a start. Next time we will
the asset. Then you assign the probability of look at identifying the threats. But of course,
losing the asset over the life of the product. only in thin slices.
Multiplying those two together will give you an
idea of the risk. It will also help you convince
your manager or in our case your customer
that you need to invest in security measures
to protect against these threats. Bob Japenga has been designing embedded
Here’s the complicated side: What is systems since 1973. In 1988, along with his
the probability that a malevolent former best friend, he started MicroTools, which
employee steals one of your boxes out of specializes in creating a variety of real-
the spare inventory and sells it to a hacker? time embedded systems. MicroTools has a
The hacker reverse engineers the system combined embedded systems experience
and discovers the passwords to get into the base of more than 200 years. They love
device through the console port. There the to tackle impossible problems together.
hacker finds the one private key that unlocks Bob has been awarded 11 patents in

the entire network. Once on the network, the many areas of embedded systems and
hacker is able to break into your customer’s motion control. You can reach him at
customer network and shut down all 300,000
devices until you pay a ransom. Hopefully you

December 3 - 6, 2018
Santa Clara Convention Center



Lead Sponsor Emerald Sponsor

Diamond Sponsors Silver Sponsor


The Darker Side

Hybrid Couplers 101

Elegant Simplicity

The benefits of hybrid couplers can be surprising.

But many engineers may not be aware of what they
are and how they can be used. In this article, Robert
takes you through the math, science and technology
around hybrid couplers—and how they provide a
lesson in the elegance of simplicity.

Robert Lacoste

W elcome back to the Darker

Side. Have you ever
encountered a problem that
seems impossible to solve,
until you discover that the problem has a
simple and elegant solution? This happened
this cable to be as cheap as possible. A good
option would be to use a single twisted pair.
Will that work? Yes, but with an issue: If
you simply connect both microphones and
earphones on a single pair of wires, the two
audio signals will add together. That means
to me when I first met the amazing “hybrid that you will hear your correspondent, but
coupler.” What is a hybrid coupler? And if you also what you are saying. Trust me, this is
know, how does it work? And how do you build very unpleasant.
one? If you don’t know the answer to any of So, the thousand-dollar question is the
these questions, then please take a seat and following: Is it possible to connect the two
enjoy—and be as amazed as I was! phones through a single pair of wires so that
you hear only the audio coming from the
THE PROBLEM remote phone? Moreover, is it possible to keep
The need for hybrids first arose with old a full-duplex transmission, meaning that both
analog telephones. Imagine that you want correspondents can speak at the same time?
to install a kind of basic wired intercom As you may imagine, the answer is yes. But
system between your home and your garage. how? Here I encourage you to stop reading
You would build and install a pair of phone this article now and to try to find a solution
handsets. You know how to do that: Each by yourself.
phone would include a microphone and … Are you back? Have you found an idea?
an earphone (Figure 1), as well as small Maybe a kind of complex frequency modulation
preamplifiers and audio amplifiers. Easy. and multiplexing? Or a digital encoding and
But how to interconnect these phones? You time-sharing protocol? Well, in fact there is a
could run a cable and I’d guess you’d want very simple and purely analog solution—and 59

Figure 1
The problem: How do you transmit
two signals using a single phone line
without earing yourself?

? ?

Figure 2
A B The idea is simple: The transmission
line carries the sum of the two signals,
however each recipient can recover
the signal sent by its counterpart by
A A+B B simply subtracting what it has sent.
(A+B)−A=B − − (A+B)−B=A
+ +

can even work without any power source: both phones are well matched. If not, the sum
Hybrid couplers are exactly what you need! will not be exact, and the subtraction will not
be accurate, giving an imperfect rejection of

BASIC PRINCIPLE the local transmission.
There are two fundamental ideas behind
hybrid coupling. The first is simply subtraction OPERATIONAL AMPLIFIERS
(Figure 2). Let’s call the two phones A and Enough theory. Now let’s look at how
B. I will assume for a minute that the audio to use these ideas for actual circuits. I will
signals coming from microphones A and B are start by sharing with you the schematic
simply summed on the wire, so you get A+B. of a hybrid coupler using an operational
How could you recover the signal that must be amplifier (op amp). This may be not the
sent to the earphone A? You do it by simply technology used for the first phones, but
by measuring the line voltage (A+B) and this is the easiest to explain. In fact, this
subtracting the level of phone A’s microphone is a straightforward implementation of
(A): (A+B) minus A. That gives you be B, the the subtraction and impedance matching
audio coming from the other microphone! concepts I just presented. Look at Figure 3.
Simple, isn’t it? Two identical devices are represented, phone
Well, the second idea behind hybrid A on the left and B on the right. Both sections
coupling is impedance matching. Why? are interconnected through a single wire and
Because the basic principle illustrated in a ground connection. Let’s focus on the left
Figure 2 is a little too simplistic. There isn’t side. The microphone and its preamplifier
something like an actual summator of a are simulated as a 1 kHz / 1 V source V1. The
piece of wire. That said, the behavior may resistor R3 provides an output impedance of
be very close if, and only if, the impedances
are properly matched. I’ve talked about
impedance matching in this column a zillion 1 1,

times. But here a simple explanation will ,++ ,++

be enough. Assume that the transmitter of

/ /2
/*678 /*678
12 1. /#9
phone A has an output impedance R, and '18:9 + + '18:9

that the input impedance of phone B is also

1 1
+ -./ +
R. These two impedances, like resistors, will
make a voltage divider. If A is transmitting & .
2 ,
& .

and B isn’t, then the voltage on the line will



be A/2. Similarly, if only B is transmitting, 0+(++


this voltage will be B/2. And, of course, if

both are transmitting the voltage on the line
will be A/2+B/2 thanks to the linearity of the Figure 3
system, which is (A+B)/2. So, there is actually Shown here is a hybrid coupler made with an op amp. The signal source V1 is sent on the transmission
a summation of both signals on the line, but line through R3, which match the input impedance of the receiver. Therefore both inputs of the difference
with a factor ½ and only if the impedances of amplifier U1:A are set to V1 divided by two. So, its output is theoretically null, as shown on this simulation.

Figure 4
A variant of the op amp based hybrid,    
/ 3 23 /
here with an added transmit buffer  
0 0
and an isolation transformer. -
. .2
.+95: .+95:
.$; 12 1 10 1 .$;
(1:<; , 0,, 0,, , (1:<;

1 1
, -. -. ,

  2 2  '

 - - 
 41 412 
$ / / 2$
/,),, /,),
Vac Vac
/. /.

41$562 2+ 41$562 2+

600 Ω, which will match the input impedance I configured V1 to 1 V (left side transmitter)
of the right section, which is R6 = 600 Ω. and V2 to 0 V (right side transmitter). Look at
A basic Texas Instruments LM358 operational the two AC voltmeters: The right one shows
amplifier, U1, is configured as a difference 0.71 V RMS, which is exactly 1 V peak. The
amplifier. As wired—and thanks to R1 and left one shows 0 V, as expected. The return
R2—it calculates the difference between twice channel is perfectly uncoupled. Of course, if
its positive input and its negative input. Look you change the voltage level of V2 and run
again at the Figure 3 schematic, the output of the simulation again, the voltmeter on the left

the difference amplifier is then: side will move accordingly. Magical, isn’t it?
Just as a reference, Figure 4 shows you a
'  (% 
(A + B) variant, still based on an op amp, but closer
2 × line voltage − V1 = 2 × −A to a real-life design. Compare it with Figure +*
2 3, and you’ll see that I just added another
amplifier configured as a voltage buffer in

      !"#$%&'  (% ) *#+* &
which gives B as expected. This output is order to avoid any impedance error due to
connected to a virtual AC voltmeter, which imperfections of the source. A pair of line
acts as the earphone. transformers were also added to insulate
In order to show you that this is actually both sections and avoid any nasty ground
working, I simulated this schematic using loop. Such a schematic can probably be used
a SPICE-based circuit simulator. I used my as a basis for any intercom system.
preferred CAD tool: Proteus from Labcenter
Electronics, but you can easily reproduce HYBRID COUPLERS
these examples using any simulator like the Now it’s time to forget op amps and jump
free and good LT-Spice. As shown in Figure 3, to 100 years in the past. Early hybrid couplers
were made with transformers, configured in a
so-called hybrid-coil configuration—a kind of
dual winding transformer. The name “hybrid
Port 1
Hybrid coupler” of course comes from this specific
Port S
coupler implementation, even though—as we just
Port 2
discussed—hybrid couplers can be made with
other solutions besides transformers.
Signal out −3dB In a moment I’ll show you how to use
Signal in transformers to build hybrid couplers. But
Signal out −3dB first let’s address the question: What is a
hybrid coupler from a system point of view?
Signal in −3dB
Signal out
There are, of course, plenty of variants. In
(Leakage only)
Figure 5 I illustrate the behavior of the
ubiquitous passive 2-port hybrid. As shown,
(Leakage only) such a hybrid has three ports, named 1, 2 and
Signal out S (for sum). All these ports are bidirectional.
Signal in −3dB
If you apply a signal to the S port, it appears
Figure 5
Signal in −3dB on ports 1 and 2 simultaneously. Because the
A hybrid coupler, more generally is a
bidirectional three port device. Port Signal sum signal is shared on two outputs, the power
1 and port 2 are isolated from each Signal in −3dB on each of them is half the input power.
other. Therefore, such a hybrid has an attenuation 61

of 3 dB from S to 1, as well as 3 dB from S to How does it work? Once again, it is all

2. In a similar way, if you apply a signal on about subtraction and impedance matching.
port 1, it will appear on port S with the same Impedance matching? Look again at the left
3 dB attenuation. The hybrid has the same section on Figure 6. All sources and loads
loss in any direction when using a given pair are well matched to 600 Ω. Moreover, still for
of ports. However, no signal appears on port impedance matching, the transformers have
2—it is isolated from signals applied on port a precise turn ratio, here that ratio is 1.414.
1. Note that the behavior is the same if you For those interested, this is because the
use port 2 rather than port 1. By extension, turns ratio of a transformer is proportional
if signals are applied to both ports 1 and 2 at to its voltage ratio, and the impedance ratio
the same time they will be summed on port S, is proportional to the square of this number.
with a 3-dB loss again. Remember Ohm’s Law? P = V 2 /R.) Since we
I guess you’ve made the connection
between this explanation and my initial phone
example. Take such a hybrid coupler, connect - -

the microphone on port 1, the earphone

( (

on port 2 and the line on port S—that’s it. ,

The signal coming from the microphone will '-576 46)

output on the line, but not in the earphone

because the two ports are isolated from each "(*:%

other. Keep in mind that this presentation

- -0
( (

is dealing with a “perfect” hybrid coupler.

Real devices have losses a little higher than 8-0 8-(

the minimum 3 dB, and some leakage will be

8-#490+ 8-#490+
46) 46)
406) 406)

present between isolated ports. But you get

the idea. One more point: If a signal applied -/ -(
.) .)
on port 1 appears only on port S and with half Vac ( ( Vac

the power, that means that the other half will

have to go somewhere. It will be dissipated as
heat inside the hybrid coupler. Figure 6
The ubiquitous balanced hybrid coupler.
Even though they were invented more than / /1

100 years ago, transformer-based hybrid ,-- ,--

couplers are still very common devices today.

. 9/ 9/1 .1
.+456 .+456
.#7 .#7
They are frequently used in radio frequency '/687 '/687

devices, and can be bought as ready-made

/ /,
3-- 3--
parts from companies like Mini-Circuits. For     $2
example, a hybrid will be used when two 9/#5: 1+ 9/#5: 1+

transmitters must share the same antenna. /

517) / &  '$ (
Thanks to the isolation between ports, this ,-- ,--
will avoid blowing out the output transistors


of one of the amplifiers when the other is

       !"#$%&  '$ () *"+* %
Next question: How to use transformers to Figure 7
make a hybrid coupler? I will start with the A single transformer can be used if all signals share a common ground.
example of the double transformer hybrid,
which is used when all input and output signals
are balanced signals (differential lines). Have ABOUT THE AUTHOR
a look at Figure 6. You’ll recognize the two
Rob e rt Lacoste l ive s in Fran ce, b e tw een
emulated phones again—one on the left and
one on the right. Here they are connected Paris and Versailles. He has 30 years of expe-
through a differential 600-Ω pair. However, in rience in RF systems, analog designs, and high
this case there isn’t an op amp—and there’s speed electronics. Robert has won prizes in more
not even a power supply. And the simulation than 15 international design contests. In 2003
still works as expected. Here the left generator he started a consulting company, ALCIOM, to
is excited, and we get 0 V on the left-side AC share his passion for innovative mixed-signal
&  '$ (
voltmeter and 0.18 V RMS on the right. This designs. Robert’s bimonthly Darker Side column
voltage is four times lower than on Figure 3. has been published in Circuit Cellar since 2007. +*

That’s because there is no amplification, but You can reach him at
there’s still a perfect isolation between each

      !"#$%&  '$ () *"+* %
pair of microphone/earphone.

Figure 8 a single transformer for each device. This

It may not be obvious, but X and Z are configuration is possible only if the source
indeed isolated from each other with a
and load—meaning the microphone and
proper choice for Y. W is the sum port. X
earphone—share the same ground. Look at
Y Figure 7 for this setup. Now there is only one
W double-winding transformer on each side and
a couple of impedance matching resistors.
The behavior is still the same. Here with V1 =
1 V and V2 = 0 V the simulation shows a null
voltage on the V1-side receiver, and 0.18 V RMS
on the V2 side, as expected. How does this
work? Well, this may be a little more complex
to understand. First, for impedance matching
want a power ration of 2:1, we need a voltage purposes the transformer still has a 1.414
ratio of √2:1 or 1.414:1. turn ratio, but all resistors are not equal.
What about subtraction? Look at the way Source and load resistors are 600 Ω, but the
TR1 and TR2 are interconnected in Figure 6. intermediary resistor R1 must have half the
A signal coming from V1 creates a magnetic value (300 Ω).
field in TR1, and this generates a signal in To help you understand why such a design
each of the two secondary coils. One of them is indeed a hybrid coupler, look at Figure 8,
is connected to the transmission line so this which is a redrawn arrangement of the same
signal is indeed transmitted. However, these idea. X and Z are the impedances of the two
two coils are also connected to the two input ports (1 and 2). W is the impedance of
secondary coils of TR2, but one is reversed. the sum port (S). Finally, Y is a load resistor.
That way, the magnetic fields generated in Imagine that you inject a signal on W. This

TR2 by these two coils cancel each other, will create a magnetic field in the transformer,
and no signal is transmitted to R5 and the so a current will flow through X and Z. Ports
earphone. We do have theoretically perfect 1 and 2 will get a signal as expected, each
isolation, and the simulator does work are with half the input power. Meanwhile Y, which
illustrated on the Figure 2. The AC voltmeter is between ground and the middle point of
shows 0! the secondary winding, will not dissipate
SINGLE TRANSFORMER? Now the opposite side: What happens
I hope you find this design quite clever. But if you inject a signal on one of the input
it’s also possible to do the same trick using ports, say X? A current will circulate in the
transformer so the primary coil will get
excited and a signal will appear as expected
. .
on W, the S port. However, no signal will
appear on the other input port, Z, providing
, 9. 9. ,
- 9.$5: + 9.$5: + -
-$7 isolation. This is due to the 180-degree
phase inversion that exists between the two
(.687 (.687

ends of the secondary winding. The voltage

. .1

generated in the bottom part of the wiring

will exactly compensate the voltage across
.0 ., Y, giving a null voltage on Z. You can easily
, , simulate that if you wish.



Last but not least, an even simpler

hybrid coupler can be designed using a
Figure 9
This autotransformer version is even simpler, but the sum impedance is half the impedance on each port
single inductor with a mid-point tap—which
(here 300 Ω). is nothing other than an auto-transformer.
Look at Figure 9. The circuit still behave as
a hybrid coupler. Here the line impedance is
For detailed article references and additional resources go to: 300 Ω—half the impedance of each load and source. How does it work? Well, in a nutshell
the signal coming from V1 propagates
through TR2 and generates a signal on the
RESOURCES line. However, it propagates also through R1.
Mini Circuits | The signal arriving on the receiver impedance
Labcenter Electronics | R5 is of course the sum of these two signals.
Texas Instruments | But the phase shift through R1 is zero while

'  (%  2 63

34 34,
., . . .
  8., 8.  
- 8.$49 + 8.$49 + -,
-+345 -+345
-$6 -$6
(.576 (.576
'345 #*:&
. .0
, ,

.'#& .',#&
.' .',
,- ,-
./ .
" 8 " 8,

Figure 10  
Shown here is a nice illustration of the “magic” of a hybrid coupler. Two overlapping pulses, of different amplitude and frequencies, are sent by each node (green). The
'  (% 
signal on the transmission line is then quite complex (center plot). However, each recipient can recover the transmitted signal with no difficulty (red)! detected. 1

the phase shift through the transformer WRAPPING UP
is 180 degrees. With a proper impedance !"#$%&'  (% ) *#+* &

      As usual, I have only scratched the
matching these signals will cancel each other surface of the topic of hybrid couplers. In
out and a proper isolation will be achieved! particular, leakages and losses are never as
Here another simulation may be welcome good as my simulations—real life is a little
to clearly understand what is the “magic” of more complex. Moreover, plenty of other
a hybrid coupler. Look at Figure 10. I simply technologies could be used to build hybrid
used the same pair of auto-transformer couplers. For example, for high frequency
hybrids, but modified the generators a little. applications, it’s possible to design such
On the left side, V1 is generating a 1 kHz/ couplers simply using well designed PCB
1 V tone but is switched to ground through tracks, thanks to microstrip techniques.
the relay R1 except from T = 5 ms to T = This would be a good subject for another
15 ms. That’s a way to simulate a pulsed column, but in the meantime look on the web
tone, and this transmitted tone is displayed for entries like “rat-race couplers,” “Lange
on the left-side graph in green. In a similar couplers” or “branchline couplers” to get an
way, I simulated another pulsed tone on the overview.
right-side generator, here with a 1.88 kHz All this said, I must admit that hybrid
/ 1.2 V carrier switched on between T =10 couplers are now scarce in telephone
ms and T = 20 ms, as illustrated in green networks. That’s because 2-pair wires are
on the right-side graph. These two pulses the norm and also because digital processing
are overlapping, so that the signal on the and transmission has some advantages. But
transmission line is a little strange, as shown even though they were invented in the early
on the middle graph. Now look at the red days of telephone systems, hybrid couplers—
plots, which are the signals received through and in particular transformer-based
the hybrid couplers on both sides. The signal hybrids—are still heavily used in applications
received on the right side is attenuated but such as wireless systems, microwave power
is exactly the one transmitted by the left combining and splitting, phase shifters,
side, and reciprocally! So, if V1/V2 were digital line interfaces, submarine repeaters
microphones and R5/R6 were earphones you and so on. So, you definitively must not
will hear your correspondent’s voice clearly forget this solution when designing your own
but not your own voice—even if both signals projects. Bring hybrid couplers out of your
share the same line! darker side!

The Consummate Engineer

Humidity Sensors
From Vapor to Voltage
George has covered a variety of
sensor types in his column throughout
this year. This time he focuses on
humidity sensors. In this article,
George examines the basic concepts
of measuring humidity and compares
different types of hygrometers.

George Novacek

H umidity is among the important

physical quantities we often
need to measure or modify
with the help of an electronic
control system. Water and water vapor are
ubiquitous and their asymmetrical electrical
AH depends on the temperature and
pressure. On average, a cubic meter
(35.315 ft 3) of air at 85°C (185°F) contains no
more than about 30 g (1.06 oz) of water vapor.
The relative humidity (RH) is expressed as
a percentage of the actual amount of water
charge distribution causes water molecules vapor in the air with respect to the amount
to be adsorbed. Adsorption is the adhesion it could hold at its current temperature.
of a thin layer of molecules—such as gases Warm air can contain more water vapor
or liquids—to the surfaces of solid bodies or (moisture) than cold air, so with the same
liquids with which they are in contact. What amount of moisture, colder air will have a
we call humidity, therefore, is water vapor in higher relative humidity. With that in mind, a
the air. relative humidity of 50% means that at that
Humidity is the amount of water vapor— specific temperature the air holds only 50%
that is the gaseous state of water—held of water otherwise needed for the air to be
in the air. As the temperature of the air saturated.
increases, more vapor can be contained The relative humidity of an air-water
since the movement of molecules at higher mixture is defined as the ratio of the partial
temperatures prevents condensation from pressure of water vapor in the mixture (p H2O)
occurring. Let’s consider the basic concepts to the saturated vapor pressure of water
of measuring humidity. (p*H2O) at a given temperature. So, as the
There are three main expressions of following equation suggests, the relative
humidity: absolute, relative and specific. humidity of air is a function of both water
Absolute humidity (AH) is the absolute amount content and the temperature:
of water in a given volume of air, stated in
grams of water vapor per cubic meter of air p H2O
(g/m3). It reflects the actual mass of water RH =
vapor in the air (mH2O) divided by the volume p *H2O
of the air and vapor mixture (V NET ) regardless
of the air’s temperature: Specific humidity refers to the weight of
water vapor contained within a unit weight
m H2O of air and is defined as grams of water vapor
AH = per kilogram of air. Notice that absolute and
Vnet specific humidity are conceptually similar. 65


Dew point is also an important concept. It
is the temperature at which air is saturated
with water and condensation begins. The
higher the dew point temperature, the greater
the amount of moisture in the air. Compared
to relative humidity, dew point is frequently
considered to be a more accurate method for
measuring the humidity and comfort of the
air. However, unlike the relative humidity, it is
an absolute measurement.
At the dew point temperature, the relative
humidity is 100%. Below the dew point
temperature, condensation will result and
liquid water will begin to form. Logically, if
the relative humidity is 100%, the dew point
temperature and the actual air temperature
must be the same. But this does not the air temperature. Relative humidity is This diagram illustrates the principle
necessarily mean that precipitation will occur. approximately the ratio of the actual vapor of a hair hygrometer.
It just means that the amount of moisture pressure (AVP) to the saturation vapor
in the air has reached saturation. Saturation pressure (SVP):
may, for example, cause fog to form on the
ground and clouds—both of which consist of AVP
tiny water droplets suspended in the air. RH = ×100%
While the dew point indicates the moisture SVP

content in the air, the relative humidity
does not, because RH is also a function of The AVP is the amount of water vapor
the air temperature. In other words, we in a volume of air which increases as the
cannot determine the relative humidity from amount of water vapor increases. SVP is the
knowing the dew point without also knowing maximum water vapor that can exist at a given

are so yesterday.

Win an IkaScope!
The wireless oscilloscope probe by Ikalogic.


This Adafruit Si7021 humidity/ Let’s begin by looking at the most common
temperature break-out board is
method for measuring humidity: the hair
approximately 0.5” x 0.5” in size.
hygrometer. Hair is hygroscopic, meaning
it tends to retain moisture. Also, its length
changes with humidity, and this can be
detected and converted into an electrical
signal. Other organic materials also work in
place of hair.
The first hygrometer was built in 1783 by
Swiss physicist and geologist Horace Bénédict
de Saussure using a human hair. Since the
hair hygrometer’s response time is dependent
on temperature, it can be used from about
-60°C to +90°C (-76°F to +194°F). Hair
hygrometers using a piece of plastic instead
of hair are used to this day. The change in
the “hair” length is detected by numerous
methods of displacement and/or position
temperature. Air at 100% relative humidity detection. For more on these methods see my
(RH) contains water vapor whose AVP is equal 3 part “Displacement and Position Sensors”
to its SVP at the given temperature. In other article series [1] in October, November and
words, the air is at equilibrium with liquid December 2016 (Circuit Cellar 315, 316 and
water. Water vapor is one of the gases in our 317). The most common hygrometer that you
atmosphere. And its total pressure according find in heating, ventilation and air conditioning

to Dalton’s law is the sum of partial pressures: (HVAC) systems is comprised of a microswitch
activated by a humidity sensitive plastic strip
P = PN2 + PO2 + PH2O + other gases as shown in Figure 1.
Chilled mirror hygrometers are among the
Devices to measure relative humidity most precise humidity measuring instruments
are called hygrometers. In this article, we’ll commonly available. Their principle relies
consider only hygrometers that can produce on chilling a mirror to the point where the
an electrical signal and, consequently, can be air is just saturated with water vapor.
used as a part of an electronic control system. The condensation on the mirror surface is
detected by an optoelectronic mechanism,
thus establishing the precise dew point
temperature. The temperature of the mirror is
maintained by electronic feedback to sustain
ABOUT THE AUTHOR dynamic equilibrium between evaporation
George Novacek is a retired president of an and condensation.
Industrial-type chilled mirror hygrometers
aerospace company. He is a professional
attain dew point accuracy of 0.2°C (0.36°F)
e n g i n e e r w i t h d e g re e s i n A u t o m a t i o n
or better within the temperature range of -20
a n d Cy b e r n e t i c s. G e o rg e ’s d i s s e r t a t i o n
°C to +40 °C (-4°F to +104°F). At a typical
project was a design of a portable
office environment this accuracy correlates
ECG (electrocardiograph) with wireless to a relative humidity accuracy RH of about
interface. He’s been contributing articles ±1.2%. On the negative side, the chilled mirror
to Circuit Cellar since 1999. Contact him at hygrometers need frequent cleaning, a skilled with “Circuit Cellar”in operator and periodic calibration to maintain
the subject line. their level of accuracy. They are also prone
to drifting in environments where smoke or
otherwise impure air may be present.
Spectroscopic chilled mirrors detect the
For detailed article references and additional resources go to:
dew point temperature by a spectroscopic
detection. This method avoids many of the
Reference [1] as marked in the article can be found there.
pitfalls of the common chilled mirrors, while
RESOURCES operating drift free.
Adafruit | Present day electronic RH sensors are
Sensirion | the most common type used today. That’s
Silicon Labs | because they can be readily used as sensors in
SparkFun | automatic control systems. Capacitive sensors
Texas Instruments | rely on changes of the dielectric constant of 67

Polymer Thermal Crystal

Hair Dew Point LiCl Resistivity
Capacitor Conductivity Oscillator
0 to 100%RH -80°C to 100°C -45°C to 95°C 0 to 100%RH 0 to 100%RH 0 to 30 g/m3 0.02-1k ppm
a polymer. Typically, such hygrometers have sensors measure absolute, rather than Listed here are the characteristics of
a range from 5% to 95% RH with ±2% RH relative humidity. several common methods of humidity
accuracy. Gravimetric hygrometers measure the measurement.
Resistive hygrometers measure the change mass of an air sample compared to an equal
of electrical resistance of a material caused by volume of dry air. This is considered the most
humidity. Among typical materials are salts accurate primary method for determination
and conductive polymers. One example is a of the moisture content of the air. This
lithium chloride (LiCl) in a polyvinyl acetate method is often automated and suitable for
binder on an insulating, such as a polystyrene, calibration of less accurate instruments.
substrate. Resistive sensors are less sensitive Table 1 lists the characteristics of several
than the capacitive sensors and their sensing common methods of humidity measurement.
material properties are adversely affected There are other methods for measuring
by both humidity and temperature. Because humidity, but there are too many to mention
of that, the sensors are often combined with in this article. Needless to say, new methods
a temperature sensor. An example along are being developed as we speak. Some
those lines is Silicon Labs’ Si7006-A20. For methods are applicable for use with embedded
experimenters, Adafruit markets a breakout controllers, others may be too slow, expensive
board Si7021 (Figure 2). or cumbersome. For those reasons they are
Extremely low vapor concentration, down used in laboratories only.
to 0.02 ppm by volume, can be measured by For the readers who want to experiment

crystal oscillators. The surface of the crystal with measuring humidity, there are many
is coated with a hygroscopic material which, inexpensive sensors available such as the
upon adsorption of water vapor, changes the Silicon Labs’ Si7006-A20, Sensirion SHT3x-
resonant frequency of the crystal. Thermal DIS, Texas Instruments HDC1080 and others.
hygrometers measure the change of thermal Breakout boards are available from vendors
conductivity of air due to humidity. Such such as Adafruit, SparkFun and others.

From the Bench

Fog-Detection Audio Project

Using Arduino UNO

Fog reduces visibility, sometimes down to a few

feet. That’s why fog horns are so important.
In this article, Jeff embarks on a project that
makes use of humidity sensors to detect fog,
and automatically plays an audio response
when fog is detected. Aside from the sensors,
his project also makes use of Arduino hardware

and software.

Jeff Bachiochi The Golden Gate bridge extends into the foggy abyss that often times
rises from San Francisco Bay to swallow up all who enter.
(Source: Flickr: Golden Fog)

P ea soup. Not one of my favorite

dishes. I just can’t see green soup.
All that said, as a consistency
descriptor, “pea soup” is spot on
for describing fog. You don’t have to live in
San Francisco to appreciate the alien qualities
As the dew point goes up, so does the relative
humidity, creating a smaller differential
between actual temperature and dew point
temperature until fog forms.
The maximum amount of water vapor that
can be held in a given volume of air (saturation)
of the scene in Figure 1. This phenomenon is varies greatly by temperature. Cold air can
commonplace to those who reside in London, hold less mass of water per unit volume than
Seattle, on any lake or in any valley. All we hot air. Relative humidity is the percentage
need is the right combination of temperature of water found relative to the maximum
and humidity, and the clouds of heaven will possible, at a particular temperature.
visit us here on Earth. Most of us have experienced the
Fog consists of visible water droplets relationship between temperature and relative
suspended in the air at or near the Earth’s humidity firsthand. When the air temperature
surface. This moisture is often generated is high, our bodies use the evaporation of
locally from a nearby body of water, and forms sweat to cool down. The cooling effect is
when the difference between air temperature directly related to how fast the perspiration
and dew point is less than about 4°F. The evaporates. The rate of evaporation depends
dew point is the temperature at which the on how much moisture is already in the air
water vapor in air (at constant barometric and how much moisture the air can hold. If the
pressure) condenses into liquid water on air is already saturated with moisture (high
tiny particles in the air, at the same rate at humidity) perspiration will not evaporate, and
which it evaporates—forming fog. A change we remain hot and uncomfortable. Discomfort
in temperature affects the relative humidity. can also exist when the humidity is low. The 69

drier air can cause our skin to crack and tends Honeywell sensor has analog output, whereas
to dry out the airways. the TI temperature sensor and Silicon Labs
humidity/temperature sensor both use I 2C
MEASURING RELATIVE HUMIDITY to communicate. If you feel uneasy writing
A hygrometer is an instrument used for a function to perform the process, Arduino
measuring the humidity and water vapor libraries are available for many sensors. This
content of the atmosphere, the soil and confined is an advantage for newbies, because you can
spaces. An instrument that measures humidity get a program working with a library and
usually relies on the detection of some other often a sample program to get you started.
quantity—such as temperature, pressure, Then you can go back and write the function
mass or a mechanical or electrical change in yourself as a learning experience.
a substance as moisture is absorbed. Today I don’t want to base the project totally
we use the electrical change of capacitance or on humidity, so I have added an ultrasonic
resistance to calculate humidity. distance measuring device to the project.
Humidity measurement is among the more Because fog forms as the air becomes
difficult problems in basic meteorology. Most supersaturated with water, this should mean
hygrometers sense relative humidity rather that the humidity has reached 100% and water
than the absolute amount of water present. droplets in the air should begin to look solid.
Because relative humidity is a function of both I’m hoping ultrasonics will be reflected by the
temperature and absolute moisture content, droplets and cause a normal non-returned
a small temperature change will translate into ping to be received. The combination of these
a change in relative humidity. two sensors exceeding some predetermined
Some materials’ properties allow humidity limits will satisfy my conditions to determine
levels to be determined based on a change the presence of “fog.”
in their capacitance, resistance, thermal

conductivity or mass. Many humidity sensors AVAST, YE LANDLUBBER!
include a temperature sensor, which allows In a previous article (March 2011, Circuit
them to approach 2-3% accuracy in a changing Cellar 248), I presented the Microchip
temperature environment. Table 1 shows Technology (formerly Supertex) SR10,
several common humidity sensors. Many of an inductorless switching power supply
them are available on some tiny PCB modules controller intended for operation directly
for easy interfacing. from a rectified 120/240 VAC line. This was
I’ve used both the Honeywell HIH- presented in support of creating a 5 V supply
5031 (with a Texas Instruments TMP102 for a lighthouse fixture designed using LEDs.
temperature sensor) and a Silicon Labs Si7021 This month’s project will build upon that 5 V
for measuring humidity in this project. The light, and will add audio to protect and guide

Part # Type Interface Pin Count Voltage
Temperature Humidity

DHT11 Resistive 40-bit serial SIP 4 3.5 to 5.5 VDC 2°C at 0 to 50°C 5% at 20-80%

DHT22 Resistive 40-bit serial SIP 4 3.5 to 5.5 VDC 2°C at -40 to 80°C 2-5% at 0-100%

BME680 +gas, pressure I2C, SPI SMD 8 1.7 to 3.6 VDC 1°C at -40 to 85°C 3% at 0-100%

Si7021 Capacitive I2C SMD 6 1.9 to 3.6 VDC 1°C at 10 to 85°C 3% at 0-80%

HTU21D Polymer Digital,analog, I2C SMD 6 1.5 to 3.6 VDC 1°C at -40+125°C 3-5% at 0-100%

HIH-5031 Capacitive analog SMD 4 2.7 to 5.5 VDC -40 to 85°C/no output 3% at 0-100%

HIH-6031 Capacitive I2C SOIC-8 2.3 to 5 VDC 1°C at 5 to 50°C 4% at 0-100%

HTS221 Capacitive I2C, SPI SMD 6 1.7 to 3.6 VDC 1°C at 15 to 40°C 4% at 20-80%

HDC2010 Capacitive I2C SMD 6 1.3 to 3.6 VDC 1°C at -40 to 85°C 2% at 0-100%

SHTC1 Capacitive I2C DFN 4 1.6 to 2 VDC 1°C at -30 to 100°C 3% at 0-100%

These are some popular humidity sensors with similar specifications.

there is code written to display progress on

each of these devices for seeing debugging
ABOUT THE AUTHOR information. The DRPlayer is a phenomenal
MP3 player that costs under $10. Physically,
Jeff Bachiochi (pronounced BAH-key-AH-key)
the module is about an inch square PCB with
has been writing for Circuit Cellar since a Mini SD card slot on one side and YX5200 on
1988. His background includes product the reverse. It will read MP3 data files from
design and manufacturing. You can reach the SD card using a FAT file system, so you can
him at: load tracks using your PC. For this project, I or at: needed only one MP3 file, that of a bellowing fog horn. The DFPlayer accepts serial data at
9,600 baud (Table 3) for the data format.
The commands are in two ranges. The
lower commands are operational and include
select track, play, adjust volume, and so
boaters who find themsleves out on a lake forth. The upper commands are queries such
under foggy conditions. as track count, status and volume. Besides
I’m centering this project around the always responding to commands, the module
Arduino UNO. While I built the prototype will also send status information when
interface (Figure 2) using the Arduino MEGA, appropriate, for instance, when the media
it only uses the pins native to the UNO. The is inserted or removed. This device has a
sensors/modules that are interfaced in this library that can make things easier. To use
project are shown in Table 2. the library DFRobotDFPlayerMini.h, we
Because the UNO has only a single must do a couple of things. First because
hardware serial port, I set up two additional this project requires a software serial port,

software serial ports—one to talk with the we need to add the library (#include
DRPlayer and one to the optional LCD (output <SoftwareSerial.h>). Create an instance
only). The main port and optional LCD don’t of this as myDFPlayer SoftwareSerial
have to be used in the final project, but myDFPlayer(10, 11); // RX, TX.

, +

 , . /   


# 2!
5> 0/ 

0  #;0



 , . /   






    / . , 


& *<


5# ,.#AB


/ +/
9: /

@ 9 6

         / . ,
!27 12 
3.4 /

The schematic shows the connections
& *<


made between the Arduino Uno

headers and the sensor/module    / .    / . , 
connectors mounted on an Arduino +
prototyping board. The finished board
is shown in Figure 4.

&''($ 71

I abbreviated the module library name to Sensor Power Arduino I/O Bus Current
myMP3 (DFRobotDFPlayerMini myMP3;). Now
the software serial port, myDFPlayer, can SR04 +5 V Trig digital output
Digital I/O 15 mA
be initialized to the same baud rate as the Ultrasonic Ground Echo digital input
module myDFPlayer.begin(9600). Finally, HIH5031 +5 V
the module, myMP3, can be started myMP3. Vout analog input Analog 200 µA
Humidity Ground
After initializing myMP3, the volume +3.3 V SCLK digital output
defaults to maximum, so I need just Humidity I2C 4 mA
Ground SDAT digital I/O
one command to play the file from Temperature
the SD card “Foghorn.MP3”, myMP3. TMP102 +5 V SCLK digital output 10 µA idle
play(fileNumber);. I have multiple Temperature Ground SDAT digital I/O 80 µA
foghorn tracks in the root directory, so any
Busy digital input
can be selected by choosing its associated file
TX digital output
number. The files are sequentially numbered
as written to the folder, not by their actual DFPlayer +5 V RX digital input 20 mA idle
filenames. Therefore, the file number Audio Ground (Speaker 100 mA
you select is the nth file in the folder. By DAC Left
monitoring the DFPlayer’s busy output, you DAC Right )
can determine if the file is being played or TDA7265 (DAC Left
has ended. +12 V Audio
Amplifier DAC Right 4A
Ground 15 W + 15 W
optional Speakers)
Early on, mariners were guided by fires built +5 V
Serial LCD TX digital output Serial 20 mA
on hilltops, which improved visibility. Where Ground

hilltops were nonexistent, placing the fire on TABLE 2
a raised platform became a practice, and Each sensor/module will add some current draw to the project. Although current can be minimized in some
that led to the development of the lighthouse. cases while it is not active, this all becomes important if the project will run on batteries.
Normally located at the entrance to a port,
the lighthouse was used to warn of reefs and
other dangers to mariners. As I mentioned
in my June 2018 column (Circuit Cellar 335)
on PIR sensors, the Fresnel lens reduced the
required mass of large lenses. Large lenses
became practical for use in lighthouses, and
in 1823 were first used to greatly improve
visibility. Until 1875, however, the source
of light was produced by coal, oil or gas.
Meanwhile electricity was being phased in to
run the more powerful carbon arc-lamp. It’s
the rotation of these beacons that allows the
concentrated beam to be seen further than
a constant unfocused light. Today’s rotating
lenses are often replaced by a high intensity
light that emits brief, omnidirectional flashes. Data Byte Format Values
The advantage to this system is that the flash
pattern is specific to each lighthouse, thereby Start 0x7E
identifying location. Version 0xFF
But no matter what beacon technology is
used, fog makes a lighthouse beacon useless. Length 0x06 (Version-Parameter_Low)
Fog reduces visibility, sometimes down to a Command 0x01-0x1A or 0x3C-0x4F
few feet. Imagine driving on the highway with Feedback 0x00 (no ACK needed) or 0x01 (please send ACK)
your eyes closed. Not a comfortable feeling.
Traffic on our waterways is not as congested Parameter_High
Data dependent on Command
as on our roads, yet running into another Parameter_Low
vessel, getting hung up on a reef, or striking Checksum_High
an iceberg become possibilities if we have no Complement of Total of Length Bytes +1
vision. During times when a lighthouse beacon Checksum_Low
cannot penetrate the atmosphere due to a wall End 0xEF
of water droplets, the fog horn is implemented
to give an audible warning of peril. And it will
This is the Command packet format for communication with the DFPlayer. All commands are sent at 9,600
cut through the fog where a light would fail. baud.

List of the library functions I’m using Library Functions Purpose
for this project
#include <LiquidCrystal.h> Optional for LCD output

#include <SoftwareSerial.h> Communications to the DRPlayer

#include “SparkFun_Si7021_Breakout_Library.h” I2C humidity and temperature sensor

#include “DFRobotDFPlayerMini.h” Sound file player

#include <Wire.h> I2C routines

#include <SparkFun_HIH4030.h> Analog humidity sensor

We have the sensors to measure uses two digital I/Os. It does not use a library,
atmospheric conditions and the means to just the getDistance() function call to
play a sound file. Let’s put this all together to calculate distance based on echo return.
provide protection from the dangers of water Along with the include statements, all the
travel under low visibility when close to any connections to the Arduino I/Os are defined,
natural or man-made hazards near shore. and any variables that I want to make public
To simplify the programming needed are also type cast. As discussed earlier,
to use any external I/O device with the friendly device names are assigned to make
Arduino, libraries of functions can be listed the code easier to understand. Also note
at the beginning of the program. This allows that your humidity and temperature sensors
the compiler to place them in executable are chosen here. Be sure the choice you
memory. Once in memory they can be called make matches the hardware that you have

upon, using a function call. Table 4 lists all of attached! Once all this preliminary stuff is
the libraries I’m using for this project. set, the compiler can make assignments so
The alternate temperature sensor TMP102 that when the code begins to execute, all the
is an I 2C device. It uses the I 2C library and the support code is firmly in place.
getTemperature() function call to retrieve There is still some work to be done in the
temperature data. The SR04 ultrasonic device mandatory setup() function that must be
included with each program. Here is where
we make the actual connections to everything
the compiler put in place. We must define how
we want each of the I/O bits we require, to be
initialized as input or output. Most libraries
require some kind of initialization—like the
.begin() function mentioned earlier—so
that they can request their needs of I/O and/
or memory space. The Arduino UNO uses its
only hardware serial port for programming
through the USB connector. While this port
is available to the user, care must be taken
when connecting it physically to a serial
device. To alleviate conflict, I use this only
as a debugging port when connected to my
PC and the Arduino IDE. I added an optional
software serial port for an external LCD, to
monitor operation without connection to
a PC. This way, I can have debugging data
FIGURE 3 while running this away from AC power while
This photo shows the debugging/data LCD connected to a software serial port on the Arduino prototyping board. on batteries. Figure 3 shows a typical screen
The 4x20 LCD requires power, ground, and a serial output line. Simple commands allow easy screen formatting. of debugging data. The final project does not
need the LCD—which adds about 20 mA to the
Additional materials from the author are available at: total current draw—but it is handy. The main loop() function is the last
mandatory function for any Arduino program.
RESOURCES This is where the work gets done repeatedly.
Honeywell | For this project, we have five operations to
do. The first three get samples from each
Microchip Technology | of the sensors—humidity, temperature and
Silicon Labs | ultrasonic. Previous sensor values are kept 73

to compare with the new readings. If there

has been a change, then the display function
is called for that sensor, and the new values
updated to the USB and LCD outputs. The last
operations determine if there are sufficient
humidity or distance measurements to signify
the existence of fog. The result is updated to
the USB and LCD. Should the result suggest
there is fog present, then the MP3 module
is called to bellow out a warning using the
chosen sound file. The MP3 module has an
amplifier on board to drive a speaker directly.
Should you require more volume, you may
add the optional 25 W amplifier.
The MP3 module’s busy output is monitored
to prevent the program from continuing until
after the sound file has finished playing. Once
it has finished, the loop() is ended and all
is repeated. Note that if there is no fog, the
sound file is not played. Instead, LowPower.
powerDown(SLEEP_8S, ADC_OFF, BOD_
OFF) is executed, which puts the Arduino
into a sleep mode for 8 s before finishing the
loop() and repeating. This cuts the current
while there is no fog, to reduce current

requirements. You can add power-down
routines for those peripherals that support
this, to further reduce current draw. Note the
debugging print statements before and after
this function. If you don’t include Serial.
flush(), the board goes to sleep before
“Zzzzz” has printed!


If you’re looking for a garden statue of a
lighthouse, many 18" models are available.
Fewer options exist with larger sizes. I FIGURE 4
found a 48" model at my local big box club Here is the Arduino and prototyping board, connecting power, speaker, ultrasonics and humidity/temperature
for around $100. Most prefab models are sensors (minus the LCD). This is all powered by a battery that is recharged using a solar cell.
molded fiberglass. If you are a woodcrafter,
plans are available for 4' to 7' (and larger)
sizes. The hollow base has plenty of room for
I poured a small concrete pad to give the
lighthouse a rigid mount. A hexagonal plate,
cut from a plastic cutting board, was bolted
to the pad with concrete fasteners. The plate
created a maintenance-free mount for the
lighthouse, using a couple of locking hasps to
allow quick removal. You will probably want
to put your circuitry into a plastic enclosure,
even though it is mounted within the body.
The electronics are contained in a 4.5" ×
4.5" × 3" enclosure that mounts to the plate
(Figure 4).
For the audio, I am using an M50H
horn speaker from MG Electronics. This is
a weather-resistant 8-Ω speaker that is FIGURE 5
This photo shows how the fiberglass
mounted internally. The panes of the window
body was modified to take on the
formed into the molded fiberglass lighthouse
ultrasonic sensor. The window panes
body were opened up with a jig saw and were removed to allow the sound
covered on the inside with screening, to keep from horn speaker to escape.

Comparison of the original Arduino Microcontroller ATmega328P 32-Bit ARM Cortex M0+
UNO and the newer Arduino Zero. Not
only has the speed and memory been Operating Voltage 5V 3.3 V
increased, but also this all comes with
Input Voltage
a less hungry appetite for current. 7 V to 12 V 7 V to 12 V
Note, however, this is a 3.3 V system, (recommended)
which simplifies some sensors but 14 (of which 6 provide
limits the field. Digital I/O Pins 20
PWM output)
UART 1 2 (Native and Programming)
Analog Input Pins 6 6, 12-bit ADC channels
Analog Output Pins 0 1, 10-bit DAC
External Interrupts 2 All pins except pin 4
DC Current per
20 mA -
5 V Pin
DC Current for
50 mA 7 mA
3.3 V Pin
32 KB (ATmega328P) of
Flash Memory which 0.5 KB used by 256 KB
SRAM 2 KB (ATmega328P) 32 KB
EEPROM 1 KB (ATmega328P) None. See documentation

Clock Speed 16 MHz 48 MHz

Length 68.6 mm 68 mm
Width 53.4 mm 53 mm
Weight 25 g 12 g
Idle Current 50 mA 20 mA

out nature but allow the sound to escape. CLEAR OUT THE FOG
I found an ultrasonic module that uses a I feel a little like a train buff—you know, the
single sealed transmitter/receiver, the JSN- ones who detail their layout with mountains,
SR04T-2.0. I like that it requires just a single tunnels, grass, trees, roads, towns and
hole and is already weatherproof. You can see people. Making something as realistic as
my modifications to the lighthouse body in possible creates an atmosphere. It helps us
Figure 5. remember the places we visited or summons
For those of you that like the Arduino but those from deep within our imaginations.
are looking for something that draws lower It was finding the inexpensive MP3
current, check out the Arduino Zero. It is playback module that sparked this project.
compared to the UNO in Table 5. With many Putting it together with the right sensors
projects required to run on batteries today, made for a good solution to a problem I
using a lower power micro helps reduce didn’t even know I had. Isn’t that what it’s
the power supply requirements. While this all about? Learning to use technologies and
newer board cost about twice as much, it then combining them to create magic! And all
has some great features that you will not without the use of a wand. Please forgive me
have to add separately, such as an RTC. Harry Potter.
Heads up: There has been a bit of jockeying
for position over trademarking among Be sure to go the Circuit Cellar article code
the Arduino camp. The latest information download page on to get the
suggests this has been resolved, and we can Arduino code discussed in this article.
continue to have confidence in all products
released by the group. If I understand this
correctly, manufacturing rights for Arduino
in the US are now in Adafruit’s hands,
whereas manufacturing outside the US
will be under the Genuino name to avoid
existing lawsuits. 75


Tool Environment Upgrade Boosts Efficiency of Multi-Board PCB Designs

The latest release of Zuken’s system-level PCB design engineers to assign topology templates, modify differential
environment, CR-8000, includes several enhancements aimed signals and assign clearance classes to individual signals. Using
at ensuring performance, quality and manufacturability. a rule stack editor during the circuit design phase, hardware
The CR-8000 family of applications spans the complete engineers can now load design rules that include differential
PCB engineering lifecycle: from pair routing and routing width stacks
system level planning through directly from the design rule library
implementation and design for into their schematic. Here they can
manufacturability. The CR-8000 modify and assign selected rules for
environment also supports 3D IC improved cross talk and differential
packaging and chip/package/board pair control. An enhanced component
co-design. browser enables component variants
Front-loading of design intent from to be managed in the schematic, and
Design Gateway to Design Force has assigned in a user-friendly table.
been achieved by adding an enhanced,
unified constraint browser for both Zuken Americas
applications. This enables hardware

Flexible Embedded/IoT OS Targets 8-/16-/32-bit MCUs

SEGGER has introduced emPack, a complete operating customizing a small number of OS adaptation functions.
system for IoT devices and embedded systems. It is delivered emPack has been fully tested with Amazon FreeRTOS and
in source code for all 8-/16-/32-bit microcontrollers and example configurations are available upon request.
microprocessors. emPack is optimized for high performance,
and small memory footprint and easily fits onto typical MCUs SEGGER |
without requiring expensive external memory, keeping the
cost of the embedded computing system to a minimum.
emPack components are written in plain C and can be
compiled by standard ANSI/ISO C compilers. The software

package includes embOS, emWin, emFile, embOS/IP, emUSB-
Device, emUSB-Host, emModbus, emCompress, emCrypt,
emSecure, emSSL, emSSH and SEGGER’s IoT Toolkit.
All emPack components work seamlessly together and
are continuously tested on a variety of microcontrollers from
different vendors. According to the company, it is very easy to
get started with emPack.
Because all components work together through well-
defined interfaces, existing projects that already have a
mandated RTOS can use emPack’s components by simply

SMARC 2.0 Module Serves up NXP i.MX8 Processor

Congatec has announced the conga-SMX8, the company’s first SMARC 2.0 Computer-on-Module based on the 64-bit NXP
i.MX8 multi-core Arm processor family. The Arm Cortex-A53/A72 based conga-SMX8 provides high-performance multi-core
computing along with extended graphics capabilities for up to three independent 1080p displays or a single 4K screen.
The new SMARC 2.0 modules with NXP i.MX8 processors, hardware-based virtualization and resource partitioning are well
suited for a wide range of stationary and mobile industrial
applications including real-time robotics and motion controls. Since
the modules are qualified for the extended ambient temperature
range from -40°C to +85°C, they can also be used in fleet systems
for commercial vehicles or infotainment applications.
The new conga-SMX8 modules feature up to 8 cores (2x A72
+ 4x A53 + 2x M4F), up to 8 GB of LPDDR4 MLC or pseudo SLC
memory and up to 64 GB of non-volatile memory on the module.
The extraordinary interface set includes 2x GbE including optional
IEEE1588 compliant precision clock synchronization, up to
6x USB including 1x USB 3.1, up to 2x PCIe Gen 3.0, 1x SATA 3.0,
2x CAN bus, 4x UART as well as an optional onboard Wi Fi/
Bluetooth module with Wi-Fi 802.11 b/g/n and BLE.

Congatec |


3D Gesture Recognition Controller for Cars

Microchip Technology has announced a new 3D gesture
recognition controller that offers the lowest system cost in
the automotive industry, providing a durable single-chip
solution for advanced automotive HMI designs. Microchip’s
new capacitive technology-based air gesture controller is
well-suited for navigating infotainment systems, sun shade
operation, interior lighting and other applications. The
technology also supports the opening of foot-activated rear
liftgates and any other features a manufacturer wishes to
incorporate with a simple gesture action.
Each 3D gesture system consists of a sensor that can needed cables, software and documentation to support an
be constructed from any conductive material, as well as easy-to-use user experience. All parts are compatible with
the Microchip gesture controller tuned for each individual Microchip’s Aurea software development environment which
application. The Emerald evaluation kit provides a convenient supports all Microchip 3D gesture controllers. The MGC3140 is
evaluation platform for the 3D gesture recognition controller. available now in sampling and volume production quantities.
The kit includes a reference PCB with the MGC3140 controller,
a PCB-based sensor to recognize gestures, as well as all Microchip Technology |

Development Kit Rolls for Cellular LTE-M Smart Modem

Digi International has announced the availability of the Digi a 20- pin Digi XBee socket. Digi International is an AWS
XBee3 Cellular LTE-M development kits. This LTE-M certification, Advanced Technology Partner in the AWS Partner Network
to be followed by the certification of Digi XBee3 Cellular (APN) and the Digi XBee3 Cellular LTE-M is a smart cellular
NB-IoT this month, allows Digi to bring one of the first LPWAN, modem supported by AWS IoT Core.
software-defined technology- The Digi XBee3 Cellular LTE-M
agile modems capable of offering smart modem development kit is
Cat-M or NB-IoT on a single, now available for evaluation and
compact footprint. Designed testing. The kit includes one Digi

to be customer-configurable, XBee3 Cellular LTE-M embedded

developers can easily standardize modem, one XBee3 development
and futureproof their IoT designs board, one active SIM, up to
by simply changing modems six months of free cellular
and SIMs to leverage different service, antennas and power
wireless protocols without having supply and Digi’s full library of
to redesign hardware for different documentation and examples.
regions or applications.
The new Digi XBee3 Cellular Digi International
LTE-M smart modem is integrated
into the development kit via

Mini PCIe Expansion Module Delivers Dual Gbit Ethernet

VersaLogic has extended its line of industrial temperature, rugged Mini PCIe expansion products with the E5. This new Dual
Gbit Ethernet expansion board provides an easy and economical way to add additional Ethernet ports to high-stress embedded
computer systems. Unlike similar Mini PCIe boards, the E5 is completely self-contained with on-board magnetic isolation. There
is no need for off-board magnetics or special cabling.
The E5’s extremely small form factor format allows it to be added to
systems with very little impact to the overall size of the solution. It’s well
suited for size and weight optimized applications. Fully tested thermal
management assures reliable operation over the full industrial temperature
range (-40° to +85°C). Latching connectors and Mil Standard 202 shock and
vibration testing ensure performance in demanding environments. The E5
is customizable, even in low OEM quantities. Customization options include
conformal coating, revision locks, custom labeling, customized testing and
screening and so on.
The E5, part number VL-MPEe-E5E, is in stock at both Versalogic and
Digi-Key. OEM quantity pricing starts at $137.

VersaLogic | 77

The Directory of
Advertisers must furnish digital files that meet our specifications (

All text and other elements MUST fit within a 2" x 3" format.
E-mail with your file.

For current rates, deadlines, and more information contact

Hugh Heinsohn at 757-525-3677 or

This ctober...


PIC® MCU is a registered trademark of Microchip Technology Inc. in the U.S. and other countries
f to a

8/16 BIT PIC® MCUs
Sales: 262-522-6500

Circuit Cellar
2017 Archive
Single Board Computer

1GHz ARM Computer with
Customizable FPGA-Driven
PC/104 Connector
and Several Interfaces
Order yours today
at Industrial Temp

Answer 1— I would argue that “depth” is a measure of
instruction overlap in the sense that it indicates the amount
of time (number of clock cycles) that must elapse before
Contributed by David Tweed
the result of one instruction can be used by a subsequent
However, there might be additional hardware stages
(instruction prefetch and decode, memory write and so on)
that do not contribute to this latency, so the “number of
The generator, the load and the wires are all in series, so
stages” could very well be larger than the “depth.”
there’s only one value of current that applies at all points in
The “optimal depth” concept arises from the fact that
the circuit. KVL tells us that the voltages must sum to zero.
doing a smaller amount of work in each clock cycle (having
Another way of saying this is that the generator voltage must
a large number of stages) generally allows a higher clock
match the sum of the load voltage and the wire voltage.
frequency, but also increases the depth (latency). Eventually,
If the load is a pure reactance, the voltage across it is 90
this can become a liability, when it gets to the point where
degrees out of phase with the current. However, if the wire is
the compiler has no useful instructions that it can schedule
a pure resistance, then the voltage across it must be in-phase
to fill the gaps imposed by the latency.
with the current. Therefore, we must add these two values
This was not much of an issue for early supercomputers,
as complex numbers, which means that the magnitude of
because they were focused on processing large arrays or
the generator voltage must be equal to the length of the
vectors of data that had no data dependencies among the
hypotenuse formed by the two voltages, or the square root
individual operations, and so they could afford to have deep
of the sum of their squares.
pipelines that ran at high frequencies. However, “random”
As you can see from Figure 1, this means that the current
calculations on scalar data generally have more data
is NOT 90 degrees out of phase with the generator voltage—
dependencies and much shorter latency requirements, which
and the in-phase component represents the power dissipated
leads to the need to keep the pipeline depth relatively small.
in the wire.
If not dealt with, this “scalar bottleneck” can severely limit
the overall performance of an application, which is what
Answer 3— When the output is low, Q1 is saturated and
Amdahl’s Law is all about.
driving Q3 into conduction. The emitter resistor of Q3
functions as a current-sense resistor, and when the voltage
Answer 2— The power dissipated in the wires is not reactive
across it begins to exceed the VBE drop of Q4 (about 0.7 V),
power, because the voltage drop “in the wires” is in-phase
Q4 begins to conduct and reduces the voltage at the base of
with the current through them. This is real power.
Q1, which in turn reduces the drive to Q3. The output current
If the load is purely reactive (a pure inductance or pure
is limited to 0.7 V / 70 Ω = 10 mA.
capacitance), the voltage *across the load* is 90 degrees out-
When the output is high, Q1 is cut off and only Q2 is
of-phase with the current, and so no real power is dissipated
conducting. This transistor is wired as a current source,
with the voltage reference being supplied by the two diodes,
Therefore, the load seen by the generator has both a real
D1 and D2, between its base and emitter. One of the diodes
component and a reactive component, because the current
compensates for the VBE drop of the transistor, while the
draw that it experiences has a phase relationship that falls

other limits the maximum voltage drop across the emitter

somewhere between 0 and 90 degrees.
resistor. If this drop becomes too high, Q2’s base current is
Another way of saying this is that the voltage at the load
reduced. Again, a maximum drop of 0.7 V across 70 Ω limits
is not in-phase with the voltage at the generator, because
the current to 10 mA.
of the resistance of the wires. Figure 1 shows a diagram to
illustrate the point.
Answer 4— The collector of Q3 is connected to the junction
of D1 and D2 in order to make sure that the pull-up current
source (Q2) is cut off when the output is low. Otherwise, all
of the capacity of the pull-down circuit would be taken up by
the current supplied by the pull-up source.
D3 provides the path for the output current to flow to Q3
when the output is low. Without it, the current would be
blocked by D2.
D4 and D5 are simply protection diodes that clamp the
output voltage in the case that something back-drives the
output pin, and the 300 Ω resistor helps limit the current in
that case.


For more information: 79

The Future of Computing

How RISC-V Enables
the Next Era

T his is the first opportunity I’ve been given to write

about my views on the future of technology in a
public forum. Yet, in many respects, a big part
of my job is exactly that, predicting the future in
my role for the past 18 years defining our FPGA roadmap
at Microsemi. Anticipating meaningful market differentiation
that our competitors do not exploit is a big part of the job
where I’ve had significant input into our focus on low power, By
reliability and, especially, security as key differentiators. For
my part, I was very early—in 2014 in fact—in identifying the
Ted Speers,
potential for RISC-V and the role FPGAs can play in fostering Board Member, RISC-V
adoption. Here, I make some predictions about the future of
Foundation Board of Directors
computing and how RISC-V fits into that future.
A useful way to look at a computer system is to view it as
organism comprised of nerve endings (devices, sensors and Head of FPGA Product
actuators), nerves (gateways and transport) and the brain
(data centers and the cloud). We’ve gone through at least Architecture and Planning,
three major stages of evolution of this organism, starting Technical Fellow, Microsemi
with telephony and moving to computing and then mobile
(Figure 1). With each stage, the value generated by each new
stage dwarfed the prior stage and new players captured large
chunks of the newly generated value. Ma Bell captured most
of the telephony value. Next, the computing stage evolved
to a point where most of the value was captured by Intel
and Microsoft, followed by some
computer manufacturers and
other software companies. Mobile
network operators emerged as
the new players in the mobile age
and their profits soon dwarfed
those of established players in
the computing realm.
Each stage was enabled by one
or more disruptive technologies
that dramatically lowered costs
and enabled a redrawing of the
value landscape. The transistor
and then the microprocessor—as
Moore’s Law predicted—ignited
computing. Soft processor
IP enabled mobile operators
and phone manufacturers to
capture massive profits. Now
let's examine what’s next for the
embedded computing industry
and how the free and open RISC-V
instruction set architecture (ISA)
will play a pivotal role. FIGURE 1
Framework for the history of computing.

that RISC-V will be widely adopted as the

main processor in this emerging class of SoCs.
And, because it’s free and open, it will be
leveraged in DSAs using custom instructions
or innovative parallel microarchitectures.
An example along those lines is Greenwaves
Technologies’ GAP8 IoT Application Processor
(Figure 2), which has eight RISC-V cores and
custom instructions.

Clearly the groundwork for the next age of
computing is being laid. Embedded systems
engineers are expected to increase their use
of a new breed of devices employing DSAs
based on RISC-V. What’s really exciting is that,
Greenwaves’ RISC-V based GAP8 (Source: Greenwaves Technologies) through the RISC-V Foundation, engineers
working in all domains—from device to
cloud—can collaborate to create the future
of computing. One criterion for this new era
THE ROAD TO DSAS is computing that is secure. In response, the RISC-V
Today, a new major epoch in computing is upon Foundation created the RISC-V Security Standing
us, creating the opportunity for massive new value Committee, bringing together pre-eminent experts
creation. The Internet of Things (IoT) is the name from around the world to help RISC-V lead the way
attached to this new era. But no one player has yet in securing the future of computing. For embedded
been able to attach massive new value creation to engineers, there is work underway to define the
IoT just yet—so the jury is still out. While we wait for fast-interrupts architecture and embedded profiles.
clarity to emerge, work is underway to lay the enabling Participants range from startups to large, successful
groundwork. The ingredients for paving this path embedded IP companies such as Andes Technology and
forward include open source and machine learning. large processor companies such as NXP Semiconductor.
This new epoch has a couple roadblocks: the end In addition to the already up-streamed RISC-V
of Moore’s Law and its partner Dennard scaling. Those support in Linux, most of the leading commercial and
roadblocks mean that waiting for the next x86 to open-source RTOSes have been ported to RISC-V. This
come out on the latest node is no longer the cure to is enabling the next step of porting popular libraries
all ills. At the 2018 ACM Turing Award Lecture the two to RISC-V to fully support the growing ecosystem. On
recipients of the Turing Award, David Patterson and the more esoteric side, a 128-bit extension is being
John Hennessy, spoke of a new “golden age of computer discussed. That might seem irrelevant to the embedded
architecture” and posited that the emergence of systems engineer, but conceptually the memory in
Domain Specific Architectures (DSAs) is the answer to every single embedded device would be uniquely
the end of Moore’s Law. Google (TPU), Nvidia (NVDLA), mapped into the memory space of 128-bit processors
Intel and many well-funded startups are already running in the data center.
exploring machine learning DSAs. Microsemi has taken a leadership role in this effort

It looks like—in the immediate term—we can expect to create solutions for the future of computing. FPGAs
to see an explosion of new, innovative devices that are a natural substrate for developing and deploying
employ both proprietary and open DSAs. RISC-V is DSAs and our focus on low power, reliability and
positioned to play a key role in this wave of innovation. security are ideally suited for the emerging edge
We’re already seeing RISC-V adopted for controllers compute applications. An early adopter of RISC-V,
in domain-specific engines. Google, for example, Microsemi offers its Mi-V Embedded Ecosystem—a
described their investigation of this use case for Pixel good place to get started with the architecture. We
Visual Core in a talk given at the RISC-V Workshop in invite you to check out the inaugural RISC-V Summit in
Barcelona. It doesn’t take much imagination to see Santa Clara running December 3-6.

For detailed article references and Ted Speers is head of product architecture and planning for the programable solutions
additional resources go to: business unit at Microsemi, a wholly owned subsidiary of Microchip Technology, where he is responsible for defining the roadmap for low power, secure, reliable FPGAs and
SoC FPGAs. He joined Microsemi in 1987 and held roles in process engineering and
product engineering before assuming his current role in 2003. Ted is a Technical Fellow
RESOURCES and co-inventor on 35 U.S. patents. Prior to joining Microsemi, he worked at LSI Logic.
Microsemi | He has a Bachelor of Science in chemical engineering from Cornell University. Ted has
RISC-V Foundation | been a member of the RISC-V Foundation Board of Directors since its inception in 2016.
Whether you are an
let our bare boards be the foundation
you build your reputation upon!
Technology: Materials:
Up to 50 Layers Fr4
Any Layer HDI Metal Core
Sequential Lamination Isola
Blind / Buried Vias Rogers
Laser Drilling / Routing Polyimide - Flex
Heavy Copper Magtron
We will make only what is needed,
when it’s needed,
and in the amount needed.
You no longer have to worry about long shelf life
or tie your capital in bare board inventory.
Single Board
Single Computer
Board Computer Computer on Module Touch Panel PC
Technologic Systems introduces the TS-7553-V2, a single board computer
that is a low power, cost effective, Internet-of-Things (IoT) capable, and
ready-to-deploy OEM board with an emphasis on data integrity.

With the TS-7553-V2 connect to Ethernet, WiFi, Bluetooth, USB, RS-232,

RS-485, and CAN networks or devices. Built in module interfaces like the
XBee/NimbeLink socket and internal USB ports allow expansion to other
TS-7680 TS-4900
networks like Cellular, DigiMesh, ZigBee, Lora, and TS-TPC-7990
other proprietary or
Low Power Industrial Industrial High Performance 7” High End i.MX6 Mountable
Single Board Computer with
industry specific networks. This ability to communicate over a wide variety
i.MX6 Module with Wireless Panel PC with Dev Tools Such
WiFi and Bluetooth of wired and wirelessand
Connectivity interfaces puts the TS-7553-V2
Flash Storage as Debian GNU inand
an QTCreator
Starting at position to be an industria
Starting at IoT gateway. Starting at
$159 $89
For specifications goQty
Qty 100
Qty 100

Board Support Packages,

Source Code and Toolchains Available