Electronics notes / Inputs and outputs

From Helpful
(Redirected from Snap-back)
Jump to navigation Jump to search
This is for beginners and very much by a beginner / hobbyist.

It's intended to get an intuitive overview for hobbyist needs. It may get you started, but to be able to do anything remotely clever, follow a proper course or read a good book.

Some basics and reference: Volts, amps, energy, power · batteries · resistors · transistors · fuses · diodes · capacitors · inductors and transformers · ground

Slightly less basic: amplifier notes · varistors · changing voltage · baluns · frequency generation · Transmission lines · skin effect

And some more applied stuff:

IO: Input and output pins · wired local IO · wired local-ish IO · ·  Various wireless · 802.11 (WiFi) · cell phone

Sensors: General sensor notes, voltage and current sensing · Knobs and dials · Pressure sensing · Temperature sensing · humidity sensing · Light sensing · Movement sensing · Capacitive sensing · Touch screen notes

Actuators: General actuator notes, circuit protection · Motors and servos · Solenoids

Noise stuff: Stray signals and noise · sound-related noise names · electronic non-coupled noise names · electronic coupled noise · ground loop · strategies to avoid coupled noise · Sampling, reproduction, and transmission distortions

Audio notes: See avnotes

Platform specific

Arduino and AVR notes · (Ethernet)
Microcontroller and computer platforms ··· ESP series notes · STM32 series notes

Less sorted: Ground · device voltage and impedance (+ audio-specific) · electricity and humans · power supply considerations · Common terms, useful basics, soldering · landline phones · pulse modulation · signal reflection · Project boxes · resource metering · SDR · PLL · vacuum tubes · Multimeter notes Unsorted stuff

Some stuff I've messed with: Avrusb500v2 · GPS · Hilo GPRS · JY-MCU · DMX · Thermal printer ·

See also Category:Electronics.

High side versus low side switching / driving / sensing

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

Some limits and choices

High versus low side sensing


Transistor output stages

Open-drain / open-collector

This article/section is a stub — probably a pile of half-sorted notes and is probably a first version, is not well-checked, so may have incorrect bits. (Feel free to ignore, or tell me)

Common collector / Common drain

Totem-pole, push-pull

Other details

Transient voltage and ESD protection, snubbers

Protection diodes (inputs and output pins)

TVS diodes


RC and RCD snubbers


Gas Discharge Tubes




See also (transients)

On ADCs and DACs


An Analog-Digital Converter (ADC) takes a voltage signal, and turns it into numbers to be consumed digitally.

Well, most ADCs do voltage sensing. A few have extra circuitry to be current-input ADCs (which mostly just means a resistor setup, but probably better specced than you can easily make), many of them for specific applications.

On quantization

Fluctuating readings


A Digital-Analog Converter (DAC) takes numbers and turn them into voltages.

What do DACs speak

Multiplying DAC (type)

Upsampling DACs

On the cheap: Resistor ladder

Basic idea: If you can change many (e.g. often 8 on microcontrollers) digital pins at the same time, then putting a resistor ladder on them means each contributes a different voltage level, and you can make 2amt voltage levels (256 for 8 pins).

E.g. the Covox Speech Thing was basically just a bunch of resistors on a parallel port. adopted by some games and music trackers.


  • you still need to write out new data with strict regularity
which is what interrupts are good at, but this will occupy a bunch of CPU power
The Disney Sound Source solved this by being buffered (but fixed the output rate to a relatively poor 7kHz)
  • the resistors' voltage contribution won't be perfect to contribute exactly what they should.
making equal steps (to produce undistorted signals) takes either precision resistors or a bunch of measuring and matching beforehand.
the more bits you have, the harder it gets - 8 is quite doable, but it starts getting impractical around 12 bits
  • more than 8 bit is rare
it's often the max you can change at the same time (single uC port)
using multiple ports is hard to get quite right, though may be acceptable at lower frequencies


On the cheap (if your IC happens to have it): Oversampling fast PWM

Basic idea: If we can PWM much faster than the signal's rate, and lowpass the result to the signal's rate.

The lowpassed duty cycle can then be an average stable and close enough to the intended signal. Oversampling PWM makes its output more linear and less noisy (lessening requirement to any filtering), and preferably we want two orders of magnitude faster, order of ~1MHz for a 20kHz signal.

That speed basically requires dedicated PWM circuitry in the IC.


  • if you don't have very fast PWM, the net result is high noise
  • the lowpass is probably fixed
so it has a range where it works best, which is part of your design
which is why this can't be a more general-purpose DDS
  • without dedicated PWM circuitry the timing issues would make this impossible for audio rate, particularly if you also want to do anything else in the microcontroller
  • even if the PWM output is regular due to dedicated hardware, we also need to update the sample to put out with strict regularity
this is what interrupts are good at. It just occupies the CPU.
you'ld really prefer a small buffer, so that you don't need interrupts to be at at audio rate (if it is, expect everything else to be secondary to this). At this point, you're starting to describe a dedicated DAC
  • multiple channels may be possible, but how easy this is varies with IC
this might actually help you e.g. produce different types of wave at the same rate


  • Raspberry Pi's onboard sound is actually dedicated PWM pins, at 50MHz(verify), plus a filter and buffer (exact details vary)

DAC practicalities

Some simple ADCs and DACs for DIY

See Some simple ADCs and DACs

See also

Digital sample capture, storage, reproduction