Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Contemplating a documentation series for my Raspberry Pi work

by afoken (Chancellor)
on Jul 06, 2017 at 06:36 UTC ( [id://1194343]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Contemplating a documentation series for my Raspberry Pi work
in thread Contemplating a documentation series for my Raspberry Pi work

One thing that I've rarely seen in the Raspi or Arduino context is the 4-20 mA interface, a.k.a. current loop. In its pure analogue variant, it's a quite clever and simple interface suitable for both sensors and actuators. The idea is to use current, not voltage, to carry the signal. 4 mA represents 0%, 20 mA represents 100%. Everything in between is linear, e.g. 12 mA = 50 %.

Some advantages:

  • The offset of 4 mA can be used to supply the sensor or actuator with energy. Many actuators actually have a separate supply voltage, because 4 mA at about 20 V is not that much energy, so it's a little bit hard to move things. Many sensors can work fine from 4 mA and don't need a separate supply.
  • A broken sensor or actuator line can easily be detected: The current drops below 4 mA, typically to 0 mA.
  • A short circuit in the sensor or actuator line can be detected: The current rises above 20 mA. The limiter (see disadvantages) will prevent excessive current, so nothing will start burning.
  • A simple shunt resistor between GND and sensor is all you need to read the sensor value into the controller (ADC input). Most times, you add an op-amp and use a lower resistor value. Also, you need some clamping (a diode pair from signal input to Vcc and GND) to avoid magic smoke escaping from the controller or the op-amp. Trust me, I know from experience that modern microcontrollers don't like 24V at their input pins. Some op-amps can handle input signals larger than their supply voltage, so the clamping may be omitted for them, but most op-amps don't like that at all.
  • Resistance of the sensor / actuator line is not an issue, because the sensor or the current source for the actuator will drive a constant current through the line. Voltage drop is irrelevant as long as the supply voltage is high enough. The industry standard supply voltage is 24 V, sufficient for insanely long lines. If line resistance becomes an issue, you can simply increase the supply voltage. (In other words: with short lines, you could get away with less supply voltage.) So usually, simple phone wire is used for current loops.
  • Noise coupled into the line is not an issue. It will cancel out, because the line is essentially symmetrical. And if it doesn't, the sensor or current source will work against the noise.
  • Electromagnetic compatibility is usually not an issue, because you rarely have high frequency signals on the line. All is purely analogue, so you usually don't have sharp edges on the signal. Unless something changes, the signal is DC.
  • A simple multimeter capable of measuring voltages up to 100 V and current up to 100 mA is sufficient for debugging. Special devices are available to drive constant current into an actuator or to control the current into a controller (replacing the sensor). A scope may occassionally be helpful if you need to see the exact signal waveform.
  • A simple potentiometer can be used during development to simulate a sensor. Add a mA meter in line and you can fake sensor data as required.

Some disadvantages:

  • Sensors are typically not referenced to GND, because the current measuring shunt is connected between sensor and GND. If one end of the sensor is tied to GND, the current has to be measured at the high side, requiring more hardware between shunt and controller. The same is true for actuators.
  • Supply voltage is typically 24 V, rarely found in the context of Raspi and Arduino.
  • You want a current limiting circuit in series with the sensor / actuator to prevent damages due to short circuit of the terminals. Ohm's law is helpful here, a simple resistor at the high side can be sufficient, adjusted for a max. current of about 25 to 100 mA. An active solution may perform better, typically need two or three transistors and a few passives.
  • You need an adjustable current source to drive an actuator. Typically, you use a special IC for the job, but you could also get away with an op-amp circuit. Both would be controlled by a voltage (DAC) output from the controller.
  • You need one pair of wires per sensor, one pair of wires per actuator. No multiplexing.
  • 4-20 mA sensors are not really cheap. They are clearly designed for industrial use, where reliability is more an issue than cost.

Update 2017-07-19: Hackaday has a nice posting about 4-20 mA current loops.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re^5: Contemplating a documentation series for my Raspberry Pi work

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1194343]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-19 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found