Electronics notes / Inputs and outputs: Difference between revisions
m (→Buffers) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{#addbodyclass:tag_tech}} | |||
{{Electronics notes}} | {{Electronics notes}} | ||
<!-- | <!-- | ||
Line 167: | Line 168: | ||
===High versus low side sensing=== | |||
==Buffers== | ==Buffers== | ||
Line 706: | Line 707: | ||
<!-- | <!-- | ||
Successive Approximation Register (SAR) ADC | Successive Approximation Register (SAR) ADC | ||
: high speed | : high speed | ||
Line 715: | Line 715: | ||
: higher dynamic range | : higher dynamic range | ||
: better linearity, but higher noise | : better linearity, but higher noise | ||
--> | --> | ||
Line 778: | Line 774: | ||
https://en.wikipedia.org/wiki/Signal-to-quantization-noise_ratio | https://en.wikipedia.org/wiki/Signal-to-quantization-noise_ratio | ||
TODO: figure out "Quantization noise's pdf is a zero mean gaussian with a width proportional to the amount of bits". | TODO: figure out "Quantization noise's pdf is a zero mean gaussian with a width proportional to the amount of bits". | ||
--> | --> | ||
==== | ====When ADC values fluctuate==== | ||
<!-- | <!-- | ||
* some signals are themselves skittish | |||
: if putting an RC filter on the signal itself helps, then it was probably the signal itself (or something coupled on) that was noisy. | |||
: and you can always supersample (do more samples and average/filter) a little for a smoother average. Won't help a lot, but it helps. | |||
* consider the reference voltage | |||
: when ''output = range * (sample voltage / reference voltage )'' | |||
: ...which isn't relevant until that reference voltage is configurable and exposed | |||
: e.g. Arduinos | |||
:: can use an internal 1.1V reference | |||
:: by default use the pwoer rail | |||
:: can use an external AREF pin | |||
:: the last two might be less clean than they could be due to things around it | |||
(if successive approximation ADCs, does the capacitive switching mean that an input buffer may be a good idea?) | (if successive approximation ADCs, does the capacitive switching mean that an input buffer may be a good idea?) | ||
https://www.analog.com/en/analog-dialogue/articles/precision-successive-approximation-adcs.html | https://www.analog.com/en/analog-dialogue/articles/precision-successive-approximation-adcs.html | ||
Line 850: | Line 842: | ||
--> | --> | ||
=====PDM in the context of DACs and ADCs===== | |||
<!-- | |||
One reason for a multiples-faster 1-bit DAC over e.g. sample-speed 16-bit DAC is that ''even though'' it needs to run a whole bunch faster, the linearity of the output signal is easier to control. It turns out that it's easier way to make it more precise, and/or cheaper to implement for the same linearity. | |||
Roughly speaking, that linearity comes from the regularity of the timing, rather than the precision of the way you combine the levels (typically a precision-engineered resistor ladder, which becomes harder to do with every bit). | |||
A 1-bit DAC was made by Philips around 1989, called Bit Streamer[https://www.stereophile.com/content/pdm-pwm-delta-sigma-1-bit-dacs-john-atkinson], and they work pretty well. | |||
AFAICT, today 1-bit DACs aren't really made anymore, because a mix of the two approaches (the broader category of delta-sigma DACs) makes more sense{{verify}}. | |||
A delta-sigma DAC has more noise around its internal speed{{verify}}, but since that's typically at order of a MHz, that's e.g. easy to filter out of audio signals. | |||
The "output when the error accumulates too much" implementation is sequential, so can be implemented in simple FPGA logic[https://www.koheron.com/blog/2016/09/27/pulse-density-modulation], and also code (e.g. mircocontrollers[https://github.com/edgar-bonet/avr-dac]). | |||
'''PDM input''' | |||
A practical application you may have heard of is MEMS microphones. | |||
Let's ignore ''how'' they oversample the acoustic signal, | |||
and recognize that their output is a ~MHz-rate binary PDM signal, | |||
and that the bit density over a longer term represents the amplitude of the (much lower rate) audio signal, | |||
and consider how you might consume that. | |||
PDM at an electronic level, e.g. as it comes out of MEMS microphones, is often | |||
* Synchronization input clock () | |||
* LR Left/Right channel selection | |||
* data output | |||
'''Analog:''' Interestingly, you have the option of consuming it as analog, which you might do if the next step wants it as analog anyway. | |||
You are one lowpass away from turning fast switching into its average - i.e. the represented signal at kHz range. | |||
Noise induced onto the wire that carried the PDM signal will be inseparable also be part of this analog output, though. | |||
'''Digital''': The point of consuming the same digitally is since this is binary, | |||
the voltage swing is pretty unambiguously either one or the other. | |||
In theory, any noise that is not strong enough to flip bits will be ignored. | |||
And note that Receiving PDM in theory mostly comes down to counting - again, very quickly, but with the right peripheral that is not much of an issue. | |||
https://en.wikipedia.org/wiki/Pulse-density_modulation | |||
https://www.ap.com/technical-library/more-about-pdm/ | |||
--> | |||
====Multiplying DAC (type)==== | ====Multiplying DAC (type)==== |
Latest revision as of 16:29, 26 April 2024
High side versus low side switching / driving / sensing
Some limits and choices
High versus low side sensing
Buffers
Transistor output stages
Open-drain / open-collector
Common collector / Common drain
Totem-pole, push-pull
Other details
Transient voltage and ESD protection, snubbers
Protection diodes (inputs and output pins)
TVS diodes
Snapback
RC and RCD snubbers
Crowbars
Gas Discharge Tubes
MOVs
Trisil
Unsorted
See also (transients)
On ADCs and DACs
ADC
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
When ADC values fluctuate
DAC
A Digital-Analog Converter (DAC) takes numbers and turn them into voltages.
What do DACs speak
PDM in the context of DACs and ADCs
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.
Limitations:
- 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
Example:
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.
Limitations:
- 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
Example:
- Raspberry Pi's onboard sound is actually dedicated PWM pins, at 50MHz(verify), plus a filter and buffer (exact details vary)