But what about voltage drop across the diodes? Silicon diodes drop around 0.6V so wouldn't you end up with -0.6V at the output? Using Schottky diodes will reduce this to 0.1-0.3 volts, but that's still less than 0 volts. Even better would be an op-amp follower circuit.
If you run a 0mA current source through a resistor you can get 0V as well. E = I/R so any resistance would work, except for 0 ohms, otherwise you'll divide by 0. Per a thread I posted a few weeks back, the best way to get a 0V reference is with a precision 0V reference IC. Or just use a 0V battery, also known as a "dead" battery. These can be found in any neighborhood trash can.
If you need more current, lower the value of the resistor. If you need lots of current, use thicker wires and higher rated diodes.
Note that by using a resistor (10M in the diagram) the output current will depend on the input voltage. If this is an issue, a constant current source could be used in place of the 10M resistor.
Oh yeah, one more thing. You can replace the two diodes with a single bidirectional diode.
I noticed that the output is shorted to GND. This is not good design practice.
Below is a method that eliminates this problem. You can probably find a better op amp than the one I chose.
EDIT: I just noticed Kpatz suggested this method. A schematic is always helpful.
Lol This should eliminate the requirement of 4-20 mA signals. NO zero error.
After over 50 years of using 4-20 to eliminate error I am ussurped by 2 diodes and a resistor. Thank you.
Well I also have invented another useful circuit: the no-pass filter. This is the dual for the all-pass filter.
You can implement it with LC components, opamps, or digital filters.
Essentially at the input you have a low pass filter followed by a high pass filter.
For optimal operation, the cutoff frequency of the low pass filter must be at least a couple of decades lower than that of the high pass filter, and the filter's response at least third order.