Lessons and the learning game

Interfacing and level shifting

An intermediate course on getting a 3.3 V microcontroller to talk to 5 V logic and to switch 12 V loads safely, ending in a 12 V panel run from an ESP32-C3.

What the course covers

Interfacing and level shifting is seven lessons, one chapter each, with a quiz after every chapter:

  1. 3.3 V meets 5 V: logic thresholds, a sagging high, an HCT part, a divider, and the clamp diode a bare 5 V signal pushes current through.
  2. Level shifters: the BSS138 bidirectional shifter both ways, and one-way buffers up (74HCT125) and down (CD4050).
  3. Transistor drivers: an NPN with the right base resistor, a MOSFET that is not logic level against one that is, and a high-side P-MOSFET.
  4. ULN2803A: eight Darlington sinks, their drop, the COM pin's flyback diodes, and the input threshold.
  5. Optocouplers: LED current, current transfer ratio, and the pull-up.
  6. Isolation: a 24 V field input into 3.3 V logic, and grounds that disagree.
  7. Boss: a 12 V panel from 3.3 V: an ESP32-C3 running the panel12v sketch switches lamps and a solenoid lock and reads an isolated door switch as an interlock.

What the simulation is and is not

  • In lessons 1 to 6 a 3.3 V pin is a 3.3 V source behind a switch, which is all a pin is to the circuit it drives.
  • The simulated 74HC04 switches at half its supply; the datasheet only guarantees a high above 70 percent of it, and the lesson says so.
  • The level shifter is built from a BSS138 and two pull-ups, which is what the breakout board is.
  • Isolation is modeled electrically only: a real part's isolation rating comes from its datasheet and the board layout.

Relays and motor control, Protection circuits, and the buses course, Talk to chips.