philo
philo
FEBRUARY 2018
circuitcellar.com ISSUE 331
CIRCUIT CELLAR | ISSUE 331 | FEBRUARY 2018
Video Game Console Uses Microchip PIC32| Home Cleaning Robot (Part 3) |
w Shannon and Noise | IoT Security (Part 1) | Modulation Fundamentals |
Money Sorting Machines (Part 3) w The Future of Industrial IoT
Trust Your Application
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.
www.iar.com/ew
Not Your Average SlingShot.
www.slingshotassembly.com info@SlingShotAssembly.com
Denver 720.778.2400
©2018 COPYRIGHT SLINGSHOT ASSEMBLY
New capabilities and technology advances are > 200+ educational sessions across four tracks:
transforming the unmanned systems industry. Policy | Technology | Business Solutions | Trending Topics
Now is the time to learn about the trends and > Covering the most timely topics:
Counter UAS | Artificial Intelligence | Data
best practices for the next generation of
unmanned technology as well as identify new > New products for technology
725+ exhibitors showcase the full spectrum of technolo-
unmanned systems solutions. gies, products and solutions
Colorado Convention Center | Denver | Educational Program: April 30 – May 3 Exhibits: May 1 – 3
Join us at the spot where new ideas are imagined. Register now at XPONENTIAL.org
2 CIRCUIT CELLAR • FEBRUARY 2018 #331
SUBSCRIPTION MANAGEMENT
E-mail: circuitcellar@pcspublink.com
NEW SUBSCRIPTIONS
AUVSI Xponential 1
circuitcellar.com/subscription
Newhaven Display International, Inc. 19 Advertising rates and terms available on request.
NEW PRODUCTS
HEAD OFFICE
INPUT
Voltage
Quantum Leaps
Jeff Child
4 CIRCUIT CELLAR • FEBRUARY 2018 #331
COLUMNS
(Part 1)
Command Injection
By Bob Japenga
54 Modulation Fundamentals
The Consummate Engineer
By George Novacek
@editor_cc
@circuitcellar circuitcellar
circuitcellar.com 5
FEATURES
20 Designing
Robot
a Home Cleaning
(Part 3)
Circuit Designs
By Nishant Mittal
26 Programmable
Network
Ad Hoc Mesh
Meshed-Up PICs
By Raghava Kumar, Brian Clark and Alex Wong
SPECIAL FEATURE
TECHNOLOGY SPOTLIGHT
PRODUCT FOCUS
By
Dongze Yue and Yixiao Zhang
overall structure of our gaming console. NTSC signal. As electrons sweep across TV
As described in the block diagram in Figure screen, intensity at each point varies so that
1, PICGAME runs on a core Game Manager images are formed.
software block that uses various libraries Full NTSC display video system uses an
to interface with the peripheral devices and interlaced scanning technique, which updates
synthesize video output. Around the main the odd number lines and the even number
FEATURES
software block there are several hardware lines alternatively. The signal involves both
drivers that drives the controller, video output vertical sync signals that divide up even/
and audio. odd frames, and horizontal sync signals that
divide up scan lines. Figure 3 contains a
HARDWARE DESIGN breakdown of one horizontal scan line. Due
Figure 2 shows a wiring schematic of the to low resolution, we used a progressive
gaming console. The VIDEO pin and SYNC pin scanning approach that does not distinguish
are connected via a 2-bit digital-to-analog even/odd fields. To generate sync signals that
converter (DAC) and produce the composite meet NTSC standard and produce pixel-wise
video output. The NES Controller has five pins: black-and-white information of the image, we
CLK, LATCH, DATA, VCC and GND. Besides the used a timer that is accurate to one cycle to
voltage reference pins, the rest of the pins are generate the sync pulse and a DMA module to
wired to the IOPORTB pin 0-2 of the MCU. The get nanosecond accuracy.
audio output is connected to the CVREFOUT pin. The book Programming 32-bit
The NTSC standard (RS170) is used for Microcontrollers in C: Exploring the PIC32,
generating black and white analog signals by Lucio Di Jasio, introduced a way of
that display image on closed circuit TV. synthesizing NTSC video by chaining two DMA
Figure 3 shows a diagram for black/white channels together [2]. But another approach
PIC32
Game manager
Manager update
Thread 2:
Controller Thread 1: Game manager
FIGURE 1
The gaming console has a core software block called game manager that does the computing and runs all the game related contents. A series of drivers and signal generators lie
around the main software block, providing support to interface with peripheral devices.
8 CIRCUIT CELLAR • FEBRUARY 2018 #331
($2
Controller uses a serial interface to transmit
a packet of data from the controller to the
&-
MCU. As shown on the schematic diagram
-)01
4
(Figure 2), the MCU sets the latch pin high to
begin transaction and toggles the clock pin
)
. 9
3 4
7 84 9-
to emulate clock pulses. As the clock signal
FEATURES
-
>
/ .
49
49
9-((
4,+
/ pulses, the data pin will return the current
status of a corresponding key. Since there
4 : +
. 4, 4,:
+ :
4, 4,
/
4, - (,-
are eight keys in total, an unsigned char with
4,
-((
4,
4,
8-bit length will contain all the information for
;
49
49
-9
-((
; the controller keys.
20(
3 4,: 4,;
SOFTWARE DESIGN
85 49: 4,
/
89<= - - 4,
: +
9<9
:
4,+ 4,/
In order to operate the game on the
+-
) *+! ,
microcontroller, we needed to implement the
3
foreground and background components of
the game and run them at the same time. We
wrote with a library written in C that enables
manipulating screen buffer, rendering
objects and interfacing with the NTSC video
FIGURE 2 output. We packaged all the dependencies
This hardware schematic diagram shows the hardware hierarchy of our system. The synthesized sync pulse into a “game engine” so it can be reused for
and image signal are combined into one video output using a 2-bit DAC. The audio output is directly wired developing games.
to the CVref pin on the MCU. All the wires coming from the controller also get directly wired to GPIO pins
To support all the game components, we
on the MCU.
built a display library that has accessible
functions to draw and fill shapes on the
display buffer that is being synthesized into
analog video signal in real-time. Since we
define every pixel to be either black or white,
%6
we draw or erase pixels on the display by
was available, which we decided to follow in setting or clearing the corresponding bit.
the end. This approach was introduced $!% in
5
To draw lines in a pixelated screen, we
Cornell Professor Bruce Land’s NTSC video adapted the Bresenham
(' line algorithm that
generation on PIC32, which uses an Output takes in the two sets of coordinates and
Compare module instead of two DMA channels automatically figures out which pixels to fill
to generate the front '"('#
! "#$!%& porch of the signal [3]. between the starting and ending points [4].
We also added support of drawing quadratic
VOLTAGE REFERENCE bezier curves onto the display [5]. To do so,
The PIC32 MCU has an on-chip voltage we specified three anchor points on the screen
reference module that can be programmed to and used the parametric function to trace
output a reference voltage on an external pin. each point of the curve and fill the points. We
Although originally designed for providing developed functions to draw rectangles and
reference voltage for the comparator module, circles on the display buffer, following the
this module can be configured as a 4-bit DAC implementation of Adafruit’s TFT library.
and produce audio during gameplay. Since The game needed to have not only outline,
the VREF module is a 4-bit DAC, we had to but also more filled shapes. So, we also wrote
truncate and fit the original audio data into functions to fill rectangles and circles line-by-
16 voltage level bins. Also, since the MCU only line. When filling horizontal lines, we directly
has 128 kB flash, we have to resample the wrote 1’s the display buffer. However, when we
audio file into a much lower sample rate so actually kept erasing and filling a large rectangle
that the MCU could hold as many audio data frequently, we noticed significant blinking on
as possible while still being able to play the the shape. That’s because this filling technique
audio with acceptable quality. To rapidly is not fast enough when working with large
produce the header files for audio data, we shapes. We worked around the problem later
used Mathwork’s MATLAB’s resample function by avoiding repeatedly re-filling large shapes.
to convert original audio at a sample rate of In the end, we loaded the bitmap data for
44,100 down to 3,000 samples/s and then displaying characters on the screen.
wrote the data into a C header file that can be We decided to use an object-oriented
included into this project. approach for all the in-game components.
In order to take user input and be able to Because of this decision, we designed the
control the game, we adapted a Nintendo NES engine to enable the user to define all the game
Controller to interface with the player. The NES mechanics in the init and update functions
circuitcellar.com 9
FIGURE 3
Shown here is the detailed breakdown
of a NTSC line signal. Each new line
starts with a horizontal sync pulse that
pulls the pin low and then followed
by a back porch on the voltage level
of black image. Then the actual
FEATURES
video signal comes in, showing the
brightness of each pixel on the line in
a 53.6 µs window.
within all the components. Our game engine the video driver to load a corresponding
has only one entry point that interacts with bitmap data to the display. Sprite contains
the outside main function called the game two function pointers, and those point to the
manager. Every component of the game is init and update function of the itself. There
defined and encapsulated within the game are two ways of displaying objects onto the
manager object. Therefore, by initializing the screen, one being directly loading the bitmap
game manager and routinely calling the game data. The other way is to use the functions
manager update function, we will be able to in the display library to repeatedly erase and
initialize and update all the game components draw shapes and texts.
that belongs to the game manager. We used the three data structures
Since there are multiple components introduced earlier to handle different parts
running at the same time, we adapted of the game. For example, consider this
Protothreads, a lightweight library that very basic scenario: A user interface panel
supports multithreading on microcontrollers appears on the screen showing the current
to support several independent modules at time and there is also a ball on the side of
the same time [6]. One of the threads we the screen that will bounce up when a user
created is the main game thread where the taps the controller key. In that example, we
game manager is initialized and routinely define two sprites, one for the current time
called. The other thread is the I/O thread, text and another for the bouncing ball. The
which periodically pulses the clock pin to game manager then selects the current scene
the NES Controller and latches the most to be se scene we just created.
recent controller status. The controller At initialization, the scene will draw the UI
status is saved as a global variable and can panel on the screen buffer. While it is doing
be immediately accessed by components so, the text sprite—which is attached to the
in the game manager. In our configuration, scene—also gets initialized and keeps drawing
we sample the input from the controller for the current time (saved as a global variable)
100 times a second and update the main text string on the screen. Finally, the ball
game 30 times a second. sprite gets initialized at a given position. And
FIGURE 4
This Rope Jumper Game Components Scenes Sprites
Hierarchy Diagram shows the
available scenes under game manager Main menu
as well as all the sprites and system Buttons
components used by each scene.
Countdown Text System
Load page dependencies
FEATURES
(countdown)
Tooltip
Display
Rope library
The game
Character
Controller
Rope Human status
jumper:
game Game paused page
manager Audio
Buttons playback
Game over page
UI Box ISR Driven
clock
Game engine
demo page
since the ball is just a circle, we use the display DEMO GAME
library to repetitively draw/erase the circle on When we finished building all the libraries
the display inside the update function. It also and hardware components, we moved on
checks the current keypress status variable to create Rope Jumper, the demo game.
that is constantly updated by the controller The objective of Rope Jumper is to keep the
thread. If a keypress is detected, the ball will character jumping when the rope is swiveling
decrease its y coordinate—the user observes past the ground. The player controls the
it to move up. character’s jump by pressing A on the
controller. The character’s jump speed and
interval are limited, so the player cannot
blindly spam the controller to hover above the
ground. The speed of the rope will also change
when player enters a certain level. Also, the
center of the rope will move left or right
randomly when a certain level is achieved.
As shown in Figure 4, the Game Manager
contains multiple scenes in it. The first
scene is the main menu that the game loads
by default. Inside the main menu scene
there are three sprites, each representing a
corresponding button. The user can use the
arrow keys on the controller to switch from
different buttons. The second scene is a
countdown scene that elegantly counts three
seconds and switches to the game scene.
The third scene is the main game scene that
contains four sprites: rope, character, human
and a UI tooltip sprite. Finally, there is a pause
menu scene which renders a pause menu on
top of the current game and a credits scene
that displays the makers of the game.
As shown in Photo 2, when the main
PHOTO 2 game scene loads up, it first draws a large
This screenshot shows the actual gameplay of Rope Jumper. The two human figures are holding and swinging box around the display as a container of
a bezier-curved rope, allowing the character in the middle to jump. all the other visual elements of the game.
circuitcellar.com 11
Next, the scene loads all the attached sprites. On the two ends of the rope, there are
The rope sprite is a quadratic bezier curve two human sprites that draw the humans on
that contains three anchor points. To simulate the sides. The humans are pixel arrays that
the physics of the rope, we fixed the starting is generated from MATLAB by reading and
and ending point of the curve and vary the pixelating a hand sketched human figure.
middle point of the curve up and down. That The image array contains multiple frames so
FEATURES
makes it look like an elastic rope swinging. We that the human’s arm can move up and down
also used a sine table to map the y position of with the rope’s rotation. The update function
the middle point, so we can obtain a smooth of the sprite compares the current rope’s
and more realistic rope animation. In order rotation position with its frame number so
to compensate for gravity, we increased that if the rope rotates to a certain angle the
the falling speed of the rope by 1.5 times sprite changes its display frame to be the
compared to the rising speed by skipping corresponding frame number.
more samples in the sine table.
The character sprite can be found DRAWING HUMANS
in the center of Photo 1. It consists of a Our first approach to displaying motion
round rectangle and a text box on top of of the humans was to constantly remove
the rectangle. The sprite is drawn at init and redraw the figure when the rope moves.
and constantly erased and redrawn during However, since the size of the humans is
update. The sprite also checks the current fairly large, we saw very blinky images.
controller status and adds an upward thrust Therefore, in order to reduce visual artifact
to the object whenever a press on the key A as much as possible, we altered the code to
is detected. The thrust is treated as a vector only erase and redraw the middle portion of
force so that the character’s velocity and the figure that contains the human’s moving
position can be computed from it. Once the arm. Since the top and bottom part of the
character arises from ground, a new gravity figure does not move, they do not need to be
force (downward acceleration) will be applied updated at all. By doing so we were able to
to the character to make sure the character minimize visual artifact and optimize game
drops back to the ground. experience.
MADE IN CANADA
www.lcr-reader.com
12 CIRCUIT CELLAR • FEBRUARY 2018 #331
RESULTS
As shown in Photo 3, our complete system
build includes the game console running on
PHOTO 3 the PIC32 which has been installed in an
This shows the complete portable build of our system. A mobile battery pack provides the power for the MCU acrylic casing, a NES Controller that directly
and a portable speaker outputs audio generated by the console. Users can easily plug in the RCA cable to the plugs into the console, a mobile cellphone
analog video connector shown on the bottom right of the picture and start gaming right away. charger that powers up the console and a
speaker that outputs audio. When powered up,
our design is capable of rendering up to seven
scenes—each containing around 5 to 6 sprites
In the end, in order to further enhance with independent logic as well as playing a
experience, we wanted to display a floating looped soundtrack that is 10 seconds long.
text when the play levels up or encounters a We have used up around 90% of our 128 kB
new challenge. We decided to create a sprite programmable memory and every component
that displays a floating tooltip on top of the functions robustly.
character when defined events take place. Actual successful video generation under
Whenever there is a speed up, difficulty the NTSC standard is an essential foundation
change or the player loses lives, the tooltip for all the work we have done in the project.
sprite generates a text box over the character The video signal is stable enough so that on a
and the text box gently rises up and disappear normal sized monitor we can clearly identify
in three seconds. The generation, controlling all the components of the game. In the end,
and animation of the text is implemented as a we have extracted all the depending libraries
state machine so that whenever a new tooltip into a distributable game engine for quick
request comes in, it resets the floating text’s game development on PIC32. A demo video
position, displays the new text and gradually of this project along and a link to our project
shifts the position of the text upwards website can be found on the Circuit Cellar
article materials webpage.
We would like to acknowledge Yuqing Sun,
Additional materials from the author are available at: another member of our group, for participating
www.circuitcellar.com/article-materials in the overall scheme proposal and
contributing to game engine and global
References [1] through [6] as marked in the article can be found there. messaging implementation.
RESOURCES
Adafruit | www.adafruit.com
Mathworks | www.mathworks.com
Microchip | www.microchip.com
When it
comes to
robotics,
the future
is now!
From home control systems to
animatronic toys to unmanned
rovers, it’s an exciting time to
be a roboticist. Advanced Control Robotics
simplifies the theory and best practices of
advanced robot technologies, making
it ideal reading for beginners and experts
alike. You’ll gain superior knowledge of
embedded design theory by way of
handy code samples, essential schematics,
and valuable design tips.
Wearable technologies, virtual reality and sensor fusion make for a powerful
combination when all are used together. These Cornell graduates designed
a low-cost arm controller that translates arm motions into interactions with
virtual objects using sensor fusion technology.
By
Emma Wang, Daryl Sew and Zachary Zimmerman
FEATURES
the odometry quality up to par with higher accelerometer is its onboard temperature
cost, higher fidelity sensors. sensor and digital signal processor (DSP) that
The accelerometer and gyroscope give data applies temperature compensation as well as
that can be used to compute arm trajectory. some basic filtering techniques.
There are several methods to process the
sensor data, and these methods vary in terms DEVELOPING THE POSE PROCESS
of simplicity and accuracy. One method is to Our process from raw data collection to
rely on accelerometer data exclusively. In this body tracking display can be summarized in
case, you would use tri-axis accelerometers three steps: 1) Collect angle velocities at a
to measure the acceleration in x-, y- and moment in time: 2) Apply the complementary
z-axes at a particular point on the arm. Using filter to the velocities collected and store the
standard relations of acceleration, velocity inferred orientation; and 3) Input orientations
and position, we know that this acceleration in the form of quaternions to the virtual reality
can be integrated to produce a velocity, and application and use forward kinematics to
that integrated velocity will produce position. draw the arm.
Using this method will most certainly We used the Kionix tri-axis gyroscopes-
result in unwanted drift. The solution to accelerometer unit, the KXG03, to measure the
minimizing the accelerometer drift is to (1) angular velocities and accelerations in x-, y-
calibrate, and to (2) weight the gyroscopic and z-axes at a particular point on an arm. We
and accelerometer data. To do this we then integrate these complementary filtered
implemented the complementary filter. The angular velocities and accelerations from the
complementary filter is essentially a weighted gyroscope to produce the orientation.
average of the gyroscopic and accelerometer Next, we represent the weighted angle
data. Figure 1 demonstrates the functionality velocities with quaternions to avoid the
of the complementary filter with sample data. singularities of an Euler angle orientation
Accelerometers sense acceleration representation. Similar to Euler angle
via “differential capacitance arising from orientation, quaternions indicate the
acceleration induced motion of the sense difference in rotation between each position
1.5
Complementary filter
Gyroscope data
1
Accelerometer data
0.5
Angle 0
−0.5
FIGURE 1
Shown here is a demonstration of a
complementary filter. Gyroscope data
−1 dominates at fast moving rates and
accelerometer data dominates at slow
moving rates. In other words, outliers
in the acceleration orientations will be
−1.5 ignored when the joint is fast-moving,
0 5 10 15 20 25 30 and the gyroscope’s orientation drifts
will be ignored when the joint is slow-
Time moving and the acceleration derived
orientations are high fidelity.
16
FEATURES CIRCUIT CELLAR • FEBRUARY 2018 #331
PHOTO 1
Running controller.py results in real time arm angles being reflected in virtual reality. The user is free to move arm across and around body to interact with the virtual balls.
of the arm in 3D space. Passing quaternions its unique address. However, we discovered
to the virtual reality application allows smooth that the sensor unit designs only allowed
interpolation of data. In the field of robotic I 2C user addressing of one bit—resulting in
manipulation, forward kinematics refers to only two unique I 2C address per sensor unit.
the use of a model as a sequence of links That means we could hook up at most two
(translations) and joints (rotations) to produce gyroscope-accelerometer units on the one
the position of the end effector (given joint I 2C channel. Our first workaround was to
angles). In that way we are able to predict retrieve data from the third set of sensor
end effector position given only orientation units from the second I 2C channel on the
measurements. PIC3232MX250f128b. Due to problems
indicated in PIC32MX250f128b errata,
HARDWARE/SOFTWARE transmission from both I 2C channels stalled.
TRADEOFFS Instead of spending more time debugging
In order to read data as quickly as this issue, we moved on to an alternative
possible from the PIC3232MX250f128b and solution. This involved issuing read/write
IMU connections, we moved as much of the instructions to the same address for
computation as possible off the microcontroller gyroscope-accelerometer and toggling the
to a full powered computer. We accomplished ADDR line of each respective sensor unit.
this by sending the sensor register data to a Essentially, we implemented a Chip-Select
PC via serial communication. Doing this also function on one I 2C channel. We found that
enabled us to use a powerful, but CPU/GPU- there were no timing issues with toggling the
intensive 3D graphics engine—one with more ADDR line across each sensor unit. As a result,
compute performance than is available on the successful communication was established
PIC3232MX250f128b. amongst the three sensor units.
By using the I 2C bus, we were initially Aside from the addressing issue, we found
under the impression that we’d be able to the Kionix device versatile and relatively
open one channel and connect all gyroscope- hassle-free to use. In an ideal world, it
accelerometer sensor units to it—with each at would be best to source or work with the
circuitcellar.com 17
FEATURES
One we wrote in C code—to compile and load reality application and displays the user’s
onto the PIC32. It was responsible for reading arm movements in real-time (Photo 1). We
sensor data over I2C and sending it to a enabled concurrent execution of the game
computer over serial. The other chunk we wrote and reading from serial in a while True loop.
in Python. It resides on the computer and is Thanks to the global interpreter lock, the
responsible for parsing incoming data on the only way to be truly concurrent in Python
serial port, filtering/fusing it, integrating it and is to use process concurrency through
rendering it via the game library Panda3D. inter-process communication. As such, we
Starting with the C files, we used implemented a shared queue that the read_
Protothreads to schedule and connect to sensors.py process uses to communicate
a PC to communicate over serial. We found odometry data over to the process rendering
that adapting the i2c_helper.h file from a the game.
previous project for its i2c_read and i2c_ read_sensors.py: In this file, we use
write wrapper functions to be immensely pyserial to read incoming data on the
helpful [2]. The wrapper functions abstracted serial port and parse it into custom classes
away the I 2C methods of reading and for accelerometer data and gyroscope data.
writing to a register on a sensor. It’s best We implemented a calibration period of
to write these functions based on the sensor three seconds over which we asked the user
datasheets and PLIB manual for the sensors to extend his/her arm horizontally outward
and microcontroller unit of your choice. For with all three IMUs facing upwards. We
increased ease of use, it’s best to implement required that the devices be at rest during
functions for each of the three sensor units, this time. The first 120 sensor readings we
and for each accelerometer and gyroscope at collected during calibration were averaged
these locations. Read and write I 2C wrapper and used for initial values after which we
functions can be used for both initializing the integrated for relative changes in position
sensors as well as reading data from them. and orientation. The calibration offsets
We have a total of two threads. One depend on the location and temperature.
thread starts out by writing configuration In the read loop, we integrate the data
and wakeup values to the sensors and then and update an odometry dictionary, which
repeatedly reads from the sensors and sends keeps track of the position and velocity of
their data over serial in the second. Since only each sensor. If run as main, this file prints out
one thread is scheduled throughout this whole the sensor values it is reading. We also apply
process, the program reads and sends sensor the complementary filter to the orientation,
values at maximum configuration speed, where the angular velocity is replaced by
provided that the baud rate is set proper. 0.97 x angular_velocity + 0.03 x acceleration.
The protocol we designed for sending data
over serial uses spaces to delimit registers
from the same sensor, newlines to delimit ABOUT THE AUTHORS
different sensors and the word “init” followed
Emma Wang (exw2@cornell.edu) graduated from Cornell in 2017 with a B.S.
by a newline to delimit sensor readings at
Electrical Engineering, and Operations Research and Industrial Engineering.
different timesteps. This protocol enables
the corresponding Python script to connect She currently works at Johnson Controls as an Electrical Engineer within the
to the device at any time as the script can Special Hazards team. Her interests are in circuit design,and she has a pen-
use inits to separate out sensor readings by chant for developing wearables and spending time in her community.
timestamp.
The following is an example data chunk Zachary Zimmerman (zacharytzimmerman@gmail.com) graduated from the
from one timestep containing the angular Cornell in 2017 with a B.S. in Computer Science. He currently works at Micro-
velocity and acceleration readings from
soft doing rapid prototyping for new technologies. His interests include design
the gyroscope-accelerometer unit. You can
and ergonomics, computer graphics programming and game development.
compare results but note the variations due
to sensor fabrication and other settings:
Daryl Sew (darylsew@gmail.com) graduated from the Cornell College of En-
init gineering in December 2016 with a B.S. in Computer Science. He currently
6 34 8 -899 -14546 -9824 works at Snapchat on computer vision and augmented reality. He’s passionate
32511 40 28009 9119 -867 11209 about game design and robotics.
36 -259 -261 -3954 -2928 14885
18 CIRCUIT CELLAR • FEBRUARY 2018 #331
HARDWARE DESIGN
The PIC32MX250f128b serves as the
intermediary link between the sensor units
and the PC. It drives the I2C1 lines and the
FIGURE 2
IMU Sensors are placed along the right arm. Each joint, shoulder, elbow and wrist receive an IMU. Gyroscope
serial communications. Pins 17 and 18 are
and accelerometer data from each location is fused to generate and track arm position. reserved for the I 2C channel—pin 21 is UART
transmission and pin 22 is UART receiving.
a) b)
'/
"
6 73 8/
38, 8/))
2 1.."
38 3-
.
3-, 3-.
.
3- 3-
2
3- / )-/ '2/
3
., 3- 3- 83:3+
3. " '/
., /)) 3-, 83::+
3 ,
., 38 /8 3
, 3
83 ( 38 /))
" )8
839 3-. 3- ,'0
)7
839 38. 3-" 3
2
/ 3-
.
3- 3-2
3" 3 32
, , ,
* + ,!"-
. . .
. 2 . 2 . 2
83 ( 839 839
" " "
)7 )7 )7
/ , / , / ,
'2/ )8 '2/ )8 '2/ )8
*;/ *;/ *;/
'2/ '2/ '2/
. . .
2 2 2
)(
circuitcellar.com 19
In order to safely power the KXG03 sensors, filter produced orientation measurements
we had to construct proper voltages. Drawing that were impressively precise. With a
from the 3.3 V of the PIC32, we dropped PIC32MX250f128b baud rate of 115,200, we
down the voltage by using the diode to bias were able to read from all three sensors at
to approximately a 0.7 V drop. Ground the approximately 41 Hz. Enabling high speed
signal of this divider through a 1 kΩ resistor, I 2C mode compatibility on the devices and
FEATURES
using 10 µF and 0.1 µF capacitors to eliminate microcontroller could possibly result in higher
transients. You can also directly source from quality odometry. That’s because a higher
a power supply set to 2.6 V. quantity of sensor data would enable us to
The toggling address Chip Select lines improve our fusion algorithms.
also need to be alternating at 2.6 V and 0 V. Using a complementary filter substantially
The proper voltage must be constructed in increased the overall usability of our
this case because of the toggle instruction application. We went from having arm drift
originating from the PIC32. A voltage divider from the beginning (0 seconds) to being able
with the properly ratio of resistors is used to to run for up to two minutes before having
create the voltage for each sensor unit. This to reset to eliminate drift. If you have good
needs to be down with each address toggle ground truth measurements for arm motion
line. In this case, that means providing three then you would be able to provide a more
unique voltage dividers for each of the three quantitative analysis of your accuracy. In
sensor units. testing, we found that movement passing
The sensor units used are three of the through the initial calibration position
KXG03 gyroscope-accelerometer units. They periodically at about 1-minute intervals also
are also referred to as IMUs. The IMUs are helped the drift to correct itself.
placed along strategic mapping points along For code and details, go the Circuit Cellar
the limb—in this case an arm—at the shoulder, article materials page. You can view our
elbow and wrist (Figure 2). Essentially, each results and there are two demo videos
joint receives an IMU. where we demonstrate the use of our system
Each of our IMUs receive VDD, IO_VDD and give brief explanations of its inner
(same value as VDD), GND, I 2C channel, workings.
1 CLK and data lines, and a line that toggles
the last bit of I 2C address to 1 or 0. Using
the PIC32MX250f128b, we assigned 3 pins to
toggle the ADDR line of the shoulder unit, the
elbow unit, and the wrist unit. We used open
pins 4,5 and 6. See Figure 3 for a detailed
overall schematic.
RESULTS
We are pleased with the result of
the project. The device enables users to
manipulate objects in a virtual world when
moving their arm around. We are happy that
the complementary filter proved effective
in eliminating orientation drift. As demos
show, implementing the complementary
EVE2
Additional materials from the author are
available at:
www.circuitcellar.com/article-materials These Capacitive & Resistive
TFT Modules
Touch HMI displays feature:
4 sizes
References [1] and [2] as marked in the
article can be found there.
Power Re-Envisioned 3.5”, 4.3”, 5.0” and 7.0”
3
media types
RESOURCES High-res graphics, video and audio
Find a discount code and learn more
Kionix | www.kionix.com about these cutting-edge products:
NHdisplay.com/EVE2cc1
2 connectors
Standard 20-pin FFC and IDC
1 powerful chip
Microchip | www.microchip.com
EVE2 graphic engine by FTDI/Bridgetek
NumPy | www.numpy.org
Panda3D | www.panda3d.org
20 CIRCUIT CELLAR • FEBRUARY 2018 #331
In this next installment of his four-part article series about building a home
cleaning robot, Nishant discusses the circuitry behind the system. This involves
the selection of the electronic components and optimizing the system for overall
power consumption.
By
Nishant Mittal
Cypress Semiconductor
Motor2 Motor1
IR Sensors
Six sensors
I n the previous two parts (Circuit Cellar
329, December 2017 and Circuit Cellar
330, January 2018) of this home cleaning
robot article series, I setup the base of
the system and its mechanicals and put the
components together. In this and in next
Motor Driver month’s part, I’ll delve into the electronics
12 V and algorithms needed to make the automatic
home cleaner work.
Gnd 12 V 12 V 5V
Regulator Figure 1 shows the block diagram of the
Header for fitting electrical system. Because this is a mobile
CY8CKIT-042 BLE
5V Module system, a battery will be used instead of
Regulator
bench-top power supply. Because of the size
constraints of this system, we’re using a 9 V
12 V battery. Two voltage regulators are needed:
Motor Driver
one boost regulator for 9 V to 12 V, and one
buck regulator for 9 V to 5 V conversion. These
voltages are mostly required to drive the
Motor3 Motor4
motor and sensors. All the data processing and
data transfer happens through the controller
FIGURE 1 module from Cypress Semiconductor: the
Block diagram of the electrical system CY8CKIT-042 BLE.
circuitcellar.com 21
FEATURES
PSoC 4200 BLE which is capable to handling
all kinds of digital and analog processing
within a single SoC. This SoC not only does
data processing, but also embeds Bluetooth
functionality—resulting in an extremely low
cost and compact solution.
The next important component choice
is the battery. When choosing a battery, we
had to consider current rating (in mA-hours)
PHOTO 1
and the required voltage. Higher the voltage
Cypress CY8CKIT-042 BLE module
rating, the bigger the battery needed. We
needed a battery with long life and a decent
voltage and current rating. The battery also
had to be rechargeable, low cost and long
lasting. With all that in mind, we chose the
HPB Power battery with 2,200 mA-hours and
9 V at 2 A. Photo 2 shows the battery—a
lithium polymer cell.
The next design element to be selected is the
sensor. Here, we chose an IR sensor although
an ultrasonic sensor was an option. Both have
their own advantages and disadvantages.
PHOTO 2
Instead of designing our own modules, we
Lithium polymer battery for the home cleaning robot
bought the module shown in Photo 3. In
this module, we can tune the distance. The
module contains the circuitry that modulates
the signal received and converts into digital
data. That data is then fed to the input of the
microcontroller. Using the potentiometer, the
modulation can be tuned to mark the distance
of object detection.
CIRCUIT DESIGN
We’ll begin the discussion of the circuit
with the power supply design. As mentioned
earlier, we have a 9 V, 2 A input. That is split PHOTO 3
into 12 V and 5 V as shown in Figure 1. To do IR sensor module
that, we needed to design a buck regulator
and a boost regulator. The boost regulator is
-
3) 3
needed for 9 V to 12 V conversion. For that %)* *
we chose a Texas Instruments (TI) LM2585 -012
(+
chip. The LM2585 is a fly back boost regulator
with has a switching frequency of 100 kHz ,
and a wide input voltage range of 4 V to 40 V. +
3. ( )!)
. %*
R123
Vout = Vref × 1 + where Vref = 1.23 V
R125
.,)+-
)
+%,)+-
,6 4
86/
</
using an LDO as a power source. We needed
,./
;/
))
#7
0 12 !3415/6 7
! 2 * a buck regulator with a 9 V to 5 V output. The
FEATURES
FIGURE 3
RFBT
Power module (buck converter) Vout = 0.8V × 1 +
RFBB
*+, *+,
This resistor should be between 1 kΩ to
0
/
6.
*))
50 kΩ. Figure 3 shows the circuit diagram of
+ +
+ 4 &4
+ +
+ +
+
" +.+ the power module for 9 V to 5 V converter
5 &5
7. 7.
&
,
1
used in this design.
*
7.
7.
7.
7.
1 *+, , Figure 4 shows the motor driver circuitry.
0
&
7. 7.
+.+ " +.+ + + Here, we’ve used the L293D from TI, which
5 5
+. 4 4
+.
can &:
+.+
be used to drive two motors using a single
*) 6.
/ IC. That means a total of those of these ICs
are required. The IC needs two power9 sources
*+,
-
*+,
#&!
at 12 V and 5 V—5 V at Vss and 12 V at Vs. This
0
is to drive the motor directly using 12 V while
)(
/
6. *))
+ + the IC voltage is at 5 V.
+
+ +
4 &4
" &+ +
&+
+.+ Figure 5 shows the I/O header for
5 &5
!!"#$%
&
,
7. 7.
1
#&!'($)(% inserting into the CY8CKIT-042 BLE module.
* 1
7.
7.
7.
7.
, *+, We’d needed as many as 8 pins for the motor
01
and 6 pins for the sensors—however other
&
7. 7.
+.+ " &+.+ &+ +
5 5
+.
4 4
&+.
&+.+
pins are brought out as GPIOs. Figure 6
*) 6.
/ shows the connector used to insert the sensor
- shown in Photo 3. These sensors are readily
available on any electronics hobbyist website.
FIGURE 4 These sensors are easy to use direct digital
L293D motor driver output sensors which can be connected to the
PSoC. The enable pin for these sensors are set
by default to ground because they are active
). low. However, these can also be connected to
)
/ the GPIO pins and can be driven according to
/ +*
+
+*-
application needs.
*3 % 3
* *-
* + 5-
*%
*
%
3 6,4(
2*
*
*
+*2
2
%*
*-
*- PCB DESIGN
*+ 2 2*3 +* + %*2 Because our board contains switching
%3
* * ), *3 % 3 *
),4! + *2 *+ *% regulators, designing the PCB appropriately is
2*+ % 3 2*% * 2 *
very important. Very fast switching current
2*
2*2
2
2*
2*
*2
+
*
!%
around&
2
long tracks and inductance generates
$ .$
voltage transients which
)( can cause problems.
For minimum ground loops and inductance,
track lengths need to be as short as possible.
! "# $ !% &' (#)( $ Single point grounding or a ground-plane
FIGURE 5 based approach is recommended for best
CY8CKIT-042 BLE header for module placement results. Power grounds and signal grounds can
circuitcellar.com 23
FEATURES
)* )* )* )*
/0" /0 /-) /-
34 )* 34 )* 34 )* 34 )*
FIGURE 6
Sensor connector
%2
!% 1
('
PHOTO 4
(a) bottom track of board. (b) top track of board
VIN
LMZ14203H VO
VOUT
VIN
High
di ⁄ dt
CIN1 CO1
GND
Loop 1 Loop 2
FIGURE 7
Feedback routing of the power module on board
24 CIRCUIT CELLAR • FEBRUARY 2018 #331
RESOURCES
Can cutting edge IoT functionality be delivered at lower costs than today’s
expensive home automation solutions? These Cornell students set out to
prove that they can with their programmable mesh network project based on
Microchip’s PIC microcontroller.
By
Raghava Kumar, Brian Clark and Alex Wong
FIGURE 1
We divided our project into
independent layers that interacted
using clean APIs. These layers are
based on telecommunications layers
defined in the OSI model, and helped
us manage complexity effectively.
FEATURES
devices, monitor the status of sensors and servos, LEDs and so on. Every node is capable
set logical relations to automate tasks in their of generating events that can affect other
home with a few keystrokes. For instance, our nodes, and maintains logical tables that
system may be used to: determine which events can modify its output.
The user can configure these settings using
● Remotely control the intensity of any the master node, and therefore set arbitrary
connected light in the house relationships between the inputs and outputs
● Check the temperature of every room their of other nodes.
house from the comfort of their bed All functions of the application layer
● Automatically turn the lights on when it is are supported through a custom, byte-
too dark in the kitchen encoded message protocol. We designed
● Configure what it means for it to be “too these messages to be short (so they can be
dark” transmitted reliably on the radio modules),
● Turn the lights off if no motion is detected easy to parse (to minimize microcontroller
in a room loading) and expose as little of the underlying
● Set off a buzzer whenever the fridge door software implementation as possible. Our
is left open system consists of the network messages
shown in Table 1. Messages that can only
Our code is designed to be as flexible as originate from the master node are marked
possible, enabling the system to interface with an asterisk.
with a variety of analog sensors, motors, The application layer supports user
Message Semantics
Force* Force a node’s output high or low
Query* Check the value of a node’s input, or any of its configurable parameters
Query Response Reply to the master with a requested value
Event Inform subscribers that the node’s input has just been turned high or low
Config* Configure a node parameter (see Table 2)
Add Event* Add a dependency to a node’s output
Add Subscriber* Add a subscriber to the node’s events
Remove Events* Remove all dependencies for a node’s on or off state
Remove Subscriber* Remove an event subscriber from this node’s subscriber list
TABLE 1
Application layer functionality is implemented through a set of custom messages that allow nodes to generate and subscribe to events. The messages marked with an asterisk can
only be sent by the master node for node configuration.
28 CIRCUIT CELLAR • FEBRUARY 2018 #331
FIGURE 2
The user can configure the network
through a simple command-line
interface. They can query the status
of a node, force it on/off or build
links between different nodes in the
network.
FEATURES
interaction through the master node, node path communication is essential for
which can be plugged into the USB port of our project in order to provide an adaptive
a computer. Communication is facilitated distributive network. This protects against
using a CP2102 UART-to-USB converter, and possible attenuation between two nodes
is used to provide a command line interface by allowing communication through other
to the user. User commands are parsed by nodes. Dynamic route discovery allows for
the master node, and essentially translate each node to actively determine the shortest
to one or more network messages. A sample route to another node. Finally, dynamic
screenshot of this interface is shown in route reconfiguration enables our network
Figure 2. to maintain efficient communication by
The functions of the application layer constantly updating routes.
are supported by the mesh layer, which is Each node is loaded with almost identical
responsible for path discovery and message mesh network software, with the only
forwarding. The interface between these two difference being individual software-defined
layers is implemented using a mesh level send node IDs. These are defined in a header file at
function that routes messages within the program time and can be changed to include
network, and a receive callback function that more nodes into the network. As shown in
alerts the application layer when a message Table 2, only 1 byte is allocated for each field
addressed to this node is received. To use in our message sending structs, with one of
the mesh-level send function, the application them being the node ID. Because of this, there
layer simply inputs a message and destination is currently a limit of 256 nodes in the network
node and lets the mesh layer handle the rest. for this particular iteration of the project. In
the future, it would be very simple to modify
MESH LAYER the struct to have more bits and thus enable
The mesh layer of our project is more nodes in the network.
designed to provide a robust, reconfigurable A cache is used to house path information
networking protocol for the multiple PIC32 for each node which, upon startup, is initially
nodes. The protocol borrows heavily from empty. Each cache is implemented via an array
the well-established AODV algorithm with and pointers to the destination node, the next
several design changes to simplify the node to hop to (for multi-node hops) and the
software and improve reliability. The main total number of hops. When the send function
features of the network are: multi-node path is called by the application layer, the mesh
communication, dynamic route discovery layer will receive information on the source
and dynamic route reconfiguration. Multi- node, destination node, message and message
circuitcellar.com 29
FEATURES
size. The cache will be searched for a cache the destination through itself. It either has a TABLE 2
entry that contains a path to the destination. path in its cache or is in fact the destination This table shows the byte-level
encoding of the various message
If one is found, the cache hits and the mesh node. Because of this, all nodes that have
headers used in the mesh networking
layer can send immediately by transmitting a propagated forward the RREQ will also be
protocol.
packet with the data—along with a prepended able to fill in its cache information about the
7-byte header for information—to the next path. Eventually the source node will receive
hop node. Otherwise—if there is a cache the RREP message and fill in its own cache
miss—it will begin the cache miss process. before sending actual data packets through
We’ll detail that miss process more later. the found path to the destination.
Assuming a cache hit, the next hop node In order to properly forward the RREP
will decode the packet and see whether it is a message to the original requester of the path,
data packet to forward or to receive. This node the path that was taken by the RREQ message
will also have a cache entry to the destination, must be reversed. This is done by storing
so when the send function is called again, the propagator of the RREQ flood message
it will always respond with a cache hit and in every node in the path. If a node receives
send. This is shown in Figure 3 which shows a RREP, it’s because it was either one of the
a cache hit for a multi-node message send. nodes along a constructed path, and should
In this case, the source node, Node 50, will forward the RREP to the node that sent it
have the destination node in its cache with the corresponding RREQ, or the source. This
the next hop address field being Node 20. means after a RREQ has been propagated to
Node 20 receives this message and because the destination node, the RREP will exactly
of the way we propagate RREP messages, retrace the path of the RREQ. This is shown
will also have a cache hit. The data message in Figure 5, which shows how the RREQ and
is therefore sent forward to the destination RREP routines work. In this case, we have
node, Node 10. If there is a cache miss, then a network with 3 nodes with Node 50 and
there is currently no path from the current Node 10 far apart and Node 20 acting as an
node to the destination. As a result, the route intermediary node.
request routine must be started. In this specific case, the nodes are in
startup with empty caches. We have Node
ROUTE DISCOVERY 50 attempting to send to Node 10 so it
In addition to having multi-node sending, floods the network with a RREQ message.
it is also important to be able to discover Node 20 receives this and realizes that it
new routes from source nodes to destination
nodes. By having a dynamic routing algorithm,
the network is able to easily acclimate to Message legend:
losing connection with individual nodes. Upon Packet type | Source ID | Destination ID | Next hop ID
initialization of the network, the first possible
event that can happen is the master node
sending out any command. The master node
attempts to send to another node which it has 0 |50 |10 |20 0 |50 |10 |10
not established route information for, since
no paths are known. In this case, there will
be a cache miss which will begin the dynamic
route discovery routine.
Node Node Node
The dynamic route discovery routine 20 10
50
works by first sending a Route Request (RREQ)
message via a network flood. The RREQ
message acts as a broadcast to all nodes
saying that the source node does not have a FIGURE 3
path to the destination node. Any node which This graph shows how the message headers used in the mesh network change in order to allow multi-node
receives the RREQ has two options: forward hopping. Here we are only viewing sent message packets. In this case the first number represents the type
the RREQ message by flooding its own RREQ of the message (a data message, for example), the second number represents the source node ID, the third
message or return a Route Reply (RREP) is the destination node ID and the last is the next hop node ID. In this example, the packet types are only
message, signifying that it knows a path to data messages which has an ID of 0. The rest are self-explanatory.
30 CIRCUIT CELLAR • FEBRUARY 2018 #331
FEATURES
possible for various configurations. With the
minimal hardware on board, the PIC32, TFT Node
and radio drew 100 mA of current in steady 20
state—enough for about 20 hours of battery
1|50 |10 |
life. However, if further optimizations were
made to the radio, and if we tapped into low- Node 2|50 |10 |50
power modes for the PIC32, or removed the 50
TFT, longer battery life could easily be achieved.
Each node except for the master contains
an optional TFT display so that the actual Node
10
packets going through the networked can
be visualized. This is useful for debugging
1|50 |10 |
purposes as well as ensuring correct
operation of various attachments put onto the
nodes. The master node, instead of having a FIGURE 6
TFT display, simply puts its outputs onto the This illustrates a route discovery routine where the source floods the network with a RREQ message and the
serial terminal that is used to interface with destination receives it and sends back a RREP message while another intermediary node receives the RREQ
it. This enables a user to communicate with flood and attempts a flood of its own which the destination ignores. (1 = RREQ, 2 = RREP)
all general nodes through a single master
Message legend:
Packet type | Source ID | Destination ID | Next hop ID
1|50 |10
1|50 |10
Node Node 1|50 |10
FIGURE 7 50 70
This diagram illustrates the scalability of the mesh network
due to the simple software filtering of flood messages built
into the mesh layer’s receive callback. (1 = RREQ, 2 = RREP)
1|50 |10
32 CIRCUIT CELLAR • FEBRUARY 2018 #331
FIGURE 8
'/
Component-level circuit schematic
diagram for each general node '/
3
.'
)6
!
01 9 03 4/
)$ 01 34 4/))
. 7
FEATURES
node that can be universally plugged into Once all three layers passed their unit
any computer with a USB port (Photo 1).tests, we put them together and began
The master node is also equipped with arigorous integration testing. First, we tested
simple one-to-one communication with
PIC32 and nRF24L01 so that it supports the
all three layers active. Once this worked,
same network interface as the general nodes.
we attempted communication with
two
&8
TESTING AND VERIFICATION nodes in range of the master node. It was
Consistent with the high-level abstraction $%
here that we first started to drop &
packets!
that we detailed earlier, we chose to among nodes. This didn’t happen earlier
independently develop our three layers prior because nRF radios have a built-in auto-
to integration. This meant unit testing of each acknowledgement packet that is sent out on
layer was handled by the respective developer. successful reception. With multiple nodes in
!" #$% & !' (")( #
range however, the master node would never
● For the application layer, this involved know whether every node in range correctly
simulating data packets, observing node received the packet.
behavior, and ensuring user input was We bypassed this issue by disabling
serialized correctly. auto-acknowledgement on the radios and
● For the mesh network, unit testing mainly manually retransmitting a fixed number of
comprised of testing possible data paths times. This seemed to alleviate the problem
for sending and receiving, such as cache hit for a small number of radios, at the risk of
hop and cache miss hop. increasing the possibility of packet collision
● For radio layer, testing consisted of ensuring for a large number of nodes.
packet reliability and functionality across The next step was to test long range
different distances and number of nodes. message hopping. To do this, we placed one
radio outside the range of the master node
and another one in between the two. This
Additional materials from the author are available at: was difficult in practice, because there’s a
www.circuitcellar.com/article-materials grey area in which nodes would still be in
range, but with a very low success rate. All
Reference [1] as marked in the article can be found there. that said, we were able to make the master
node to communicate with nodes out of
RESOURCES direct range—demonstrating one of the
key functionalities of our mesh network.
Microchip | www.microchip.com
We were also able to verify path discovery
Nordic Semiconductor | www.nordicsemi.com in larger multi-node networks. In these
circuitcellar.com 33
FIGURE 9
Packet success rate vs. Distance
Shown here is a racket reliability
100 chart. Straight: No obstacles between
the destination and master node.
90
Bend: 90º angles about every 45 feet
80 at which one hop node was placed.
FEATURES
70
60 Two nodes
Success Three nodes straight
rate 50 Three node bend
(%)
Four node bend
40
30
20
10
0
0 20 40 60 80 100 120 140 160 180
Distance between master and destination node (ft.)
networks, we observed high traffic in the among other factors, but were unable to
form of RREQ floods and RREP messages increase packet reliability beyond a certain
during route discovery stage, and had to add threshold. For future iterations, we believe
software packet filtering to ensure stable it would help to either experiment with
performance. different radio modules, use independent
radios for transmission and reception on
RESULTS each node, or find a more robust library.
After completing our project, we
conducted range tests and observed FUTURE DEVELOPMENT
performance to collect the results shown in We were able to achieve many of the
Figure 9. The application and mesh layers goals of our final project. While radios turned
performed consistently well through our out to be more fickle and mesh algorithms
experiments. We tested different commands far more difficult than expected, we were
and messages with up to four nodes able to demonstrate automation functionality
communicating and dynamically discovering on a mesh, as desired. Future work on this
paths in the network. We were able to verify project could involve testing with superior
multi-node paths by constructing several hardware, optimizing the mesh algorithm to
test cases with nodes out of direct range. increase reliability and adding more
This worked well for a small number of application layer functionality to make this
nodes, despite occasional packet drops and project into a full-fledged, highly
collisions. One limitation here was that four customizable automation system.
is a relatively small number for realistic
applications. Ideally, we would have liked to
test latency and throughput under higher
stress conditions.
ABOUT THE AUTHORS
The radio and hardware layers were able
to achieve a reasonable tradeoff between Raghava Kumar (rk534@cornell.edu) is a senior in Electrical and Computer
cost, performance and power-consumption. Engineering at Cornell University. He loves working with microcontrollers,
Our prototype nodes cost $20 each and FPGAs, and embedded computers.
would last 20 hours of continuous usage.
If we optimized for production, we believe
Alex Wong (aw528@cornell.edu) is a senior double majoring in Electrical and
cost could easily be halved, and battery life
Computer Engineering and Computer Science at Cornell University. He enjoys
could be increased significantly with some
all things Computer Architecture, ASIC/FPGA Design, and Space.
software support.
All that being said, hardware was the
limiting factor our in-network reliability. Brian Clark (bac239@cornell.edu) is a senior at Cornell University currently
A lot of effort was put into debugging the double majoring in Electrical and Computer Engineering and Computer sci-
seemingly inherent unreliability of the nRF in ence. You can find him spending his free time on applying microcontrollers
multi-node situations. We experimented with to practical applications and writing code for various application.
different channels, pipes and transmit rates
34 CIRCUIT CELLAR • FEBRUARY 2018 #331
It may not happen overnight, but the shift from driver assisted
vehicle controls to full autonomous driving is underway. To meet
demands, MCU and analog IC vendors are crafting new chip and
development tool solutions.
SPECIAL FEATURE
W
By Jeff Child, ithin the next couple years, we’ll blink our eyes and driverless
Editor-in-Chief cars will suddenly be a mainstream phenomenon. Building toward
that goal, chip vendors are evolving their driver assistance
technologies into complete driver replacement solutions. These
solutions make use of powerful system-on-chip (SoC) and microcontroller devices
to analyze a car’s surroundings, process the information and employ control
functionality to steer cars safely.
Building on their long histories of serving the automotive market, the leading
microcontroller vendors have taken the lead, facilitating driverless car systems
with not just chips, but also very elaborate development platform solutions. And
over the last 12 months, that trend has accelerated as MCU suppliers evolve their
driver assistance technologies in parallel with their autonomous vehicle solutions.
LEVEL 3 AUTONOMY
Exemplifying these trends, Infineon Technologies supplies key components for
the Audi A8, the first series production car featuring level 3 automated driving
(Photo 1). Level 3 automated driving is where drivers can temporarily take their
hands off the steering wheel under certain conditions. The Audi A8, for example,
allows this when parking and exiting, in slow-moving traffic or in traffic congestion.
PHOTO 1
The Audi A8 is the first series production car featuring level 3
automated driving. Level 3 is where drivers can temporarily take
their hands off the steering wheel under certain conditions.
circuitcellar.com 35
Table 1 shows how the ability of cars to self- Autonomous Driving Levels
drive is split into a number of different levels. There are no automated driving features. The driver is
Various chips from Infineon enable responsible for longitudinal guidance (maintaining speed,
automated driving in the Audi A8. These Level 0
accelerating, braking) and lateral guidance (steering). There
include sensors, microcontrollers and power are no intervention systems, simply warning systems.
semiconductors. Radar sensor chips from the
A system can either take over longitudinal or lateral guidance
Infineon’s RASIC family are installed in the
Level 1 of the vehicle, while the driver permanently executes the
front and corner radar. They send and receive
other activity respectively.
high-frequency 77-GHz signals and forward
these on to the central driver assistance The driver can hand over longitudinal and lateral guidance to
controller (zFAS). A microcontroller from Level 2 the system in a specific application. The driver must always
Infineon’s AURIX family is a key component of be in a position to immediately retake control of the vehicle.
the zFAS for reliable automated driving. AURIX The system identifies the system limits independently. The
enable a secure connection to the vehicle driver no longer has to permanently monitor the longitudinal
data bus. It assesses and prioritizes data Level 2 and lateral guidance of the vehicle. However, the driver has
packets and initiates their processing in the to remain able to resume driving when prompted by the
SPECIAL FEATURE
fastest possible time. For example, it initiates system with a specific buffer time.
emergency braking based on data from radar The driver can hand over the full driving task to the system
and other sensor systems. The AURIX family Level 4 in specific applications (road type, speed zone, environmental
of microcontrollers is especially ideal for this conditions).
purpose thanks to high processing power and Driverless driving. The vehicle can perform the driving task
extensive safety features. Level 5 fully autonomously—on all road types, in all speed zones and
AURIX microcontrollers are used in several under all environmental conditions.
controllers in the Audi A8. They control
the functions for the engine. And they also TABLE 1
operate in the Audi AI active chassis and in the The ability of cars to self-drive is split into a number of different levels (Source: German Association of the
electronic chassis platform, which controls the Automotive Industry).
SPECIAL FEATURE
Kit will include a front vision system based on The first release of NXP’s Automated Drive Kit will include a front vision system based on NXP’s S32V234
NXP’s S32V234 processor, allowing customers processor, enabling developers to deploy their algorithms of choice.
to deploy their algorithms of choice. The
Kit also includes front camera application
software APIs and object detection
algorithms provided by Neusoft. The kit also CRATON2 chipset, an advanced and secure V2X
includes sophisticated radar options and GPS communication module.
positioning technology. System developers In a demonstration, they showed how
can choose from various LiDAR options the now commercially-ready technology can
and can add LiDAR Object Processing (LOP) be used to avoid collisions, describe road
modular software from AutonomouStuff, conditions and indicate distance to important
which provides ground segmentation and infrastructure, such as EV charging stations.
object tracking. The DSRC-based technology today exceeds
all existing US Department of Transportation
VEHICLE NETWORKING (USDOT) specifications. The exhibit featured a
An important piece of future autonomous virtual reality experience that allowed visitors
vehicle infrastructure is the ability for vehicles to “drive” a V2X-equiped vehicle so they can
to communicate with other vehicles and with see the technology’s benefits while “driving
other platforms outside the vehicle. Providing through” multiple hazardous road scenarios.
a solution for those needs are Vehicle-to-
vehicle (V2V) and vehicle-to-infrastructure MORE EFFICIENT CONNECTIVITY
(V2I) communication, collectively referred Automated driving functionality is certain
as V2X. V2X is a wireless technology aimed to increase the demand for accommodating
at increasing road safety and improve traffic
management. V2X technology is based on
5.9 GHz Dedicated Short Range
Communication, a derivative of Wi-Fi
specifically defined for fast moving objects.
It allows vehicles to communicate their
state, such as their position and speed, to
surrounding vehicles and infrastructures even
in non-line-of-sight condition, such as behind
a building or a curve.
At the Consumer Electronics Show (CES)
last month, Autotalks, a manufacturer of V2X
communication chipsets and STMicroelectronics
partnered to highlight both V2V and V2I use
cases at the show. The companies showed the
first mass-market-ready 2nd-gen DSRC-based
V2X solution (Figure 2). This includes ST’s FIGURE 2
Telemaco3 telematics platform and Autotalks’ This V2X solution includes ST’s Telemaco3 telematics platform and Autotalks’ CRATON2 chipset.
38 CIRCUIT CELLAR • FEBRUARY 2018 #331
heavier amounts of data networking coaxial physical layer (cPHY), optical physical
throughout vehicles. This is being fueled not layer (oPHY), daisy-chain topologies or
only by the increasing amount of sophisticated creative hybrid combinations. Customers
driving electronics, but also the emergence currently using MOST150 systems can also
of more sophisticated infotainment systems rapidly migrate to new topologies or daisy-
aboard cars. Microchip Technology for is chain additional nodes with little hardware
part is helping evolve that networking with and software redesign.
its intelligent networking solution. In June Besides an integrated cPHY, a USB 2.0
of 2017, Microchip announced its newest high-speed user interface is also part of the
MOST150 Intelligent Network Interface OS81119 INIC. This integration further reduces
Controller (INIC). It enables automotive system component count, driving down overall
manufacturers and tier one suppliers costs. Time to market can be improved when
to incorporate Media Oriented Systems using the USB standard and corresponding
Transport (MOST) networks in a daisy-chain standardized MOST Linux Driver. Meanwhile,
configuration on coaxial physical layer with using an open-source Linux operating system
the support of full-duplex communication, in and driver for the OS81119 helps customers
SPECIAL FEATURE
moving objects. High output power enables informational ADAS, integrated digital
greater range and identification of smaller cockpit, digital instrument cluster, head-
objects, while its low phase noise improves up display and more. Designed for
unambiguous detection of smaller objects in automotive safety and robustness, the
the presence of large objects. Jacinto heterogeneous architecture includes
The Renesas Autonomy Platform is an hardware firewalls, allows separation
open, innovative and trusted platform for between High Level OS (HLOS) and safety OS
ADAS and automated driving, supported as well as implementation of robust multi-
by Renesas’ sustainable and scalable SoC domain software architecture capable to be
and MCU roadmaps. The RH850/V1R-M MCU ASIL-B safety certified.
was specifically designed for use in RADAR
applications as part of the sustainable and INFOTAINMENT EVOLUTION
scalable portfolio. The new MCU includes Although it may seem obvious, the
optimized programmable digital signal emergence of autonomous vehicles will
processing (DSP), a dual CPU cores each naturally boost demands for more advanced
operating at 320 megahertz (MHz) with 2 MB in-vehicle infotainment systems. Drivers will be
SPECIAL FEATURE
of flash and 2 MB internal RAM. freed up to take advantage of those systems
With feet in both worlds, Texas once being hands-off the steering wheel
Instruments for its part is a provider of becomes “normal.” The trend toward more
both embedded processing and analog ICs advanced vehicle infotainment will involve a
aimed at the automotive space. For example, variety of high-performance computing,
TI’s Jacinto family of processors provides display and connectivity technologies. But we’ll
support for a variety of automotive digital save that for a future article.
cockpit applications including infotainment,
head unit co-processing for infotainment,
40 CIRCUIT CELLAR • FEBRUARY 2018 #331
PHOTO 1
TS-7553-V2 is developed around the NXP i.MX6 UltraLite, an advanced implementation of a single
ARM Cortex-A7 core, which operates at speeds up to 696 MHz. The board specifically targets the
industrial Internet of Things (IIoT) sector.
By Jeff Child,
Editor-in-Chief
off” implementation that takes some of the SBCs featuring eight standard models. The
benefits of a standard form factor. There are Newport Family is based upon the Cavium
also some company-specific “standard” form Octeon TX 64-bit ARMv8 SoC, which has been
factors that offer an innovative new approach. designed specifically for high performance
The focus in this article is on commercial SBCs networking applications. The Newport Family
for professional applications, not modules for of boards offers processors ranging from
hobbyist projects. an 800 MHz Dual Core up to a 1.5 GHz Quad
Core. The Octeon TX features large L1/L2
ARM-BASED BOARDS caches, rich I/O with support for the latest
In terms of sheer numbers of SBC standards (PCIe Gen 3, SATA3.0, USB 3.0,
products, Intel processor-based solutions DDR4), security and networking acceleration
tend to dominate. But in recent years, non- engines, hardware virtualization, low power
TECH SPOTLIGHT
standard SBCs based on ARM embedded (less than 4 W) and IPSec performance of 8
processors are increasing mindshare in Gbps with only 2-cores.
the industry. In a recent example of an The Newport Family of network processor
ARM-based solution, Technologic Systems boards feature up to 8 GB of DDR4 DRAM,
in December starting shipping its newest up to 64 GB eMMC flash, up to 5 GbE Copper
SBC, the TS-7553-V2 (Photo 1). The board is Ethernet ports, up to 2 SFP ports for fiber
developed around the NXP i.MX6 UltraLite, a support, microSD, SIM and USB 3.0. The board
high-performance processor family featuring also has up to 4 Mini-PCIe expansion sites
an advanced implementation of a single ARM allowing support for a variety of peripherals
Cortex-A7 core, which operates at speeds up to including Wi-Fi radios, 4G/LTE cellular
696 MHz. While able to support a wide range of modems, mSATA drives and other Mini-PCIe
embedded applications, the TS-7553-V2 was cards. Optional features include GPS w/PPS
specifically designed to target the industrial support, CAN bus and a SHA-256 crypto-
Internet of Things (IIoT) sector. strong symmetric key-based authentication
The TS-7553-V2 was designed with IC for secure deployments.
connectivity in mind. An on-board Xbee Additional standard features include
interface, capable of supporting Xbee or digital I/O, RS232/RS485 ports, USB3.0,
NimbleLink, provides a simple path to adding SPI/I 2C expansion ports, wide voltage range
a variety of wireless interfaces. An Xbee input (8 VDC to 60 VDC), 802.3af/at PoE,
radio can be used to link in with a local industrial temperature operation and the
2.4 GHz or sub 1 GHz mesh networks, allowing Gateworks System Controller (GSC). The
for gateway or node deployments. Both Digi GSC provides system health monitoring and
and NimbleLink offer cellular radios for this advanced watchdog support, including the
socket, providing cellular connectivity for ability to power up and down the board at
applications such as remote equipment programmable intervals.
monitoring and control. There is also the Board sizes range from a small GW6100 at
option for a cellular modem via a daughter 35 mm x 100 mm, up to the largest GW6400
card. This allows transmission of serial data at 140 mm x 100 mm. Power consumptions of
via TCP, UDP or SMS over the cellular network.
The TS-7553-V2 also includes an on board
WiFi b/g/n and Bluetooth 4.0 option, providing
even more connectivity.
Further radio expansion can be
accomplished with the two internal USB
interfaces—one on a standard USB Type A
connector, and the second on simple pin
headers. The USB interfaces enable support
for multiple proprietary networks via a dongle
or USB connected device. This provides
the opportunity to run mesh, LoRa, ZigBee,
automotive WiFi or other protocols with the TS-
7553-v2. All of these radio options combined
with the on board 10/100Base-T Ethernet
create the opportunity to communicate
seamlessly with up to 5 different networks
simultaneously from a single point.
TECH SPOTLIGHT
In November Digilent announced its Zybo Z7 (PCIe/104 and PCI-104 expansion) with
board (Photo 3), a feature-rich, ready-to- support for up to 4 I/O modules. Venus also
use embedded software and development supports two Mini Card sockets. The top side
board built around the Xilinx Zynq-7000 FPGA socket supports full-size PCIe and USB Mini
family. This is the second-generation update Card along with mSATA disk modules, while
to the popular Zybo that was released in the bottom side socket supports full and half
2012. The Zynq family is based on the Xilinx size PCIe Mini Card. Mass storage options
All Programmable System-on-Chip (AP SoC) include SATA DOM, mSATA and a connector
architecture, which tightly integrates a dual- for an external SATA drive (all ports are SATA
core ARM Cortex-A9 processor with Xilinx III capable). The wide range 9 V to 18 V input
7-series FPGA logic. voltage provides additional flexibility.
The Zybo Z7 surrounds the Zynq with Venus incorporates a full suite of rugged
a rich set of multimedia and connectivity features such as soldered memory, latching
peripherals to create a formidable SBC, even connectors, and a thicker PCB, making it
before considering the flexibility and power suitable for the most demanding vehicle
added by the FPGA. The Zybo Z7’s video- applications. The 4 GB soldered memory
capable feature set includes a MIPI CSI-2 may be upgraded to as high as 20 GB using
compatible Pcam connector, HDMI input, HDMI Diamond’s unique RSODIMM rugged memory
output and high DDR3L bandwidth. Attaching modules, which are designed to withstand
additional hardware is made easy by the Zybo MIL-STD-202G shock and vibration
Z7’s Pmod connectors, allowing access to specifications. Standard DDR4 SODIMM
Digilent’s catalog of over 70 Pmod peripheral modules may also be used.
boards, including motor controllers, sensors, The bottom side heat spreader provides
displays and more. Zybo Z7 comes in two the most efficient cooling solution in a
APSoC variants: Zybo Z7-10 features Xilinx
XC7Z010-1CLG400C. Zybo Z7-20 features the
larger Xilinx XC7Z020-1CLG400C.
XEON-BASED SBC
Likewise embracing the 3.5-inch defacto
standard, COMMELL in October announced
its LS-37K 3.5-inch embedded mini-board
based on Intel 6th/7th generation FCLGA1151
Skylake / Kaby Lake Core processor
family and Xeon E3-1200 v5 processor
PHOTO 5 (Photo 5). The Skylake PC is claimed to deliver
The LS-37K-3D8The LS-37K desktop 3.5-inch mini-board platform that supports DDR4 memory DIMM 30% better performance than a PC base on Ivy
1866/2133 MHz up to 16 GB. The board is based on Intel HD530 (Skylake) HD630, (Kaby Lake) and HD P530 Bridge architecture, 20% better performance
(Xeon E3-1200v5). than a PC based on Haswell, and 10% better
performance than a Broadwell PC.
LS-37K-3D8The LS-37K desktop 3.5-inch
mini-board platform supports DDR4 memory
DIMM 1866/2133 MHz up to 16 GB. The
platform is based on Intel HD530 (Skylake)
HD630, (Kaby Lake) and HD P530 (Xeon E3-
1200v5). For graphics, the Skylake GPU offers
24 execution units (EUs) clocked at up to
1150Mhz (depending on the CPU model). The
revised video engine now decodes H.265/HEVC
completely in hardware and thereby much
more efficiently than before, and HD Graphics
630 GPU is largely identical to the 530 found
in Skylake. The only real upgrade here is the
HEVC and VP9 support. LS-37K Displays can
be connected via 1 VGA, 1 LVDS, 1 DVI, 1 HDMI
and one DP port, up to three displays can be
controlled simultaneously.
LS-37K offers lots of features including
high-speed data transfer interfaces such as
4 x USB 3.0 and 2 x SATA III, equipped with
dual Gigabit Ethernet (One of the dual LAN
with iAMT 11.0 supported), and comes with
PS/2 port, 5 x RS232 and 1 x RS232/422/485,
4 x USB 2.0, Intel High Definition Audio, and
1 Mini PCIe socket (supporting mSATA) and
9 VDC to 30 VDC input.
Axiomtek’s offering is the CAPA312, a
fanless 3.5-inch embedded motherboard,
powered by the Intel Pentium processor
N4200 or Celeron processor N3350. This 3.5-
inch embedded board is a performance-driven
solution for IoT/M2M related applications,
such as industrial automation, self-service
terminals, digital signage, POS/kiosk displays,
medical and more. It offers a wide operating
PHOTO 6
temperature range from -20°C to +60°C (or
The GENE-SKU6 W1 is a 3.5-inch subcompact board designed to handle harsh, unstable conditions. This
optionally up to +70°C) and comes with rich
includes has a DC input range of 9 VDC to 36 VDC that enables it to take power drops and spikes in its stride
and continue operating.
I/O connectors, various display interfaces and
circuitcellar.com 45
TECH SPOTLIGHT
DESIGNED FOR HARSH
ENVIRONMENTS
Not all applications are equal when it
comes to their environmental requirements.
And several non-standard SBCs take special
care in their designs to enable them to operate
in harsh environments. Along those lines,
in December AAEON has launched its GENE-
SKU6 W1, a 3.5-inch subcompact board with
the specifications needed to handle harsh,
unstable conditions (Photo 6). When hardware
is used for outdoor, factory automation, or in-
PHOTO 7
vehicle applications, you can’t always be sure
The MIO-5350 is a 3.5-inch fanless SBC that supports the latest Intel Pentium N4200/ Celeron N3350/ Atom
that its DC input will remain stable. Because E3900 series low power consumption processors with a TDP of only 6 W to 12 W.
businesses can’t afford for their systems to
shut down, they need computers that can
withstand power fluctuations and keep on
running. With that in mind, the GENE-SKU6
W1 has a DC input range of 9 VDC to 36 VDC,
so it takes power drops and spikes in its stride
and continues operating.
This rugged subcompact board also PaaS/RMM—a cloud ready solution for remote
has a WiTAS 1 wide-temperature rating, device management that brings the benefits
meaning it’s guaranteed to run smoothly in of cloud computing within the reach of many
environments as cold as -20°C and as hot embedded application developers.
as 70°C. This capability is achieved through MIO-5350 is designed to fulfill a variety
intelligent design, low-power components and of vertical application needs. It adopts a rich
an effective heatsink. Those design features array of I/O interface including: dual LAN ports,
enable the GENE-SKU6 W1 to function as 2 x USB3.0, 4 x USB2.0, 4 x COM ports, and 2
a reliable, fanless solution. The board’s x SATAIII. For expansion, MIO-5350 supports
features include support for 4K resolution 1 x M.2 (key-E), 1 x full-size MiniPCIe (mSATA),
and independent DP, DVI, and LVDS display and MI/O Extension (MIOe). These allow various
outputs. It has Mini-card and mSATA slots, peripherals modules like WiFi, 3G/LTE, storage,
four USB 3.0 and two USB 2.0 ports, four COM and I/O expansion (EXM and MIOe) to expand
ports and an additional BIO interface enabling functionality. MIO-5350 can operate under wide
board-to-board connection. temperature settings ranging from -40 °C to
Meanwhile, Advantech latest play in the 85 °C, making it well suited ideal solution for
3.5-inch SBC arena is its MIO-5350. Released use in rugged and harsh environments such
in October, the MIO-5350 is a 3.5” fanless SBC as factory automation, railways and outdoor
that supports the latest Intel Pentium N4200/ signage and kiosks.
Celeron N3350/ Atom E3900 series low power While non-standard SBCs aren’t expected
consumption processors with a TDP of only to really encroach too much into the market
6 W to 12 W (Photo 7). MIO-5350 provides share of standards-based form factor
40% CPU performance enhancement and 46% solutions, they do have a bright future. The
graphic performance boosts compared with direction of semiconductor integration is
previous generations. It offers 4K2K graphics always leading to an ability to fit more
and three simultaneous displays through electronics on a smaller board. That means
HDMI/DP, LVDS/eDP, and VGA interfaces. that non-standard SBCs will trend toward
MIO-5350 comes bundled with Advantech’s ever higher compute-densities while pushing
exclusive iManager APIs, utilities and WISE- down the power dissipation curve.
46 CIRCUIT CELLAR • FEBRUARY 2018 #331
Product Focus:
MCU Development Tools
Connectivity Expands
Photo 1
Because NXP’s Kinetis KW41Z wireless MCU supports multiple connectivity protocols, it was
possible to build an IoT-driven aquarium ecosystem. This enabled aquarium enthusiasts to
By Jeff Child, quickly and easily create a connected system of aquarium lights and pumps, and control it
all from anywhere with just a smartphone.
Editor-in-Chief
PRODUCT FOCUS
Platform Supports ADI’s MCUs Tools for Cypress Semi’s PSoC Kit Enables XMC MCU Digital
and RF Transceivers BLE 6 MCU Power Development
The EV-COG-AD4050 is a development Cypress Semiconductor’s PSoC Infineon Technologies’ XMC digital
platform for Analog Devices’ Ultra Low BLE Pioneer Kit features a PSoC 63 power explorer kit uses Infineon’s
Power technology across ADI’s MCU MCU with Bluetooth Low Energy XMC range of ARM Cortex-M
and RF transceiver portfolio. The board (BLE) connectivity. The kit enables microcontrollers, OptiMOS BSC0924NDI
uses CrossCore Embedded Studio, an development of modern touch and MOSFETs and IRS2011S high and low
open source Eclipse based Interactive gesture-based interfaces that are side drivers. The kit’s power board
Development Environment (IDE), which robust and reliable with a linear slider, features synchronous buck converter
can be downloaded free of charge. touch buttons and proximity sensors with on-board resistive load banks. The
The platform contains many hardware based on the latest generation of load banks can be switched between
and software example projects for Cypress’ CapSense capacitive-sensing 10%, 55% and 100% of the maximum
customers to prototype and create technology. load, so that the transient response and
solutions for IoT applications. the quality of the control loop under
• Single- or dual-core PSoC 6 MCU, different load conditions can be tested.
• On-board ultra-low power ARM with an ARM Cortex-M4 and ARM
Cortex M4F MCU Cortex-M0+ core, 1 MB of Flash, • Two control card options: XMC1300
• No external debugger/emulator tools 288 KB of SRAM, 78 GPIO, 7 control card (ARM Cortex-M0) and
required programmable analog blocks, 56 XMC4200 control card (ARM Cortex-
• Small form factor (75 mm X 35mm) programmable digital blocks and M4F
• Multiple power options: USB, Bluetooth Low Energy (BLE) • Synchronous buck converter
Coincell, External and Li-Ion • 2.7” E-ink display shield board • 2 different control card options:
• Onboard peripherals: accelerometer, • Cypress EZ-PD CCG3 power delivery XMC1300 and XMC4200
temperature sensor system • High resolution PWM (150 ps) and
• Compatible with ADI RF daughter • For CapSense, baseboard comes smart analog comparators on
cards, and RF modules with 2 buttons, a 5-segment slider XMC4200
• Compatible with ADI application and a proximity sensor. • On board resistive load
add-on boards (gears) • On-board antenna to develop BLE • PMBus communication option
• Expansion connectors and jumpers designs. • Easy entry into digital power control
for providing external access to all • Software, documentation, design • Voltage mode control and peak
MCU signals and create solutions for files, and code examples current mode control (with slope
IoT applications. compensation) available
Cypress Semiconductor • Full software support
Analog Devices www.cypress.com
www.analog.com Infineon Technologies
www.infineon.com
48
PRODUCT FOCUS CIRCUIT CELLAR • FEBRUARY 2018 #331
MAX32625 Development Eval Kit Facilitates Development Platform Supports NXP Kinetis
Platform is mbed Enabled for SAM D5x/E5x MCUs W Series MCUs with Bluetooth
The MAX32625MBED development Microchip Technology’s SAM E54 The FRDM-KW40Z from NXP
platform from Maxim Integrated Xplained Pro Evaluation Kit is available Semiconductors is a low-cost
provides a convenient platform for to kick-start development. The kit development platform enabled by
evaluating the capabilities of the incorporates an on-board debugger, the Kinetis W series KW40Z/30Z/20Z
MAX32625 microcontroller. The as well as additional peripherals, to (KW40Z) family built on the Arm
MAX32625MBED also provides a further ease the design process. All Cortex-M0+ processor featuring
complete, functional system ideal SAM D5x/E5x MCUs are supported an integrated 2.4 GHz transceiver
for developing and debugging by the Atmel Studio 7 Integrated supporting Bluetooth Smart/Bluetooth
applications. The MAX32625MBED Development Environment (IDE) as well Low Energy (BLE) v4.1 and/or IEEE
includes a MAX32625 ARM Cortex-M4 as Atmel START, a free online tool to 802.15.4-2011 standards.
microcontroller with FPU, prototyping configure peripherals and software that
area with adjacent access to precision accelerates development. • Supports MKW24D512 Kinetis MCUs
analog front end (AFE) connections, (up to 50 MHz Corte-M4 MCU, 512
I/O access through Arduino-compatible • ATSAME54P20A microcontroller KB Flash)
connectors, additional I/O access • Embedded debugger with USB • Full IEEE 802.15.4 compliant
through 100 mil x 100 mil headers, USB interface. wireless node
interface and other general-purpose • Digital I/O: Two mechanical buttons Software support: Thread, ZigBee Pro,
I/O devices. (user and reset button); One Atmel 802.15.4 MAC and SMAC and Kinetis
QTouch button. One yellow user LED; Software Development Kit (SDK)
• Arduino-compatible headers Three Xplained Pro extension headers. • Reference design area with small
and mbed support enable rapid • 256 Mb of QSPI Flash footprint, low-cost RF node
prototyping of low-power embedded • ATECC508 CryptoAuthentication device • Integrated PCB inverted F-type
systems • AT24MAC402 serial EEPROM with antenna and SMA RF port
• MAX32625 96 MHz ARM Cortex-M4 EUI-48 MAC address • Selectable power sources
microcontroller • Ethernet: 10Base-T/100Base-TX; • 32 MHz reference oscillator; 32 kHz
• Expansion connections: Arduino SD/SDIO card connector; Parallel clock oscillator; 2.4 GHz frequency
form-factor headers; MicroSD Card Capture Controller header and operation (ISM Band)
connector; Micro-USB connectors; ATA6561 CAN transceiver • OpenSDA debug interface
prototyping area • Debug connectors: 10-pin Cortex • Combo sensor, 6-axis sensor with
• Integrated peripherals: 4x user Debug Connector with SWD; 20-pin integrated linear accelerometer and
indicator LED; 2x user pushbutton Cortex Debug + ETM Connector with magnetometer
• Integrated DAPLink programming 4-bit trace
adapter • Supported with application NXP Semiconductors
examples in Atmel START www.nxp.com
Maxim Integrated
www.maximintegrated.com Microchip Technology
www.microchip.com
circuitcellar.com 49
PRODUCT FOCUS
Wi-Fi Cloud Connectivity Kit Development Platform Covers MCU Platform Enables IoT
Supports RX65N MCU Whole STM32 MCU Line Application Development
Renesas Electronics’ RX65N Wi- STMCube from STMicroelectronics The SimpleLink MCU platform from
Fi Cloud Connectivity Kit provides an is the implementation of STMCube that Texas Instruments is a single development
easy-to-use platform for connecting covers the whole STM32 MCU portfolio. environment that delivers flexible
to the cloud, evaluating IoT solutions The package includes STM32CubeMX, a hardware, software and tool options for
and creating IoT applications through graphical software configuration tool that developers crafting IoT applications. With
cloud services and real-time workflows. allows the generation of C initialization a single software architecture, modular
The RX65N Wi-Fi Cloud Connectivity code using graphical wizards. It also development kits and free software tools
Kit integrates the high-performance comprises the STM32CubeH7 MCU for every point in the design life cycle,
Renesas RX65N microcontroller (MCU) Package composed of the STM32Cube the SimpleLink MCU ecosystem allows
and Medium One’s Smart Proximity hardware abstraction layer (HAL), plus a 100% code reuse across the portfolio of
demo with the data intelligence consistent set of middleware components MCUs, which supports a wide range of
featured in Renesas IoT Sandbox. (RTOS, USB, FAT file system, Graphics, connectivity standards and technologies
TCP/IP and Ethernet). All embedded including RS-485, Bluetooth low energy,
• 120 MHz RX65N MCU board software utilities are delivered with Wi-Fi, Sub-1 GHz, 6LoWPAN, Ethernet,
• GT202 Wi-Fi module with Qualcomm a full set of examples running on RF4CE and proprietary radio frequencies.
QCA4002 low-energy 801.11a/b/g/n STMicroelectronics boards. SimpleLink MCUs help engineers easily
SoC develop and seamlessly reuse resources
• Maxbotix ultrasonic range finder • Complete embedded software to expand their portfolio of connected
• USB to UART interface (with cable) package that frees the user from products.
• 4 Pmod connectors dependency issues
• Arduino shield socket • Maximized portability between • 100% code compatibility across
• E1/E2 Lite/J-Link header for external all STM32 Series supported by SimpleLink MCU portfolio
J-Link support STM32Cube • TI Drivers offers standardized set
• USB Type B connector (with cable) • Hundreds of examples for easy of functional APIs for integrated
• 5 VDC Power Jack understanding peripherals
• High quality HAL using CodeSonar • Integrated TI-RTOS, a robust,
Renesas Electronics static analysis tool intelligent kernel for complete, out-
www.renesas.com • STM32H7-dedicated middleware of-the-box development
including USB Host and Device, • POSIX-compatible APIs offer flexible
TCP/IP and Ethernet OS/kernels support
• Free user-friendly license terms • Encryption-enabled security
• Update mechanism that can be features
enabled by the user to be notified of • IoT stacks and plugins to add
new releases functionality to IoT designs
In the first part of his new article series on IoT security, Bob
examines command injection. Command injection is a type of
attack that involves injecting and executing an unwanted shell
command or operating system command into your IoT system.
COLUMNS
By
Bob Japenga
COLUMNS
was not encrypted. This enabled any hacker COMMAND INJECTION EXAMPLE
to get access to the PHP code that handled Our security breach didn’t happen over
the HTTP interface. With code in hand, anyone Internet traffic. It happened through use of
could find an obvious and gaping security an installer accessible configuration screen
hole where we were taking input from the from an Ethernet port. When the configuration
HTTP interface and passing it to the Linux screen saved the settings, it created a URL
command line interpreter. We did not limit with all of the settings as parameters. These
or bound the input in any way. This enabled were sent to an XML parser. These parameters
the user to spoof the host and basically send were visible to someone sniffing the local
whatever commands he wished to the Linux communication which could then be modified
shell. He could create new user accounts. He to include any Linux command to be executed.
could read our symmetric keys. Ouch! The code snippet is shown in Listing 1.
This is a technique called “command cmdxmlin is an app that we wrote that
injection” which is a subset of “code injection.” parses xml input. Notice that we didn’t call
How did this happen? We know better. We the PHP shell_exec directly. A sophisticated
know what command injection is. We know hacker could still simulate the web browser
the dangers of command injection. We know and append his own commands by utilizing a
how to stop it and even exploit it. In my feature of the shell command called sequential
article “ The Internet of Things (Part 5): IoT execution. Or the hacker could take advantage
Security” (Circuit Cellar 307, February 2016) of many of the flexible features of the bash
I discussed how we used extremely clever shell to perform all sorts of nefarious attacks.
command injection to update some devices
remotely that were destined for RMAs. How
could this happen? Simple. Our systems if ($_GET[‘submit’])// when saving config
are more complex that we are capable of {
perfectly protecting. But that doesn’t mean $keys = array_keys($_POST); // get all the parameters
we don’t keep pushing for perfection. With $config_string = ‘’;
that in mind, let’s look a little more in depth foreach ($keys as $key)
at command injection. { // Fill config_string with the parameters on the URL
In my article “The Internet of Things (Part $config_string .= “\”$key=$_POST[$key]\” “;
8): Security for Web-Enabled Devices” (Circuit $response = `/apps/cmdxmlin set ${config_string}`;
Cellar 313, August 2016) I talked about code }
injection specifically with SQL which provided }
a simple mechanization for injecting unwanted
code into the system. Our failure made it even
easier to inject commands. Command Injection LISTING 1
is a subset of Code Injection. In the Common Code snippet that captures configuration settings.
52 CIRCUIT CELLAR • FEBRUARY 2018 #331
When I first introduced the topic of IoT should be limited, but most are not. If your
For detailed article security in this magazine, I described it as web server doesn’t support this, then some
references and additional defending a castle where there are many sort of watchdog that monitors certain critical
resources go to: layers of protection including the moat; the files would be helpful.
www.circuitcellar.com/ bridge, the entrance gate, the wall and even Bound all input: Input from the web should
article-materials the boiling oil. I recommended that you use be limited to be valid only within the narrow
as many layers of protection as possible to range of what you expect. We must recognize
mitigate risks. Our security gap could have our inherent blind spots in this area. It is hard
been closed or mitigated through a number of for us to think of all of the possible ranges of
layers as listed here: input. I love the first example from the classic
“The Art of Software Testing” by Glenford
Encrypting all program updates: Without Myers called a “Self-Assessment Test.” In it,
being able to read the code, many forms of code he asks you to create a set of test cases for
and command injection security breaches can the following simple program:
be avoided or at least be physically impossible
to find by trial and error. A lot of web services The program reads three integer values from
code is interpreted rather than compiled. That an input dialog. The three values represent the
means the source code is sent down during an lengths of the sides of a triangle. The program
update. Sending your code down unencrypted displays a message that states whether the
is just asking for trouble. triangle is scalene, isosceles or equilateral.
Don’t provide root access to the web
interface: When we released our first IoT Put down this article and try this now.
device, one of our customer’s customers Write out every distinct test case you can
asked us if our applications ran as root. They think of. You will have to buy the book to see
did because we didn’t know better. They how many you got right. Or email me your
COLUMNS
refused to buy the product until we changed test cases and I will grade it. At the end of
all of our application code to run as non-root. the article are three of the fourteen that I
What would have been easy at the start of missed completely. This self-assessment test
the design was difficult after the design was demonstrates how difficult it is to plan for
complete. Without root access, the hacker every possible input.
could not have done much damage even with Never treat data from the web as a
the command injection security hole. command to the shell: Our engineer assigned
Limit write access to all critical files: This to this described his fix as following:
is similar to limiting root access. A careful
look at your permissions to your files is in We closed the hole by writing the “save
order. The web server app should not be configuration” data to a temporary file,
able to write any file without some sort of rather than passing them to the command
authentication. Ideally the web server itself line interpreter. The ‘cmdxmlin’ program
PHOTO 1
Mercury switch thermostats had an electro-mechanical feature called a heat
anticipator that worked very efficiently.
circuitcellar.com 53
that used to take the configuration data as make a name for themselves at our expense. It
command line parameters now reads the is really to our benefit.
configuration data from /tmp/set_args.txt.
This way the configuration items are treated CONCLUSION
as data and not evaluated by the command When you handle things in thin slices,
line interpreter. there is so much to say and so little space to
say it. IoT security is absolutely vital. We
Study every use of calls to the command need to get this as right as possible. And we
line interpreter (shell): Be very careful with need each other’s help. Software terrorism
the passthrough exec system in PHP, the has just begun. In my opinion we’ll only see
subprocess or os.system in Python, the it increase. Next time, more lessons learned
system in Ruby…and you get the idea. in IoT security.
Push hard to close vulnerabilities: We
knew about this security hole in 2012. It
was exposed in 2015 and embarrassed the
customer in 2016. The customer closed the ABOUT THE AUTHOR
vulnerability as soon as it was reported. We
Bob Japenga has been designing embedded
didn’t push hard enough to get this changed
systems since 1973. In 1988, along with his
as soon as we knew about it. We as developers
need to be more insistent about closing best friend, he started MicroTools, which
security holes. specializes in creating a variety of real-
An open EULA: We have come full circle from time embedded systems. MicroTools has a
our introduction. I would challenge our users to combined embedded systems experience
find our security holes. Let them use automated base of more than 200 years. They love
tools to find our holes. Let them sniff our data. to tackle impossible problems together.
COLUMNS
Then the EULA would ask them to report it to us Bob has been awarded 11 patents in many
before reporting it to a government watchdog areas of embedded systems and motion
agency. As I said earlier, the systems are more control. You can reach him at rjapenga@
complex than we are capable of protecting. We microtoolsinc.com.
need others help—especially those that want to
Verilog HDL
With the right tools
designing a microprocessor
can be easy.
Okay, maybe not easy, but certainly
less complicated. Monte Dalrymple
has taken his years of experience
designing embedded architecture and
microprocessors and compiled his
knowledge into one comprehensive guide
to processor design in the real world.
cc-webshop.com
54 CIRCUIT CELLAR • FEBRUARY 2018 #331
Modulation Fundamentals
By
George Novacek
OOK MODULATION
OOK modulation results when the
baseband is a rectangular wave, such as
digital data. In many applications the OOK
modulation index is 100%—such as when
the carrier is fully on or off. In the days of
COLUMNS
Morse code communications, the continuous
wave (CW) transmission mode was a typical
OOK modulation. Some applications—
b)
namely the WWVB transmission for clock
synchronization—use 86% modulation index to
prevent receivers from losing synchronization
during transmission of logical 0s.
Three characteristics define the AM
modulation: the carrier frequency, the
bandwidth and the modulation index. Figure 2a
shows 100% and Figure 2b 50% modulation
index (depth). Amplitude modulators come
in many different configurations and are
quite simple to build. One of the early
implementations was the bridge modulator
shown in Figure 3. Figure 4 shows the WWVB,
86% depth modulator I built for my 60-kHz
carrier transmitter in the WWVB repeater. FIGURE 2
This was covered in my article “WWVB Clock In the top graph (a) a 100% modulation index is shown. The bottom one (b) shows a 50% modulation index.
Revisited” (Circuit Cellar 288, July 2014). In
this circuit the MOSFET Q1 operates in its
resistive region to modulate the gain of the
carrier amplifier U1A.
Demodulation of the broadcast AM signal is
commonly performed by envelope detectors, +
+
which can be nothing more than a simple
rectifier diode followed by an RC network. The .
FM AND PM MODULATION
Similar to the AM, the main characteristics
FIGURE 4 of the FM and the PM modulation are the
Simplified diagram of the WWVB modulator carrier frequency, the required bandwidth
and the modulation index. The modulation
index is the frequency or phase deviation
of the carrier in response to the modulation
signal. PM is similar to the FM except that
instead of changing the carrier frequency,
which remains constant, only its phase is
modulated. In the time domain analysis, both
FM and PM look the same, just the deviation
COLUMNS
COLUMNS
for digital communications, while the
analog QAM carries the chrominance (color)
information in television broadcasting and
the OOK is commonly found in remote
control systems, key fobs and some digital
data transmitters.
For completeness we should mention
two special modulations: frequency hopping
and spread spectrum modulation. These
modulations do not carry information per
se. The former is intended to increase
communications security while the latter
improves electromagnetic compatibility
(EMC) of electronic systems.
Over the years numerous circuits have
been developed for demodulation of FM, PM FIGURE 8
and other modulations. Older demodulators PLL demodulator
used the slope of LC resonant circuits, then
came ratio detectors, PLLs, quadrature
demodulators and others. Nowadays PLLs
(Figure 8) are still used for both FM and PM
demodulation, but this is quickly changing.
Our present-day technology facilitates the
development of digital radio, which relies
on digitization of the carrier frequency. This
makes possible digital signal processing ABOUT THE AUTHOR
and may be followed by conversion of the
George Novacek is a retired president of an
digital data back to analog to recreate
aerospace company. He is a professional
the baseband. Whether data or voice
engineer with degrees in Automation and
communications are involved makes little
Cybernetics. George’s dissertation project was
difference. Digitization of 10 GHz carrier
is already a reality and once digitized, the a design of a portable ECG (electrocardiograph)
skies are the limits for further processing. with wireless interface. He’s been contributing
I intentionally omitted the pulse width articles to Circuit Cellar since 1999. Contact
modulation (PWM). This is a technique for him at gjnovacek@nexicom.net with “Circuit
conversion of digital signals to analog power Cellar”in the subject line.
and not fitting the current topic.
58 CIRCUIT CELLAR • FEBRUARY 2018 #331
By
Robert Lacoste
this limit. Conversely this theorem also states random source of binary bits.
that there isn’t any way to reduce it to less
than this limit—even if you are the cleverest SOME NOISE?
engineer on Earth! Okay, now let’s see what happen when there
In this article I will no longer assume is some noise. And there is always noise in a
that the channel is noise free. For simplicity, circuit or transmission. Trust me! First of all,
I will however restrict myself to the case noise introduces errors in the bit transmission.
of a binary data source (there are only two Secondly, noise will limit the capacity of the
symbols to transmit: 1 and 0). I will also channel, depending on its bandwidth. That
assume that the probability of 1s and 0s is second sentence may seem strange, but don’t
identical: 50% of the bits are 1s and 50% are worry. I will come back to it.
0s. It you do the calculation of the entropy of For the moment, I will simply assume
such a source, using the formula above, you that the noise introduces some errors on the
COLUMNS
will find of course that E = 1. This means that transmitted bits. Of course, the higher the
such a source needs a channel with a capacity noise, the higher the probability to receive a
of 1 bit per symbol: C = 1 x S = S. This simply wrong bit—as illustrated on Figure 1. By the
means that there isn’t any way to compress a way, I devoted an article on bit errors a while
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
0.5
0
−2 −1.5 −1 −0.5 0 0.5 1 1.5 2
FIGURE 2
Error correction protocols always Without errors
reduce the available throughput, or
increase the required raw channel
capacity for the same useful Useful bit rate Useful bit rate Useful bit rate
throughput.
Error correction
overhead
ago called “Let’s Count Errors” (Circuit Cellar In either case, the addition of these error
295, February 2015). correcting protocols will inevitably increase
If we assume that the probability of a bit the number of bits to be transmitted. You
error p err is not null, then the transmission will will have to transmit not only the source
be deteriorated. Now, assume that you need to bits, but also additional bits like checksums,
design a reliable and error free transmission retransmissions, error correcting codes and
using such a channel. What would your so on (Figure 2). So, when noise introduces
options be? You could try to improve the some errors in the transmission, the actual
electronics with a better signal to noise ratio channel capacity must be higher to allow
(SNR), reducing the noise as much as you can error recovery. More exactly, this capacity
or try using stronger signals. Another way— (in bits per seconds) must be more than the
more interesting from an information science minimum capacity in the case of a noise free
point of view—would be to use an error channel, which is the entropy of the source
correction protocol instead of just sending times the symbol rate. But how much more?
the raw bits. Such a protocol would help to
recover the erroneous bits—as long as they’re FUNDAMENTAL THEOREM
not too numerous. For that, you could simply And here comes some magic again
add checksums to the transmitted data and with the fundamental Shannon theorem in
retransmit any wrongly received message. presence of noise. Shannon proved that the
You could also use forward error correction minimum channel capacity in the presence of
codes, as explained in another of my old such a noise must be:
articles: “ Living with Errors: An Introduction
to Forward Error Correction,” (Circuit Cellar CMINIMUM (bits / s) = E(entropy per symbol,
235, February 2010). S(symbols / s)
in bits) ×
R (reduction factor )
between 0 and 1. Look at the plot of this what this best error correction method is,
function on Figure 3. The capacity of a channel but simply that it exists. With that in mind,
in presence of noise is simply reduced by a thousands of researchers are working on
factor R, depending on the error probability. error correcting codes since 1948, in order
An example should help: Assume that you to find error correction codes as close as
send ten million binary symbols (bits) per possible to Shannon limit!
second and that 5% of them are corrupted by To summarize, the quite simple formula
noise. What would be the minimum channel given above enables you to calculate the
capacity for an error free transmission? Here Shannon limit or Shannon capacity of a
we have E = 1 (one bit per symbol), S = 10M communications channel, which is the
and R = 1+0.05.log2(0.05) + 0.95.log2(0.95). theoretical maximum error-free information
Do the calculation and you will find R = transfer rate of the channel for a particular
0.71. That means that the minimum channel noise level. Information simply cannot be
COLUMNS
capacity in that case is: guaranteed to be transmitted reliably at rates
beyond this channel capacity.
10M
CMINIMUM = 1 × = 14.1 Mbps
0.71 LIMITED BANDWIDTH
In my introduction, I told you that noise
Okay, but what does this actually also limits the capacity of the channel
mean? What did Shannon prove? First, he depending on its bandwidth. What’s that
demonstrated that if the raw channel capacity all about? To understand, we have to move
is lower than this value then there is absolutely from a theoretical transmission channel to
no way to invent an error correction protocol something closer to an actual channel—like
that will correct the transmission errors. a wire or radio link. It will for sure have a
You will always have a significant number of limited bandwidth W, expressed in Hertz.
errors, even if you are a genius. Conversely, Let’s assume W = 100 kHz, and for simplicity’s
Shannon also demonstrated that there exists sake consider that the channel is something
a solution to have an error rate as low as like a brick-wall filter: It transmits perfectly
you want, as long as the channel capacity is all frequencies from DC to 100 kHz, but stops
just slightly above that threshold. That result any signals above that threshold.
astonished the community in 1948—and is What’s the capacity of such a channel
still to this day nearly unbelievable. The bad in bits/s? First, a strange but true result: If
news is that the Shannon theorem is not a so there isn’t any noise, then this capacity is
called constructive proof. It doesn’t tell you infinite. Now you probably think I’m crazy. Hey
1.0
0.9
0.8
0.7
0.6
Channel
capacity 0.5
reduction
0.4
0.3
0.2
0.1 FIGURE 3
This plot shows you the reduction of
the channel capacity R, depending
0 on the probability of an error on
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
single bits: perr. Not surprisingly,
Probability the throughput is 100% when there
of bit error are no errors, and 0 when bits are
random (50% of bits wrong).
62 CIRCUIT CELLAR • FEBRUARY 2018 #331
FIGURE 4
Here is the maximum useful error-free 7
bit rate Bmax for 1 Hz of bandwidth,
depending on the signal to noise ratio
6
SNR (here expressed in dB).
Error
free bits 3
per Hertz
COLUMNS
0
−20 −15 −10 −5 0 5 10 15 20
SNR (dB)
FIGURE 5
16 The maximum achievable Eb/N0
performance is closely linked to H: the
number of useful error-free bits per
14
Hertz of bandwidth.
12
10
Eb⁄ No 8
minimum
(dB) 6
COLUMNS
4
−2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8
Error free bits per Hertz
in a 1 Hz bandwidth, measured in Watts per Read this last formula again. It provides
Hertz. N0 is then calculated as the total noise an absolute minimum on Eb/N0, depending
power N divided by the channel bandwidth W: only on the effective number of bits per Hertz
of bandwidth. This is illustrated on Figure 5.
N(noise level) If H is very small (large bandwidth), then Eb/
N0 =
W (channel bandwidth) N0 gets close to ln(2), which in decibels is
10log(ln(2)) = -1.59 dB. This often-quoted
You will notice that Eb and N0 are limit of Eb/N0 = −1.59 dB applies only to the
both expressed in Joules, so their ratio is very theoretical case of infinite bandwidth.
dimensionless. It can then be expressed For limited bandwidth, the absolute
in decibels if you wish. Of course, Eb/N0 is Eb/N0 limit is always higher. For example, if
closely related to the carrier-to-noise ratio: H = 2 (bandwidth twice more than the bit
rate), then the formulas shows that Eb/N0 is
(Eb × B)
SNR = S / N = = (Eb / N0) × (B / W ) always above 1.76 dB.
( N0 × W )
And finally, remember the Shannon WRAPPING UP
capacity limit? It is calculated as: I know that these two articles on
information theory were a little more math-
B max(bits / s) = W (Hertz) × log 2 (1 + SNR ) oriented than usual, but I am strongly
convinced that these results are far too
The useful bit rate B should stay below the important to be skipped by any electronic
threshold Bmax, so we must have: engineer, ham radio guy or
telecommunication enthusiast. I hope that
B < W × log 2 (1 + SNR ) or you have grabbed the essentials. If not, read
B / W < log 2 (1 + Eb / N0 × B / W ) these articles again and have a look on the
books and articles listed on Circuit Cellar’s
If we call H = B/W (useful bits per Hertz of article materials webpage. And finally, like
bandwidth), then this leads to: most of you, I’m far more of an electronic
designer than an information science expert,
H < log 2 (1 + Eb / N0 × H) or so don’t hesitate to contact me if I’ve said
2H < 1 + Eb / N0 × H something wrong or too simplified. Last but
not least, play with these formulas yourself
or finally: and have fun!
(2H − 1)
Eb / N0 >
H
64 CIRCUIT CELLAR • FEBRUARY 2018 #331
Merchandising Association (NAMA), the require two receivers for its configuration.
organization that developed the international The carrier board will have a MDB
specification for the Multi-Drop Bus/ connection on one end and a microcontroller
Internal Communication Protocol (MDB/CP) with the ability to interchange 9-bit data
released in July 2010. The MDB/ICP enables with the MDB. My original project, the slave
communication between a master controller interface, requires a standard 8-bit UART to
and any of the peripheral hardware like Coin connect with the coin acceptor. While all the
Acceptors and bill validators. By adhering functions of a master could be programmed
to these guidelines, any manufacturer’s into this microcontroller when the carrier
equipment is interchangeable. board is configured to emulate a master,
Turns out the Coin Acceptors I purchased a UART interface would enable a master
don’t have the MDB interface necessary interface to a PC. The PC could be used to
to communicate with a Vending Machine emulate the master and allow a user to
Controller (VMC). I reviewed the protocol and issue commands to the MDB. When used as
VMC/Peripheral Communication Specifications a spy device the UART interface allows all
required by the Coin Acceptor/Changer communication to be displayed on a PC, LCD
peripheral and began work on developing or even a printer! That’s the logic that has
an MDB interface that would bridge my Coin twisted this project’s circuitry into its present
Acceptor with the multi-drop bus. configuration.
The carrier board in last month’s
PROJECT CIRCUITRY installment contains a power supply front
If you need to review the MDB/ICP, please end for a master. Either an AC (transformer)
reread last month’s article (Circuit Cellar 330, or DC (power supply) input can be used for
January 2018) or get the specs from the NAMA input when the carrier board is configured as
website [1]. The communication protocol is a master. When used as a slave, the supply
COLUMNS
9600, 9, 1, N. There are two unusual things on the MDB is regulated into a 12 VDC supply
here. First, you’ll note the data size on the and a 5 VDC supply. Not only does this give
MDB is 9 bits—not standard with many UARTs. two additional voltage outputs for a slave/
The second thing here is that the multi- spy device, but it also divides the regulator
drop bus uses a 20 mA control current and drops over two regulators reducing the
peripherals are opto-isolated from the bus. power that must be dissipated by each.
The LED transmitter in each opto-coupled The microcontroller has a few configuration
device is easily turned on with 20 mA. The inputs and LEDs, enabling the application
master directly interfaces with the bus and it to be changed via jumpers. At present we’ll
must supply a minimum of 20 VDC with some be using three of the four possible jumper
hefty current in support of all connected settings for Mode 0:2—master, slave and spy.
peripherals. The MDB/ICP specs suggests
some typical bus interfacing circuitry. SPYING
If you review this, you’ll find four different The protocol for any MDB activity requires
circuits (a through d), a non-isolated that no slave send any response unless the
transmitter and receiver (master) and an master has asked that particular slave device
isolated transmitter and receiver (slaves). to respond to its command. This means that
There is a reason for presenting these as while the MDB has a transmission path to all
individual circuits (modules). This project slaves and a separate response path from all
requires emulating a slave device and, slaves, that communication will only take place
therefore, requires an isolated interface to the on one path at a time—either a command or a
MDB. If you wanted to emulate a VMC (master) response. You’ll note from the carrier board’s
you would need a non-isolated interface to circuitry that when two receivers are used for
the MDB. Using modules would allow a carrier
board to be configured for either a master or
a slave by substituting modules! In fact, it also
opens a third possibility—a configuration that ABOUT THE AUTHOR
might even be more useful in this project: an Jeff Bachiochi (pronounced BAH-key-AH-
MDB spy board! key) has been writing for Circuit Cellar
Without access to a complete system—like s i n c e 1 9 8 8 . H i s b a c kg ro u n d i n c l u d e s
a product vending machine—it will be difficult product design and manufacturing. You can
to know if the protocol is being sent correctly
reach him at:
unless we can monitor all MDB activity.
Producing a spy device that can attach to the jeff.bachiochi@imaginethatnow.com or at:
MDB and display both master transmissions www.imaginethatnow.com.
and slave responses will be indispensable for
assuring proper operation. A spy device will
66 CIRCUIT CELLAR • FEBRUARY 2018 #331
PHOTO 1
Using RealTerm to display the SPY
boards output of MDB traffic, you can
see how the coin acceptor responds to
commands from the master.
COLUMNS
a spy device (Mode 2), we have separate serial additional input to the MCU to determine
communication channels. If we are going to when the command receiver was active. After
use one UART for peripheral communication, that, I figured as long as I was going to use
that only leaves one hardware UART left for an additional input, I might as well implement
the MDB communications. I figured I could a third UART via software. With the command
just wire OR them into that UART. Since receiver connected to the hardware UART and
communication only exists on one of the two the response receiver connected to a software
channels at a time, I could easily receive both UART, the problem would go away!
through the same UART. This turned out to Commands and responses are sent in
be a bigger issue than I expected. There groups. At 9600 baud, a data byte can
was no easy way to determine the end of the be sent in just over 1 ms. The maximum
command and the beginning of the response. interbyte delay can be no more than 1 ms.
Each command (or sub command) can have Any response to a command must be made
different lengths. After trying to predefine within 5 ms of a command. Remember how
this, it was turning into a difficult project. the format of the MDB data is 9-bits? Well,
I experimented a bit with using an this serves two purposes. First, the master
Denomination Security Security Bell in Water- Color Shifting Raised Magnetic Micro Linen/Cotton
Thread Ribbon the mark Denomination Printing Ink Printing w/red
Inkwell blue fibers
$100 X X X X X X X X X
$50 X X X X X X X X
$20 X X X X X X X X
$10 X X X X X X X X
$5 X X X X X X X
$2 X X X
$1 X X X
TABLE 1
High tech embedded technology helps to thwart counterfeiters. High value denominations include more technology that offsets the difficulty in reproductions.
circuitcellar.com 67
sets the 9th bit of the first byte of every comes into a separate software UART—it can FIGURE 1
command as an indication of address data. now be displayed appropriately. Here we see the $5 dollar bill with
The data in this byte is monitored by all slave the visible security measures labeled.
devices to determine if it will respond to the UNIVERSAL MDB RECEIVER Validation looks for a combination of
these and other measures to identify
command or just ignore it. As we saw last While the carrier board configured with
COLUMNS
‘‘real‘’ currency.
month, each different slave device has its modules can only be used for a specific
own predefined address. For example, our configuration—master, slave or spy—the
Coin Acceptor/Changer has a base address of MCU’s application can support any of the
B’00001xxx’. Any address between 0x08 and Modes. Setting the jumpers is used to
0x0F should only be responded to by a Coin configure the Mode. In Mode 0 we’re emulating
Acceptor/Changer slave device. Each separate a master, while anything received from the
address may have a pre-defined command MDB will be a response from a slave. When in
specifically for that particular type of device. Mode 1, we’re emulating a slave and anything
If a command is issued for an address with no received from the MDB will be a command
pre-defined command, the slave device just from the master. Finally, when the Mode is 2,
does not respond. So, if the first byte of a
received string of data has the 9th bit set on
the first byte, it’s a command. Responses also
use the 9th bit. In that case, the last byte of a
received string will have its 9th bit set.
For the most part, all commands and
responses will have a checksum added as the
last character of the command string. This is
simply the least significant bit (LSB) of all the
proceeding bytes. There are three instances
of no checksum: ACK, NAK and RET. The ACK
response indicates the data is accepted. The
NAK response indicates a timeout. The RET
response is a request to resend the last data.
Note that while none of these responses have
checksums added, responses by the slave
must have the 9th bit set because it is the
last, and only, character!
So, as a slave device we can determine
when a command ends by looking for a
5 ms timer overflow after each command
character received. Once received, the slave
must determine if the command is using one
PHOTO 2
of the slave’s addresses and if so, what to do
Here I’ve exposed the main circuitry from two different bill validators. Optical sensors are used to measure
next. For a spy device, we can potentially see
physical parameters as well as spectrum components. These, along with magnetic signatures, help to
a response within 1 ms. However, now that assemble a digital representation of each bill. Validation occurs when this corelates to the prestored data
we can differentiate the response—because it for each denomination.
68 CIRCUIT CELLAR • FEBRUARY 2018 #331
VMC Address VMC Data Response VMC ACK we’re spying on both the master’s commands
Command Data and any slave’s responses. Hardware UART2
RESET 0x30 - ACK - receives commands and software UART3
receives responses.
SETUP 0x31 - 27 bytes ACK As the coin acceptor slave device, once a
SECURITY 0x32 2 bytes ACK - command string has been received with an
address byte between 0x08 and 0x0F—and
POLL 0x33 - 16 bytes ACK
the checksum verified—the command can be
BILL ENABLE 0x34 4 byte ACK processed. This slave will respond to all legal
ESCROW 0x35 1 byte ACK commands, however only three are pertinent.
The Reset command 0x08 will reset the slave
STACKER 0x36 - 2 bytes ACK
device. The Setup command 0x09 response
EXPANSION 0x37 0x00 29 bytes ACK will indicate the coins that can be accepted.
The Poll command 0x0B response will indicate
TABLE 2 when a coin has been accepted. The Coin
The command/response formats for most devices are similar—either a command with data and an ACK
Type command 0x0C can enable and disable
returned by the slave, or a command/response by the slave and an ACK by the master.
the coin acceptor. The coin acceptor interface
includes UART1RX to receive the monetary
value of each coin accepted, 12 VDC power
regulated from the MDB interface and an
enable pin driven from one of the MCU’s I/Os.
As a spy device, command and responses
are sent at 115200 baud via UART1RX. The
data is formatted as ASCII text. The address
range of every command is used to determine
COLUMNS
PHOTO 4
The total system comprised of
the master, SPY and slave boards
BILL MAKEOVER (top to bottom) are daisy chained
Let’s take a quick look at the present with the bill validator to complete
technologies implemented in the most the system. The coin acceptor
recent US currency by the Department of the attaches to the slave board. The
Treasury’s Bureau of Engraving and Printing, MDB is monitored via SPY’s AUX
which is issued and distributed by the Federal UART output. All commands are
Reserve. Table 1 shows a chart of the security sent to the master via its AUX
precautions and on which denominations they UART connection.
COLUMNS
easy cleaning and access to the bill movement
mechanism. A magnetic head is buried on the
main unit and not easily accessed. Optical
sensors include reflective and transmissive
paths. The optical spectrum covers infrared
to ultraviolet.
Left and right alignment sensors send
information to the microprocessor on item
width. The center optic sensor informs the
microprocessor that an item has been inserted
and ready to be transported. The left and right
optic sensors perform various optical checks
on the bill. The magnetic sensor reports on any
magnetic properties of the item.
Once an item is inserted, the microcontroller
enables the movement mechanism to feed the
item back and forth across the sensors. The
MCU assembles a digital fingerprint of the item
and checks its data bank for a match to any
preloaded prints of valid currency. If no match
is made the item is rejected. A validated bill
is then advanced to the holding area where
its value can be used to purchase product
and stored or returned to the customer if the
transaction is canceled.
Like the coin acceptor discussed earlier,
the bill validator has its own set of commands
that must be recognized when connected
to the MDB. The address range for the bill
validator is 0x30-0x37. You’ll find the validator
commands in Table 2 to be similar to that of
the coin acceptor. When the bill validator is PHOTO 5
accessed via the master device, the spy device This Liberty Basic application enables each command string to be sent to the master. Responses are
shows the command/response format of the interpreted by the application and displayed in the center text box. This gives the user complete control over
bill validator as displayed using RealTerm each slave device. Once initialized, each device is polled periodically. When a device indicates it has validated
(Photo 3). The setup now consists of three receiving a coin or bill, the application increases that specific denomination and also displays a running total
boards: the master (command converter to of all currency.
70 CIRCUIT CELLAR • FEBRUARY 2018 #331
Reference [1] as marked in the article can be found there. autonomous—or even just “smart”—would
take this project beyond the bore factor for
RESOURCES some. If your input demands it, I’ll continue
Microchip Technology | www.microchip.com
this project in a later article. But next month
we’ll look at something different.
Circuit Cellar
2017 Archive
cc-webshop.com
Order yours today
circuitcellar.com 71
PRODUCT NEWS
Eurotech
www.eurotech.com
PRODUCT NEWS
Qseven Module Sports Renesas RZ/G1M Processor
iWave has announced a System-On-Module (SOM) based on Renesas RZ/G1M
embedded processor. RZ/G1M SOM is Qseven R2.0 compatible industrial grade CPU
module. Called the iW-RainboW-G20M, this SOM module supports 1 GB DDR3 RAM,
4 GB eMMC Flash and 2 MB SPI NOR Flash. Expandable memory is optional. The
module also includes on SOM Gigabit Ethernet PHY, Micro SD slot and USB HUB.
Renesas’s RZG1M processor supports dual cortex A15 core operating at
1.5 GHz core and includes 64-bit DDR3 interface at 800 MHz. The high-speed on-
chip integrated USB 3.0, PCIe, Gbit Ethernet and SATA peripherals
allows easy expansion of functionality without the need for external
components. The RZ/G1M processor supports full HD hardware
encode and decode processing up to 1,080 at 60 frames/s, dual
display and three channel video input ports. The built-in PowerVR
SGX544MP2 Graphics core at 520 MHz allows the user to develop
highly effective user interfaces.
The RZ/G1M SOM is supported Linux 3.10 LTSI with Android BSP
support to come. To enable quick prototyping of RZG1M SOM, iWave
systems supports RZ/G1M development kit with comprehensive
peripheral support. This will help engineers save up to 60% of
their new product development cycle time using the RZ-G1M MPU.
PRODUCT NEWS
Linear Technology
www.linear.com
TDK-Lambda Americas
www.us.tdk-lambda.com
circuitcellar.com 73
PRODUCT NEWS
Versalogic | www.versalogic.com
PRODUCT NEWS
Radiation-Tolerant MCU Family Meets Space Requirements
A new microcontroller that combines specified COTS device can be replaced with a pin-out compatible,
radiation performance with low-cost development radiation-tolerant version with the same functionality as
associated with Commercial Off-The-Shelf (COTS) the original device.
devices is now available from Microchip Technology.
The ATmegaS64M1 is the second 8-bit megaAVR MCU Microchip Technology | www.microchip.com
from Microchip that uses a development approach
called COTS-to-radiation-tolerant. This approach takes
a proven automotive-qualified device, the ATmega64M1
in this case, and creates pinout compatible versions in
both high-reliability plastic and space-grade ceramic
packages. The devices are designed to meet radiation
tolerances with the following targeted performances:
PRODUCT NEWS
Axiomtek
www.axiomtek.com
PRODUCT NEWS
PRODUCT NEWS
Semtech | www.semtech.com/iot
PRODUCT NEWS
Toshiba Electronic Devices & Storage has added two new need for external non-volatile memory. This also lowers
devices to its lineup of ICs that are compliant with the Bluetooth the part count, which reduces both the cost and mounting
low energy standard. The new TC35680FSG (featuring area. The TC35681FSG, which does not include a built-in
built-in flash memory) and TC35681FSG are well-suited to flash memory, operates in conjunction with an external non-
applications requiring long-range communication, including volatile memory or host processor. A wide operating range of
beacon tags, IoT devices and industrial equipment. The new -40° to +125°C makes it suitable for applications exposed to
communication ICs support the full spectrum of data rates high temperatures.
required for the high-speed features—2M PHY and Coded PHY
(500 kbps and 125 kbps)—found in the Bluetooth 5.0 standard. Toshiba Electronic Devices & Storage
The new devices also deliver an industry-leading receiver www.toshiba.semicon-storage.com
sensitivity level of -105 dBm (at 125 kbps) and a built-in high
efficiency power amplifier in the
transmission block that provides
up to +8 dBm transmission power.
Based on an ARM Cortex-M0
processor, the new ICs incorporate
a 256 KB Mask ROM to support
the Bluetooth baseband process,
and 144 KB of RAM for processing
Bluetooth baseband, stack and
data. Toshiba’s TC35680FSG and
TC35681FSG also feature 18-port
GPIOs as interfaces, which can be
set to 2 channels each for SPIs,
I2C, and UART.
The TC35680FSG includes 128
KB of flash memory for storing
user programs and various data
in stand-alone operations, making
it well-suited to a wide range of
applications and removing the
Have you
stopped by
the shop lately?
contest CDs
Circuit Cellar is always adding new items to
help with your design projects. Stop by often
books
for the latest deals.
audio
back issues
archive CDs
www.cc-webshop.com
circuitcellar.com 77
IDEA BOX
The Directory of
PRODUCTS & SERVICES
AD FORMAT:
Advertisers must furnish digital files that meet our specifications (circuitcellar.com/mediakit).
Explore SENSORS
Learn C with hands-on tools that
inspire real world applications.
SENSORS
rn
EXPLORER KIT
In
lea ed c clud
es:
edd C CoCCS
emb n a mpil
o ! & er
mcu more
pic® !
sales@ccsinfo.com
262-522-6500 x 35
www.ccsinfo.com/cc218
PIC® MCU is a registered trademark of Microchip Technology, Inc.
Answer 1—In a DLL, the input signal is fed both to the phase
comparator and to the input of the delay line. The output of
TEST YOUR EQ Contributed by David Tweed
the delay line feeds the second input of the phase comparator,
and the output of the phase comparator is filtered and used
to control the delay line. The end result is that the delay is
adjusted until it equals the period of the input signal, causing
the delayed edges of coming from the delay line to line up with period established by the delay line. A simple D flip-flop
the undelayed edges. can be used to discriminate between these two cases,
providing a direct digital copy of the original baseband
signal.
embedded wireless devices have continued to Most organizations seem keenly aware
drive miniaturization and increased computing that more data is likely going to result in
capabilities into very small form factors. Add more data-related jobs required in their
to the mix the desire for quicker installations, organizations to make sense of the data—
elimination of wires, lower cost deployments, possibly a large and ongoing expense.
quicker realization of value and expectations Ultimately, the corporate business owners are
to keep up with changing standards and the most interested in ecosystems that leverage
shift to 4G/5G seems like the perfect storm. the data for the purposes of driving action.
To further the efficiency and looking That means action towards their goals and
longer term, many embedded wireless objectives: increased efficiency, better
sensing devices may do some amount of utilization, higher throughput, increasing
data analytics in the field—thereby providing safety, improved forecasting, reducing risks,
business opportunities for managing the flow optimized logistics, predictive maintenance
and format of the data more efficiently. and many other ways to drive value to their
To realize the dream of sensors monitoring stakeholders and partners. But, data without
equipment wherever there is a chance to action is, well…just data.
improve outcomes and efficiency, not only The convergence of low cost sensors, low
do the sensor devices require a low capital cost embedded wireless devices and low-
cost, but also a low operating cost. To achieve cost communications is the perfect trifecta
both of these objectives simultaneously, the to driving sensors (across an enterprise)
ideal technology would be able to transmit into every nook and cranny of operations
great distances on low power locally while and equipment to identify opportunities for
also requiring an order of magnitude (or two improvements. Initially, many business cases
or three) less back-haul infrastructure—and may be based on optimistic expectations
ideally in an open spectrum. of results that will deliver a return in a
For many companies looking to the future, reasonable period of time. Soon however, the
Long Range low power technology (LoRa) is the devices and connections will be so ubiquitous
platform of choice upon which they are basing and easy to deploy that business owners may
their embedded designs. With the advent of speculatively place sensors in places they are
LoRaWAN there is increased interoperability, unsure if they will derive value—but use the
improved security options and an emerging data for modeling and evaluating alternatives.
public network to support untold numbers Should the creative, innovative and
of embedded wireless sensing devices at possibly lucky placement of sensors in novel
extremely low prices. If predictions are to be locations prove to be valuable it will naturally
believed, systems will emerge that require beg the question: “Where haven’t we put
only $1 of capital expense per device that is sensors that could give us even more insight?”
connected via LoRaWAN for just pennies a This is only half the story—the other half is
month. automatically using the data to control
equipment and processes throughout the
ALL ABOUT ACTIONABLE operation and supply chain. We’ll save that for
Data analysts love with the idea of another article.
TECH THE FUTURE
Brent T. Ward is responsible for business and strategy development, marketing and sales activities. He has had experience working in multiple spin-offs
and start-up’s out of RTI, RTP, and Silicon Valley. Brent holds a bachelor’s degree in electrical engineering and psychology, a master’s degree in electrical
engineering from Duke University and an MBA from Fredericton University.
Whether you are an
EMS, CM or OEM,
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.
www.PCB4u.com sales@PCB4u.com
AUTOMATED
SMART
INDUSTRIAL
INTERNET OF PRODUCTIVE THINGS
MESHED
LOW POWER
INTELLIGENT
CUSTOMIZED
LINKED
PERCEPTIVE
CONNECTED
SCRIPTED
HELPFUL
RUGGED
RELIABLE
WEARABLE
LIFE SAVING
BENEFICIAL
TS-7553-V2
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.
AL
D
EN
LI
IN
GG
@ts_embedded
G
OP
IG
N
RU
OR
LO