Embedded Notes

Key notes from The Art of Designing Embedded Systems.

Partition projects into as many small, independent pieces as possible to maximize efficiency and reliability. This can mean adding subprocessors to handle smaller tasks.

More people on a team is not better. Higher performing coders perform better on smaller, not larger, tasks.

Code inspections and careful design are more reliable than testing and debugging. Specs are key.
Design with the aid of high level goals, objectives, assumptions (“contracts”) for each function, such as this parameter must not be zero, the result must be smaller than x, this peripheral must be enabled, etc.

Real time tasks must finish before some deadline. Instrument the code with I/O’s that can be measured on an oscilloscope to see margin. Higher loaded processors imply significantly higher effort.

Interrupts and asynchronous code are very dangerous. Hardware based interrupts are typically asynchronous. All code must be re-entrant, where all used data including hardware manipulations are “atomic”, meaning the operation cannot be interrupted and modified by other code.

Be aware of EMI and SI.

Debounce switches in HW or SW. HW debounce requires Schmitt trigger input logic. SW debounce should poll and make sure x number of consecutive values are equal (shift register). For “instant” response to user input, react within 50 to 100 ms.

Developers are most effective when not interrupted, above even experience or skill level.

Use a version control system, use a firmware design standard, do code inspections, create quiet environment for thinking, measure bug and production rates, constantly try to study and improve.

Mechanical Equivalent Circuits


Differential equations are the heart of a vast array of engineering theory, and as such, one can create models of entirely different branches of physics by using circuit theory.

The usefulness of this concept here is that electronics engineers can gain insight into mechanical systems by using their circuit knowledge. They can also use standard electronics tools like SPICE to incorporate mechanical outputs, such as motors or temperature rise.
In the recent past, this was useful for designing analog computers to solve mechanical problems.

Electrical Fundamentals

The fundamental electrical components are resistors, capacitors and inductors.
Their voltage-current relationships are:
$$v(t) = i(t)R$$
$$i(t) = C \frac{dv}{dt}$$
$$v(t) = L \frac{di}{dt}$$

Mechanical Dynamics Fundamentals

The key equations of motion are Newton’s laws, the main one being:
$$F(t) = ma(t) = m\frac{dv}{dt}$$
In a rotational system, we have:
$$M(t) = I\frac{dw}{dt}$$

Thermal Fundamentals

The steady state thermal equation is:
$$T = P\theta + T_{env}$$

Dynamically there is Newton’s law of cooling:
$$\frac{dT}{dT} = \frac{T_{env} – T}{t_0}$$

Steady State Circuit

The steady state temperature rise equation is identical to the solution of a DC resistor circuit.

The equivalents are:
Voltage (V) = temperature (°C)
Current (A) = power (W)
Resistance ($$\Omega$$) = thermal resistance (°C/W)

The solution is then very intuitive:
Temperature rise is caused by heat flow through a non-zero thermal resistance, exactly how voltage difference is caused by current flow through non-zero electrical resistance.

The power is a current source, the resistance a resistor, and the ambient temperature is the reference voltage. The resulting voltage at the current source is the new temperature of the device.

Typically a component datasheet will provide a $$\theta_{j-a}$$ which is the thermal resistance from thr component junction (j) to the ambient (a) environment. This can easily be added to a SPICE simulation.

Dynamic Circuit

Having established thr equivalence above, we can choose an electrical element to represent the thermal time constant.

Since temperature is similar to voltage and the thermal time constant slows it down, a capacitor is the appropriate electrical element (inductors slow down current).

A capacitor added in parallel to the current source results in an equation identical to Newton’s law of cooling:
$$i_c(t) = C \frac{dv}{dt}$$
$$i_c(t)R = RC \frac{dv}{dt}$$
$$v(t) = RC \frac{dv}{dt}$$
$$\frac{dv}{dt} = \frac{v_c(t) – v_{ref}}{RC}$$
$$\frac{dT}{dt} = \frac{T(t) – T_{env}}{t_0}$$
Therefore, the thermal time constant is equivalent to RC, which is the familiar electrical time constant.

Wire Sizing

Selection of Wire

There are several factors in sizing wire.

Temperature Rise

Maximum operating temperature of insulation must be respected.

Ambient temperature + Temperature rise < Max temperature

Temperature rise depends on current and \(I^2R\) losses.

Voltage Drop

Voltage drop is key for power distribution but also for signals when using fine gauge wire.

Voltage drop is \(IR\)