Important Programming Concepts (Even on Embedded Systems) Part II: Immutability
Other articles in this series:
- Part I: Idempotence
- Part III: Volatility
- Part IV: Singletons
- Part V: State Machines
- Part VI: Abstraction
This article will discuss immutability, and some of its variations in the topic of functional programming.
There are a whole series of benefits to using program variables that… well, that aren’t actually variable, but instead are immutable. The impact of...
Important Programming Concepts (Even on Embedded Systems) Part I: Idempotence
There are literally hundreds, if not thousands, of subtle concepts that contribute to high quality software design. Many of them are well-known, and can be found in books or the Internet. I’m going to highlight a few of the ones I think are important and often overlooked.
But first let’s start with a short diversion. I’m going to make a bold statement: unless you’re a novice, there’s at least one thing in computer programming about which you’ve picked up...
Someday We’ll Find It, The Kelvin Connection
You’d think it wouldn’t be too hard to measure electrical resistance accurately. And it’s really not, at least according to wikiHow.com: you just follow these easy steps:
- Choose the item whose resistance you wish to measure.
- Plug the probes into the correct test sockets.
- Turn on the multimeter.
- Select the best testing range.
- Touch the multimeter probes to the item you wish to measure.
- Set the multimeter to a high voltage range after finishing the...
10 Items of Test Equipment You Should Know
When life gets rough and a circuit board is letting you down, it’s time to turn to test equipment. The obvious ones are multimeters and oscilloscopes and power supplies. But you know about those already, right?
Here are some you may not have heard of:
Non-contact current sensors. Oscilloscope probes measure voltage. When you need to measure current, you need a different approach. Especially at high voltages, where maintaining galvanic isolation is important for safety. The usual...
Musings on Publication — and Zero Sequence Modulation
Perhaps you don’t think about it, but in order for you to read these articles, someone has to do something.
And I don’t just mean writing them. Stephane Boucher has set up this website so that it’s automatic, for the most part — at least from my end of things, as an author. When I get an idea for an article, I open up a new IPython Notebook, write my article, save it in a Mercurial repository, run a Python script to convert from IPython Notebook format to HTML, open...
How to Include MathJax Equations in SVG With Less Than 100 Lines of JavaScript!
Today’s short and tangential note is an account of how I dug myself out of Documentation Despair. I’ve been working on some block diagrams. You know, this sort of thing, to describe feedback control systems:
And I had a problem. How do I draw diagrams like this?
I don’t have Visio and I don’t like Visio. I used to like Visio. But then it got Microsofted.
I can use MATLAB and Simulink, which are great for drawing block diagrams. Normally you use them to create a...
First-Order Systems: The Happy Family
Все счастли́вые се́мьи похо́жи друг на дру́га, ка́ждая несчастли́вая семья́ несчастли́ва по-сво́ему.— Лев Николаевич Толстой, Анна Каренина
Happy families are all alike; every unhappy family is unhappy in its own way.— Lev Nicholaevich Tolstoy, Anna Karenina
I was going to write an article about second-order systems, but then realized that it would be...
Lost Secrets of the H-Bridge, Part IV: DC Link Decoupling and Why Electrolytic Capacitors Are Not Enough
Those of you who read my earlier articles about H-bridges, and followed them closely, have noticed there's some unfinished business. Well, here it is. Just so you know, I've been nervous about writing the fourth (and hopefully final) part of this series for a while. Fourth installments after a hiatus can bring bad vibes. I mean, look what it did to George Lucas: now we have Star Wars Episode I: The Phantom Menace and
April is Oscilloscope Month: In Which We Discover Agilent Offers Us a Happy Deal and a Sad Name
Last month I wrote that March is Oscilloscope Month, because Agilent had a deal on the MSOX2000 and MSOX3000 series scopes offering higher bandwidth at lower prices. I got an MSOX3034 oscilloscope and saved my company $3500! (Or rather, I didn't save them anything, but I got a 350MHz scope at a 200MHz price.)
The scope included a free 30-day trial for each of the application software modules. I used my 30-day trial for the serial decode + triggering module, to help debug some UART...
How to Analyze a Differential Amplifier
There are a handful of things that you just have to know if you do any decent amount of electronic circuit design work. One of them is a voltage divider. Another is the behavior of an RC filter. I'm not going to explain these two things or even link to a good reference on them — either you already know how they work, or you're smart enough to look it up yourself.
The handful of things also includes some others that are a little more interesting to discuss. One of them is this...
A Second Look at Slew Rate Limiters
I recently had to pick a slew rate for a current waveform, and I got this feeling of déjà vu… hadn’t I gone through this effort already? So I looked, and lo and behold, way back in 2014 I wrote an article titled Slew Rate Limiters: Nonlinear and Proud of It! where I explored the effects of two types of slew rate limiters, one feedforward and one feedback, given a particular slew rate \( R \).
Here was one figure I published at the time:
This...
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.
Modulation Alternatives for the Software Engineer
Before I get to talking about modulation, here's a brief diversion.
A long time ago -- 1993, to be precise -- I took my first course on digital electronics and processors. In that class, we had to buy a copy of the TTL Data Book* from Texas Instruments.
If you have any experience in digital logic design you probably know that TTL stands for Transistor-transistor logic (thereby making the phrase "TTL Logic" an example of RAS...
Ten Little Algorithms, Part 6: Green’s Theorem and Swept-Area Detection
Other articles in this series:
- Part 1: Russian Peasant Multiplication
- Part 2: The Single-Pole Low-Pass Filter
- Part 3: Welford's Method (And Friends)
- Part 4: Topological Sort
- Part 5: Quadratic Extremum Interpolation and Chandrupatla's Method
This article is mainly an excuse to scribble down some cryptic-looking mathematics — Don’t panic! Close your eyes and scroll down if you feel nauseous — and...
Reading and Understanding Profitability Metrics from Financial Statements
Whoa! That has got to be the most serious-minded title I’ve ever written. Profitability Metrics from Financial Statements, indeed. I’m still writing Part 2 of my Supply Chain Games article, and I was about to mention something about whether a company is profitable, when I realized something that didn’t quite fit into the flow of things, so I thought I’d handle it separately: how are you supposed to know what I mean, when I say a company is profitable? And how am I...
The CRC Wild Goose Chase: PPP Does What?!?!?!
I got a bad feeling yesterday when I had to include reference information about a 16-bit CRC in a serial protocol document I was writing. And I knew it wasn’t going to end well.
The last time I looked into CRC algorithms was about five years ago. And the time before that… sometime back in 2004 or 2005? It seems like it comes up periodically, like the seventeen-year locust or sunspots or El Niño,...
Important Programming Concepts (Even on Embedded Systems) Part III: Volatility
1vol·a·tile adjective \ˈvä-lə-təl, especially British -ˌtī(-ə)l\ : likely to change in a very sudden or extreme way : having or showing extreme or sudden changes of emotion : likely to become dangerous or out of control
— Merriam-Webster Online Dictionary
Other articles in this series:
Real-time clocks: Does anybody really know what time it is?
We recently started writing software to make use of a real-time clock IC, and found to our chagrin that the chip was missing a rather useful function, namely elapsed time in seconds since the standard epoch (January 1, 1970, midnight UTC).Let me back up a second.A real-time clock/calendar (RTC) is a micropower chip that has an oscillator on it that keeps counting time, independent of main system power. Usually this is done with a lithium battery that can power the RTC for years, so that even...
Short Takes (EE Shanty): What shall we do with a zero-ohm resistor?
In circuit board design you often need flexibility. It can cost hundreds or thousands of dollars to respin a circuit board, so I need flexibility for two main reasons:
- sometimes it's important to be able to use one circuit board design to serve more than one purpose
- risk reduction: I want to give myself the option to add in or leave out certain things when I'm not 100% sure I'll need them.
And so we have jumpers and DIP switches and zero-ohm resistors:
Jumpers and...
Margin Call: Fermi Problems, Highway Horrors, Black Swans, and Why You Should Worry About When You Should Worry
“Reports that say that something hasn’t happened are always interesting to me, because as we know, there are known knowns; there are things we know that we know. There are known unknowns; that is to say, there are things that we now know we don’t know. But there are also unknown unknowns — there are things we do not know we don’t know.” — Donald Rumsfeld, February 2002
Today’s topic is engineering margin.
XKCD had a what-if column involving Fermi...
March is Oscilloscope Month — and at Tim Scale!
I got my oscilloscope today.
Maybe that was a bit of an understatement; I'll have to resort to gratuitous typography:
I GOT MY OSCILLOSCOPE TODAY!!!!Those of you who are reading this blog may remember I made a post about two years ago about searching for the right oscilloscope for me. Since then, I changed jobs and have been getting situated in the world of applications engineering, working on motor control projects. I've been gradually working to fill in gaps in the infrastructure...
Linear Feedback Shift Registers for the Uninitiated, Part XVII: Reverse-Engineering the CRC
Last time, we continued a discussion about error detection and correction by covering Reed-Solomon encoding. I was going to move on to another topic, but then there was this post on Reddit asking how to determine unknown CRC parameters:
I am seeking to reverse engineer an 8-bit CRC. I don’t know the generator code that’s used, but can lay my hands on any number of output sequences given an input sequence.
This is something I call the “unknown oracle”...
Linear Feedback Shift Registers for the Uninitiated, Part VIII: Matrix Methods and State Recovery
Last time we looked at a dsPIC implementation of LFSR updates. Now we’re going to go back to basics and look at some matrix methods, which is the third approach to represent LFSRs that I mentioned in Part I. And we’re going to explore the problem of converting from LFSR output to LFSR state.
Matrices: Beloved Historical DregsElwyn Berlekamp’s 1966 paper Non-Binary BCH Encoding covers some work on
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...
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...
Linear Feedback Shift Registers for the Uninitiated, Part VI: Sing Along with the Berlekamp-Massey Algorithm
The last two articles were on discrete logarithms in finite fields — in practical terms, how to take the state \( S \) of an LFSR and its characteristic polynomial \( p(x) \) and figure out how many shift steps are required to go from the state 000...001 to \( S \). If we consider \( S \) as a polynomial bit vector such that \( S = x^k \bmod p(x) \), then this is equivalent to the task of figuring out \( k \) from \( S \) and \( p(x) \).
This time we’re tackling something...
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
Last time we looked at the use of LFSRs for pseudorandom number generation, or PRNG, and saw two things:
- the use of LFSR state for PRNG has undesirable serial correlation and frequency-domain properties
- the use of single bits of LFSR output has good frequency-domain properties, and its autocorrelation values are so close to zero that they are actually better than a statistically random bit stream
The unusually-good correlation properties...
Thoughts on Starting a New Career
I recently completed a 16-year stint at an engineering company. I started there fresh out of college in June 1996. This June I just started a new career as an applications engineer in the area of motor drives at Microchip Technology in Chandler, Arizona. The experience I had in switching jobs was a very enlightening one for me, and has given me an opportunity to reflect on my career. I want to share some of that reflection with you.
Disclaimer: the opinions expressed in this and other blogs...
Modulation Alternatives for the Software Engineer
Before I get to talking about modulation, here's a brief diversion.
A long time ago -- 1993, to be precise -- I took my first course on digital electronics and processors. In that class, we had to buy a copy of the TTL Data Book* from Texas Instruments.
If you have any experience in digital logic design you probably know that TTL stands for Transistor-transistor logic (thereby making the phrase "TTL Logic" an example of RAS...