Important Programming Concepts (Even on Embedded Systems) Part VI : Abstraction
Abstraction is essential, but it is not free. Jason Sachs walks through the many faces of abstraction—pattern recognition, generalization, simplification, and indirection—and shows how each helps and hurts real projects. Using examples from math, API design, UI toolkits, schematics, and embedded C, he gives practical context so firmware engineers can apply abstractions without causing maintenance or debugging headaches.
Ten Little Algorithms, Part 3: Welford's Method (and Friends)
Jason Sachs takes a practical look at Welford's method, a numerically stable online algorithm for computing mean and sample variance without storing large batches. He demonstrates Python implementations, shows why the naive sum and sum-of-squares approach suffers catastrophic cancellation, and why Welford is a better fit for memory- and CPU-constrained embedded systems. Jason then turns Welford into simple filters for tracking time-varying noise and discusses heuristic fixes and tradeoffs.
Python Code from My Articles Now Online in IPython Notebooks
Jason M. Sachs has published the Python code from his EmbeddedRelated articles as standalone IPython notebooks. He automated extraction of example code and pushed the notebooks to a public Bitbucket repository under the Apache license, and they are viewable via nbviewer. The post lists available notebooks and asks readers to link back to EmbeddedRelated and share feedback on how they used the code.
Ten Little Algorithms, Part 2: The Single-Pole Low-Pass Filter
Jason Sachs shows how a single-pole IIR low-pass filter, implementable in one line y += alpha * (x - y), tames noise in embedded signals without floating point. The post explains how to compute alpha from tau and delta-t, practical tradeoffs like phase lag and oversampling, and fixed-point pitfalls including how many extra state bits you need to avoid quantization. Short, practical, and code-ready.
Ten Little Algorithms, Part 1: Russian Peasant Multiplication
Jason Sachs revisits a centuries-old multiplication trick and shows why it still matters. He lays out Russian Peasant Multiplication with simple Python code, then reveals how the same shift-and-add pattern maps to GF(2) polynomial arithmetic and to exponentiation by squaring. The post mixes historical context with practical bitwise techniques that are useful for embedded and low-level math work.
Two Capacitors Are Better Than One
Jason Sachs revisits a simple stacked RC trick that dramatically reduces DC error from capacitor insulation leakage in long time-constant filters. Splitting one RC into two stages forces most of the DC drop onto the lower capacitor, squaring the remaining error while changing the effective pole locations. The post walks through the math, practical component tradeoffs, and when to prefer a digital approach.
My Love-Hate Relationship with Stack Overflow: Arthur S., Arthur T., and the Soup Nazi
Jason Sachs traces his decade-long relationship with Stack Overflow, celebrating its fast answers, polished UI, and massive searchable archive while calling out a growing culture of harsh moderation. He argues strict, quality-first closures and inflexible automation often alienate newcomers and block helpful short-term answers. The post urges kinder handling of gray-area questions and smarter automation to keep the site useful and welcoming.
Voltage Drops Are Falling on My Head: Operating Points, Linearization, Temperature Coefficients, and Thermal Runaway
Today’s topic was originally going to be called “Small Changes Caused by Various Things”, because I couldn’t think of a better title. Then I changed the title. This one’s not much better, though. Sorry.
What I had in mind was the Shockley diode equation and some other vaguely related subjects.
My Teachers Lied to MeMy introductory circuits class in college included a section about diodes and transistors.
The ideal diode equation is...
Important Programming Concepts (Even on Embedded Systems) Part V: State Machines
State machines are not glamorous, but they solve a lot of real embedded problems. Jason Sachs uses a motorized couch example to show how FSMs and Harel statecharts expose corner cases, simplify timing constraints, and make behavior easier to specify and review. The article walks through hand-rolled switches, tabular implementations, the state pattern, libraries like QP and Boost, and tool tradeoffs.
Optimizing Optoisolators, and Other Stories of Making Do With Less
Jason Sachs digs into how to squeeze speed and reliability from low-cost optoisolators, showing practical tweaks that often outperform default datasheet usage. He mixes hands-on circuits — using 4N35 base-emitter resistors, Schottky clamps, input speedup caps, and output buffering — with transistor-switching theory and a cautionary production story to show when to optimize and when to splurge on pricier isolators.
Linear Feedback Shift Registers for the Uninitiated, Part XI: Pseudorandom Number Generation
Jason Sachs breaks down when linear feedback shift registers make good pseudorandom sources and when they fail. He shows why LFSR output bits look very different from full-state integer samples, explains their two-valued autocorrelation and quasi-random behavior, and gives practical guidance on when an LFSR is acceptable for fast hardware bit generation and when you should use a proper PRNG instead.
The Least Interesting Circuit in the World
Jason Sachs pulls apart the humble power-on reset and shows why the common RC-and-Schmitt trick is the least interesting but most dangerous circuit in your design. He walks through voltage thresholds, brown-out reset behavior, and how slow or noisy Vdd ramps can let parts start in indeterminate states. Read this for practical rules on choosing supervisors, comparators, and reset pulse timing to ensure reliable embedded startup.
Scorchers, Part 3: Bare-Metal Concurrency With Double-Buffering and the Revolving Fireplace
Jason Sachs presents a practical, low-overhead concurrency pattern for tiny bare-metal systems where an ISR (Speedy) must safely exchange data with a nonreal-time main loop (Poky). He describes the "revolving fireplace", a double-buffering variant that swaps ownership of two shared memory regions, and walks through C examples, atomic/volatile considerations, and testing strategies so you can implement it on RAM-constrained MCUs.
Slew Rate Limiters: Nonlinear and Proud of It!
Slew-rate limits are a small nonlinear detail that often decides whether a controller behaves nicely or wrecks hardware. Jason Sachs walks through why slew limits appear in electronics and actuators, then shows two practical digital ways to impose limits: constraining input increments and constraining input around the output. He compares performance on underdamped second-order systems, gives closed-form intuition for overshoot, and demonstrates simulations with scipy and ODE solvers.
Wye Delta Tee Pi: Observations on Three-Terminal Networks
Three-terminal passive networks, wye, delta, tee, and pi, are more interchangeable than many engineers expect. Jason Sachs walks through Kennelly's wye-delta formulas, Z and Y matrix representations for tee and pi two-port networks, and worked examples ranging from balanced to highly skewed impedances. The post highlights practical payoffs, including using topology transforms to substitute hard-to-source capacitors with simpler, precision-friendly parts.
Real-time clocks: Does anybody really know what time it is?
Most RTC chips still expose calendar fields rather than seconds-since-epoch, forcing embedded engineers to write ugly conversion code. Jason Sachs makes the case for offset encoding, subseconds, and an explicit snapshot feature to simplify interval math, raise precision, and avoid rare timing bugs. Read this practical take on RTC trade-offs and a short wishlist for chip makers.
Linear Feedback Shift Registers for the Uninitiated, Part XII: Spread-Spectrum Fundamentals
Jason Sachs shows why LFSR-generated pseudonoise is a natural fit for direct-sequence spread spectrum, then walks through Fourier basics, spectral plots, and runnable Python examples. The article demonstrates how DSSS multiplies a UART bitstream with a chipping sequence to spread energy, how despreading concentrates the desired signal while scrambling narrowband interference, and how multiple transmitters can share bandwidth when using uncorrelated sequences.
Linear Feedback Shift Registers for the Uninitiated, Part VIII: Matrix Methods and State Recovery
Matrix methods for LFSRs look intimidating, but Jason Sachs walks through companion-matrix representations and shows why they matter for time shifts and state recovery. He derives lookahead masks from powers of the companion matrix, then translates those matrix insights into efficient bitwise and finite-field algorithms. The article includes two simple state-recovery methods and working Python/libgf2 examples you can run and adapt.
Optimizing Optoisolators, and Other Stories of Making Do With Less
Jason Sachs digs into how to squeeze speed and reliability from low-cost optoisolators, showing practical tweaks that often outperform default datasheet usage. He mixes hands-on circuits — using 4N35 base-emitter resistors, Schottky clamps, input speedup caps, and output buffering — with transistor-switching theory and a cautionary production story to show when to optimize and when to splurge on pricier isolators.
Have You Ever Seen an Ideal Op-Amp?
Forget the ideal op-amp fantasy, Jason Sachs walks through the practical nonidealities that make textbook gain formulas fail in real circuits. Using the uA741C and TLC081C as examples, he explains offset voltage, input bias and offset currents, common-mode and supply rejection, gain-bandwidth and slew-rate limits, plus capacitive loading, RF rectification and overload recovery. Read to learn which datasheet specs matter and why.
Oscilloscope review: Hameg HMO2024
Jason Sachs tests the Hameg HMO2024, a 200MHz 4-channel mixed-signal oscilloscope that promises Agilent-like features at a lower price. He finds strong analog noise performance, useful hi-res and zoom modes, and inexpensive serial-decode options, but warns of clumsy digital-input handling, awkward data-transfer software, and missing per-channel thresholds and Ethernet waveform export. The review helps budget-conscious embedded engineers weigh the trade-offs.
How to Analyze a Differential Amplifier
Jason Sachs walks through the algebra and intuition behind the classic four-resistor differential amplifier. He derives the exact output equation, isolates error terms from resistor mismatch and op-amp imperfections, and explains why common-mode gain depends on mismatch not on the differential gain. Read this for clear formulas, modal insight into common-mode versus differential-mode, and practical steps to reduce offsets in real designs.
Have You Ever Seen an Ideal Op-Amp?
Forget the ideal op-amp fantasy, Jason Sachs walks through the practical nonidealities that make textbook gain formulas fail in real circuits. Using the uA741C and TLC081C as examples, he explains offset voltage, input bias and offset currents, common-mode and supply rejection, gain-bandwidth and slew-rate limits, plus capacitive loading, RF rectification and overload recovery. Read to learn which datasheet specs matter and why.
Jaywalking Around the Compiler
Messing with inline assembly can feel powerful until the compiler silently undoes you. Jason Sachs walks through a real bug on a Microchip dsPIC33E where pushing CORCON and writing a fixed value corrupts compiler-managed state and produces wrong results when the compiler reorders code. The post shows why the stack and certain registers are off-limits to raw inline asm, and gives practical, safe patterns to save and restore mode bits.
Linear Feedback Shift Registers for the Uninitiated, Part XIV: Gold Codes
Last time we looked at some techniques using LFSR output for system identification, making use of the peculiar autocorrelation properties of pseudorandom bit sequences (PRBS) derived from an LFSR.
This time we’re going to jump back to the field of communications, to look at an invention called Gold codes and why a single maximum-length PRBS isn’t enough to save the world using spread-spectrum technology. We have to cover two little side discussions before we can get into Gold...
Isolated Sigma-Delta Modulators, Rah Rah Rah!
Analog isolation can blow up DAQ budgets, but isolated sigma-delta modulators let you send a single 1-bit stream and a clock across the barrier, keeping costs down. Jason walks through Avago, TI, and Analog Devices parts, explains sigma-delta noise shaping in plain terms, and calls out the real engineering work: converting a 10–20 MHz bitstream into usable samples with sinc/CIC decimators or FPGA filtering.
Linear Feedback Shift Registers for the Uninitiated, Part XV: Error Detection and Correction
Last time, we talked about Gold codes, a specially-constructed set of pseudorandom bit sequences (PRBS) with low mutual cross-correlation, which are used in many spread-spectrum communications systems, including the Global Positioning System.
This time we are wading into the field of error detection and correction, in particular CRCs and Hamming codes.
Ernie, You Have a Banana in Your EarI have had a really really tough time writing this article. I like the...
Linear Feedback Shift Registers for the Uninitiated, Part XII: Spread-Spectrum Fundamentals
Jason Sachs shows why LFSR-generated pseudonoise is a natural fit for direct-sequence spread spectrum, then walks through Fourier basics, spectral plots, and runnable Python examples. The article demonstrates how DSSS multiplies a UART bitstream with a chipping sequence to spread energy, how despreading concentrates the desired signal while scrambling narrowband interference, and how multiple transmitters can share bandwidth when using uncorrelated sequences.
Linear Feedback Shift Registers for the Uninitiated, Part XVII: Reverse-Engineering the CRC
Jason Sachs shows how to pry CRC parameters out of a black-box oracle and reimplement the checksum yourself. By canceling the affine offsets, probing single-bit basis messages, and treating per-bit outputs as LFSR sequences, you can recover the generator polynomial, bit and byte order, and init/final XOR values. The post includes working Python code, a 4-message shortcut, and real-world tests such as zlib CRC32.
Linear Feedback Shift Registers for the Uninitiated, Part VI: Sing Along with the Berlekamp-Massey Algorithm
Jason Sachs breaks down the Berlekamp-Massey algorithm and shows how to recover an LFSR's minimal connection polynomial from a stream of output bits. The article mixes intuition, worked examples, and Python code to demonstrate the update rule, visual debugging tables, and when the solution is unique. Expect practical implementation notes, a complexity discussion, and a libgf2 example you can run in an IPython notebook.







