Electronics notes/General sensor notes, voltage and current sensing

From Helpful
(Redirected from Current loop)
Jump to: navigation, search
This is for beginners and very much by a beginner.

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 · Ground · batteries · resistors · changing voltage · transistors · fuses · diodes · varistors · capacitors · inductors · transformers · baluns · amplifier notes · frequency generation · skin effect

And some more applied stuff:

IO: Input and output pins · wired local IO wired local-ish IO · · · · Shorter-range wireless (IR, ISM RF, RFID) · bluetooth · 802.15 (including zigbee) · 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

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

Audio notes: microphones · device voltage and impedance, audio and otherwise · amps and speakers · basic audio hacks · digital audio ·

Less sorted: Common terms, useful basics, soldering · Arduino and AVR notes · ESP series notes · PLL · signal reflection · pulse modulation · electricity and humans · resource metering · Microcontroller and computer platforms · SDR · Unsorted stuff

See also Category:Electronics.

On floating inputs

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

Floating inputs refer to sensing from wires that are not connected to anything.

Since most sensing (transistors, op amps, comparators, ADCs) is high impedance, 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).


  • 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

Current loops

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

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

The use of 4-20mA signmalling of sensors first were a de facto standard, then got described in ISA-S50.1 (ANSI/ISA-S50.1-1975, -1982, -1992).

The point is using a current range to represent a value range.

Yes, voltage output is often a more natural choice given the output of most sensors, but voltage drops over long lines, and interference presents mostly as voltage.

So while voltage is fine within most devices, due to short distances and ability to control shielding, So current loops communicate more stably and are less noisy and make a lot of sense in e.g. industrial settings.


Currents are by definition the same everywhere in their path, so are not bothered by such voltage drops.

...as long as the loop's driver can maintain that current, which is basically until the voltage drops over the cable and components is larger than the power supply voltage. The supply voltage is DC and often 24V, and devices are often lenient (Voltages like 12V, 15V, 36V, and others are also seen)

A voltage signal's meaning is directly and proportionally affected by interference on the line.

Current signals are not immune, but are less affected.

Being zeroed at 4mA rather than 0mA, while makes ratiometric use harder, also makes it easy to sense a disconnected port / broken wire

where voltage input would float and just become more environment-sensitive and behave randomly

Two wires can be used for both signal and power

...though not all sensors can be loop-powered

Only one parameter per loop (for complex setups this can be a lot of wiring)

Nontrivial component-wise

Not too particularly complex, but e.g. 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)

Not immune to ground loops (but they may be easier to solve).

(e.g. a local sensor display may have its own ground)

Where the power is
See also

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

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

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
  • 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
  • Pipelined
effectively multiple flash type, better resolution

See also:

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


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.)


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

See also