Electronics notes/General sensor notes, voltage and current sensing
On floating inputs
Floating inputs refer to sensing from wires that are not connected to anything.
Since most sensing (transistors, op amps, comparators, ADCs) is high impedance (see also impedance bridging), they are easily influenced by the tiniest electromagnetic effect nearby, such as static electricity, your presence, e.g. your hand, induced signals such as mains hum, components near the sensing circuitry, and sometimes the behaviour of the sensing circuitry itself.
The voltage level of floating inputs is unpredictable and may vary/oscillate wildly (sometimes fairly smoothly).
The behaviour depends on too many factors to predict outside of a very controlled setting, so also not very easy to detect (unless you're specifically designed for that).
Issues:
- Usually the largest issue is unpredictable behaviour.
- If the result of this unpredictable input goes to some output, it may cause some very interesting things to happen.
- if it involves pins like reset or enable, leaving them unconnected can crash things
- if it senses oscillation
- if there's a registered ISR, it could lead to freezes
- there may be some low level thing drawing a little more power (e.g. CMOS draws a little power when switching states), like half a mA per pin, where when pulled up/down that might be microamps
- it may cause some high-frequency switching
- which, if it goes to some output, can damage components that don't like that
- logic ICs with unused inputs may actually be switching wildly, which functionally wouldn't matter because you're also not using their outputs -- but they may induce a little noise nearby, causing issues nearby.
- You can avoid that, for nearly-free, by tying their inputs to Vcc or Gnd.
Current loops
Current loops are those that signal using either presence of current (on/off) or degree of current, rather than voltage.
Which itself is a very general concept, and most uses are specced more specifically.
For example, MIDI communicates as a unidirectional serial port, and electrically each interconnection is its own 5mA current loop -- because it's driving an optocouple.
(In practice, RS-485 often replaced such use, for practical reasons)
But often, current loops refer specifically to the 4-20mA variant (see below).
This because it's easier to communicate stable current than stable voltage in the presence of interference, so in e.g. industrial settings it's worth the extra conversions that are often involved.
4-20mA current loops
"4-20mA" refers to a way of reading out sensors, and for sensors to send values this way.
Started as a de facto standard, later got described in standards like ISA-S50.1 (ANSI/ISA-S50.1-1975, -1982, -1992) (verify)
(click boards are a specific manufacturer's way to have a exchangable socket for various add-ons)
The point is using a current range to represent a value range, rather than voltage.
Sure, voltage is a more natural choice for a lot of sensors, and many sensors will fairly directly output a voltage, is easier to use, takes fewer components to communicate, and inside devices is good enough (short distances, ability to control shielding).
However,
- voltage drops over long lines (changing the value), and
- interference on the line presents mostly as extra voltage source (changing the value in a way that is very hard to remove).
It turns out that current loops are more stable and less noisy, so make a lot of sense in e.g. industrial settings,
where a few extra bucks .
(there are other solutions, such as differential signalling, and digital signalling)
Upsides
Easier to make reliable on long cables
- Currents are by definition the same everywhere in their path, so are not bothered by voltage drops.
- ...that is, as long as the loop's driver can maintain that current on whatever loop you attach to it, which mostly comes down to 'until the voltage drop over the cable and components is larger than the power supply voltage'.
- The supply voltage is DC, without high frequency noise (so often a regulated supply)
- industry standard is 24V, but voltages like 12V, 15V, 36V, and others are also seen. A 9V battery can be a temporary fix.
- The actual voltage is not important, just that it's more than the total voltage drop in the circuit.
Current signals are less affected by interference on the line
- not immune, but a bunch better than voltage signals
Allows detecting a problem
- Being zeroed at 4mA rather than 0mA makes it easy to sense a disconnected port / broken wire / failed power supply (voltage signals would become floating input and probably react wildly to EM in the environment, in a way that's hard to distinguish from real signal)
- ...though makes ratiometric use a little harder
- ...and yes, there are also 0-20mA loops in use, which can't do this.
Two wires can be used for both signal and power
- ...though not all sensors can be loop-powered
Limitations/downsides
Only one parameter per loop (for complex setups this can be a lot of wiring)
Takes more components
- Not too particularly complex, but op amps with feedback are a little beyond beginner DIY
Only one transmitter per loop
- when you have a lot of sensors, this quickly becomes a lot of wires
- (so these days longer range transmission is often digital, though locally it may still be collecting a bunch of current loop signals)
- you can have multiple receivers in one loop (but there's often no point)
Not immune to ground loops
- (e.g. a local sensor display may have its own ground)
- ...though they may be easier to solve
- receivers tend to lowpass (below mains frequency)
Not ideal for fast-changing signals
- good for sampling dozens of times per second, but not orders more
For complex setups there may be better alternatives
- e.g. if your measurements are digital already, it's often easier to use digital communication, e.g. use RS-485 if you have to go longer distances (can be used as a shared bus)
Where the power is
How
Extensions
See also (current loops)
- acromag Introduction to the two-wire transmitter and the 4-20mA current loop
- dataforth AN104
- libelium 4-20ma current loop guide
- 4-20 mA Transmitters Alive and Kicking
Notes on ADCs and DACs
See Electronics_notes_/_Inputs_and_outputs#On_ADCs_and_DACs
On nonlinear quantization
Impedance and buffering
ADC operation works with current, so they have relatively low-impedance inputs. As such, they may interact with the source circuit (consider e.g. SAR ADCs, which are also a non-linear load on the source circuit).
Impedance also easily varies with (sampling) frequency. This seems particularly true of high-performance ADCs.
If you want to minimize the interaction with the circuit you can use a buffer, such as an op amp, which presents a high-impedance load to your circuit and a lowish-impedance output to the ADC. (Assuming you were not already using an op amp construction (e.g an instrumentation amp) anyway, you can e.g. make it a fairly-simple voltage-following unity-gain amp)
Some typology
Input structure
- Single-Ended
- measures the difference between one pin and ground
- (Fully-)Differential
- measures the difference between two pins (i.e. no ground)
- Floating-differential and pseudo-Differential relate to voltage ranges and noise (verify)
Getting the value
Resolution and speed depends entirely on application. Imaging and such needs to be both, movement needs speed more than accuracy, while temperature and such can be slow if that means it's more accurate, or just cheaper.
- Ramp Counter (a.k.a. digital ramp)
- Delta-sigma - refers to a way of dealing with noise, used by both ADCs and DACs
- medium speed, high resolution
- https://en.wikipedia.org/wiki/Delta-sigma_modulation
- http://www.ti.com/lit/an/slyt423/slyt423.pdf
- http://www.allaboutcircuits.com/vol_4/chpt_13/9.html
- Single-slope
- Dual-slope
- slow speed, good resolution
- Successive Approximation Register (SAR)
- medium speed, high res
- most common, because of the above and low cost
- Flash
- high speed, medium resolution
- https://en.wikipedia.org/wiki/Flash_ADC
- Pipelined
- effectively multiple flash type, better resolution
See also:
- http://www.maximintegrated.com/app-notes/index.mvp/id/1108
- http://www.hardwaresecrets.com/printpage/How-Analog-to-Digital-Converter-ADC-Works/317
oversampling / supersampling
See Oversampling
Amplifying and otherwise massaging voltage
Certain sensors are by nature low-voltage. You'll regularly use op amps to (offset and) amplify that voltage to a range your ADC likes.
Voltage sensing
Signal conditioning
Lowpass
See Low-pass filter.
You may want to consider doing the low-pass calculations in in floating point (or fixed point) even if you return (truncated) ints (with pure-integer solution, small alphas can lead to problems related to truncation within each step. You can hack around this, but only really if you understand the problem, so using floats is usually simpler).
If you're doing an occasional sample of a sensor and want the return a filtered value for stability, there are a few things to keep in mind, particularly when your code has other things to do, and you only occasionally call this lowpassed-sampling function.
- the question of whether the value can adapt quickly enough to the changes in the sensor value that may happen in the time between such calls. (When there's nothing time-critical about the sampling this can be fairly easily solved by doing a couple hundred samples each call (well, depending on the alpha) to let it adapt)
- In a 'take x samples, lowpass the series, give last output', the first value has a relatively strong influence on the output in that if relatively few samples follow it may not adapt well enough. This means that if the high-frequency fluctuations that you want to filter out make it into the first value, the result can be less stable than you might think. To avoid this you may want (an option) to use the most frequent output as the first value. (Note this does influence the question of whether the value will adapt quickly enough within each sampling call, if the value can change significantly between calls.)
Analysis
Spectrum analyser ICs (per-band information)
- for some example uses, see e.g. NJU7505A, MSGEQ7
Current sensing
Resistive sensors
Creative repurposing
- stepper motor as a rotary encoder