Ten Little Algorithms, Part 7: Continued Fraction Approximation
In this article we explore the use of continued fractions to approximate any particular real number, with practical applications.
Embedded Developer’s New Year’s Resolution
As we reach the end of another year, while wrapping up this one, we also contemplate the year ahead. Though nothing major might change on the 1st of January, it’s nice to pause during the holidays to reflect on the past and plan for future improvements.
I like to plan my professional improvements, and I always include them in my New Year’s resolution. Here are some ideas that I’d like to share.
Good Software Design PracticesYes, we Embedded developers love...
Remember Y2K?
There was fear that the turn of the century at the end of 1999 would cause problems with many embedded systems. There is evidence that the same issue may occur in 2038.
Getting Started With Zephyr: Writing Data to EEPROM
In this blog post, I show how to implement a Zephyr application to interact with EEPROM. I show how the Zephyr device driver model allows application writers to be free of the underlying implementation details. Unfortunately, the application didn't work as expected, and I'm still troubleshooting the cause.
My TDD Journey Started Dec 6, 1999
My story of learning Test-Driven Development started 23 years ago today. TDD has helped me exercise my code well before there is target hardware to run on. TDD helps me prevent defects. It can help you too.
More than just a pretty face - a good UI is essential
A user interface can make or break a device - determining its success in the marketplace. With careful design, the UI can make the product compelling and result in a high level of satisfaction from new and experienced users.
Getting Started with NuttX RTOS on Three Low Cost Boards
If you are an embedded system developer chances are you already played with Linux on some embedded board and saw how it is powerful, right?
So, I have a good news: you can have same power using NuttX on some ultra low cost board powered by a microcontroller instead of microprocessor (that normally is way more expansive).
In fact many companies already realized it before me. It explains why NuttX is the kernel used by many IoT frameworks:
Another great news is that few days ago...
Elliptic Curve Cryptography - Multiple Signatures
The use of point pairing becomes very useful when many people are required to sign one document. This is typical in a contract situation when several people are agreeing to a set of requirements. If we used the method described in the blog on signatures, each person would sign the document, and then the verification process would require checking every single signature. By using pairings, only one check needs to be performed. The only requirement is the ability to verify the...
Lightweight C++ Error-Codes Handling
The traditional C++ approach to error handling tends to distinguish the happy path from the unhappy path. This makes handling errors hard (or at least boring) to write and hard to read. In this post, I present a technique based on chaining operations that merges the happy and the unhappy paths. Thanks to C++ template and inlining the proposed technique is lightweight and can be used proficiently for embedded software.
Flood Fill, or: The Joy of Resource Constraints
When transferred from the PC world to a microcontroller, a famous, tried-and-true graphics algorithm is no longer viable. The challenge of creating an alternative under severe resource constraints is an intriguing puzzle, the kind that keeps embedded development fun and interesting.
Digital PLL's -- Part 2
In Part 1, we found the time response of a 2nd order PLL with a proportional + integral (lead-lag) loop filter. Now let’s look at this PLL in the Z-domain [1, 2]. We will find that the response is characterized by a loop natural frequency ωn and damping coefficient ζ.
Having a Z-domain model of the DPLL will allow us to do three things:
Compute the values of loop filter proportional gain KL and integrator gain KI that give the desired loop natural...How to Build a Fixed-Point PI Controller That Just Works: Part I
This two-part article explains five tips to make a fixed-point PI controller work well. I am not going to talk about loop tuning -- there are hundreds of articles and books about that; any control-systems course will go over loop tuning enough to help you understand the fundamentals. There will always be some differences for each system you have to control, but the goals are the same: drive the average error to zero, keep the system stable, and maximize performance (keep overshoot and delay...
Ten Little Algorithms, Part 3: Welford's Method (and Friends)
Other articles in this series:
- Part 1: Russian Peasant Multiplication
- Part 2: The Single-Pole Low-Pass Filter
- Part 4: Topological Sort
- Part 5: Quadratic Extremum Interpolation and Chandrupatla's Method
- Part 6: Green’s Theorem and Swept-Area Detection
Last time we talked about a low-pass filter, and we saw that a one-line...
MSP430 Launchpad Tutorial - Part 1 - Basics
TI's LaunchPad is a complete MSP430 development environment: all you have to do is download and install CCS IDE (login required), connect your G2231-ready LaunchPad to your computer with the included mini-usb cable, and you are ready to code!
Texas Instrument MSP430 LaunchPadSo, let's see how to start a new project in Code Composer Studio. This IDE is derived from Eclipse, so if you used it before you shouldn't have much problems.
We'll write a simple program that will...
Endianness and Serial Communication
Endianness is a consideration that is easily overlooked in the design of embedded systems. I myself am amply guilty of this oversight. It’s something you don’t ever have to worry about if you’re only working with a single processor or two processors that have the same endianness. You can even avoid it if you have two processors that have different endianness but never transmit data between themselves that consists of more than one byte. It’s easy to lull...
Free Goodies from Embedded World - What to Do Next?
I told you I would go on a hunt for free stuff at Embedded World in order to build a bundle for someone to win.
How to use analog input (ADC) on NuttX RTOS
In all previous tutorial about NuttX we used some type of digital interface (I2C, SPI, etc), so today we will see how to use an analog interface to read some analog sensor or other analog device. In fact we live in an analog world and sometimes we need to read some analog voltage to make sense of some external analog signal. Today we will see how to use the ADC (Analog Digital Converter) from Raspberry Pi Pico RP2040 to read analog voltages.
First let me explain what...
++i and i++ : what’s the difference?
Although the ++ and -- operators are well known, there are facets of their operation and implementation that are less familiar to many developers.
Round Round Get Around: Why Fixed-Point Right-Shifts Are Just Fine
Today’s topic is rounding in embedded systems, or more specifically, why you don’t need to worry about it in many cases.
One of the issues faced in computer arithmetic is that exact arithmetic requires an ever-increasing bit length to avoid overflow. Adding or subtracting two 16-bit integers produces a 17-bit result; multiplying two 16-bit integers produces a 32-bit result. In fixed-point arithmetic we typically multiply and shift right; for example, if we wanted to multiply some...
MSP430 LaunchPad Tutorial - Part 4 - UART Transmission
Today we are going to learn how to communicate using UART with the Launchpad. For this purpose I will replace the default microcontroller that comes with the board with the MSP430G2553. It is the most powerful device in the MSP430 Value Line and it comes with an integrated hardware UART module, along with 16 Kb of Flash memory, 512 bytes of SRAM and an 8-channel, 10 bit ADC.
UART communication can be useful when dealing with sensors: as a basic example, we could...
Cortex-M Exception Handling (Part 1)
This article describes how Cortex-M processors handle interrupts and, more generally, exceptions, a concept that plays a central role in the design and implementation of most embedded systems.
Introduction to Microcontrollers - 7-segment displays & Multiplexing
Doing the 7 Segment ShuffleThe 7 segment display is ubiquitous in the modern world. Just about every digital clock, calculator and movie bomb has one. The treadmills at my gym have 6 or 7, each one displaying 3 or 4 digits. What makes the 7-seg interesting is that it presents an opportunity to make a trade off between GPIO (output pins) for time. Every 7-seg display requires 8 outputs (the 7 segments and usually either a decimal point or a...
Important Programming Concepts (Even on Embedded Systems) Part IV: Singletons
Other articles in this series:
- Part I: Idempotence
- Part II: Immutability
- Part III: Volatility
- Part V: State Machines
- Part VI: Abstraction
Today’s topic is the singleton. This article is unique (pun intended) in that unlike the others in this series, I tried to figure out a word to use that would be a positive concept to encourage, as an alternative to singletons, but
Linear Feedback Shift Registers for the Uninitiated, Part I: Ex-Pralite Monks and Finite Fields
Later there will be, I hope, some people who will find it to their advantage to decipher all this mess.
— Évariste Galois, May 29, 1832
I was going to call this short series of articles “LFSRs for Dummies”, but thought better of it. What is a linear feedback shift register? If you want the short answer, the Wikipedia article is a decent introduction. But these articles are aimed at those of you who want a little bit deeper mathematical...
R1C1R2C2: The Two-Pole Passive RC Filter
I keep running into this circuit every year or two, and need to do the same old calculations, which are kind of tiring. So I figured I’d just write up an article and then I can look it up the next time.
This is a two-pole passive RC filter. Doesn’t work as well as an LC filter or an active filter, but it is cheap. We’re going to find out a couple of things about its transfer function.
First let’s find out the transfer function of this circuit:
Not very...
Visual Studio Code Extensions for Embedded Software Development
Visual Studio Code has become one of the most popular IDEs in the world. To date, software developers have downloaded it more than 40 million times! I suspect you’ve at least heard of it, if not already attempting to use it. Visual Studio Code allows developers to easily customize their development environment which can help them accelerate development, minimize bugs, and make developing software overall much better.
One challenge with Visual Studio Code is that embedded software...
Lost Secrets of the H-Bridge, Part I: Ripple Current in Inductive Loads
So you think you know about H-bridges? They're something I mentioned in my last post about signal processing with Python.
Here we have a typical H-bridge with an inductive load. (Mmmmm ahhh! It's good to draw by hand every once in a while!) There are four power switches: QAH and QAL connecting node A to the DC link, and QBH and QBL connecting node B to the DC link. The load is connected between nodes A and B, and here is represented by an inductive load in series with something else. We...
Lost Secrets of the H-Bridge, Part III: Practical Issues of Inductor and Capacitor Ripple Current
We've been analyzing the ripple current in an H-bridge, both in an inductive load and the DC link capacitor. Here's a really quick recap; if you want to get into more details, go back and read part I and part II until you've got equations coming out of your ears. I promise there will be a lot less grungy math in this post. So let's get most of it out of the way:
Switches QAH and QAL are being turned on and off with pulse-width modulation (PWM), to produce an average voltage DaVdc on...
VHDL tutorial - A practical example - part 1 - Hardware
In previous posts I described some simple VHDL examples. This time let's try something a little more complex. This is part one of a multiple part article. This is intended to be a detailed description of one of several initial designs that I developed for a client. This design never made it into a product, but a similar design was used and is currently being produced. As a considerable amount of work was put into this effort, I decided to share this design...
Introduction to Microcontrollers - More On Interrupts
A Little More Detail About The Interrupt MechanismIt's time to look a little closer at what happens in an interrupt request and response. Again this is in general terms, and different microcontroller designs may do things somewhat differently, but the basics remain the same. Most but not all interrupt requests are latched, which means the interrupt event sets a flag that stays set even if the interrupt event then goes away. It is this latched flag...