Summarising from a group of sensors

I have a group of sensors the nominally output 2.5V but if they come in contact with a magnet they'll increase slightly or decrease slightly based on the polarity (north/south pole).

These sensors have a decent range but they're pretty narrow in scope, so as a result I've aligned a number of them side by side.

My issue now is that I have 6 of them, and I don't want to spend 6 analogue in pins if I can help it. Ideally I'd like to build a circuit that ultimately reports the greatest difference from the nominal 2.5V between all 6 of the sensors.

For example, let's say we begin in a neutral environment -- no magnets are present. All sensors will read 2.5V and none of them really "win" the output pin. However, as I bring a magnet closer to the line of sensors, the one closest will read let's say 2.9V, and it's neighbour will read 2.7V. Between these two the 2.9V will "win" the output pin because it has the greatest difference from the nominal 2.5V. So I'd like to see either 2.9V on the output pin of this circuit, or 0.4V (the difference). Doesn't really matter which since the rest can be handled by software.

I'm thinking a summer op-amp might be the right answer here but I was wondering if you guys have any other suggestions. Thanks!

EDIT: To clarify, I don't care which sensor "wins" I just want to know if ANY sensors change from 2.5V, what's the greatest change?

EDIT2: There's only one magnet being sensed here so if one sensor reads negative then they all will. No need to account for some being +0.4V while another is -0.4v.

• You don't need to subtract 2.5 volts, unless you can go below 2.5V on a sensor -- in which case you'll be wanting an absolute value circuit after the difference circuits. – Scott Seidman Feb 18 '19 at 18:31
• Oh -- so there's no need to know WHICH sensor wins?? – Scott Seidman Feb 18 '19 at 18:43
• An analog mux needs a serial 3 bit address so 2 ports. 1 analog in and 1 digital serial port. Would you prefer a software or hardware solution? If the latter, then a FW precision rectifier for each channel then an analog 6:1 MUX with serial address if you care about which sensor. an inverting sum amp will add all channels, which is not the majority input you want, but maybe will do what you need – Tony Stewart Sunnyskyguy EE75 Feb 18 '19 at 18:54
• Try to re-write it like specifications in a datasheet. Rise time, peak voltage, update time or sustain time[ms,s?], absolute peak detection + OR- , + AND -, minimum duration[us,ms,s], signal BW. Offset error, dynamic range 1/r^2, B field [mT] Max:min, Peak-average output etc...Some clarity is needed in your specs. – Tony Stewart Sunnyskyguy EE75 Feb 18 '19 at 19:13

5 Answers

Depending on how you want to process the data and the driving current you have available, you can use a simple non-linearity to provide you with a maximum voltage. All you need is an element that behaves non-linearly with respect to the voltage across it.

Assuming your sensor outputs are low impedance, the simplest version of this would be:

simulate this circuit – Schematic created using CircuitLab

Vmax will be approximately equal to the largest voltage in all the sensors minus a diode drop. Likewise Vmin will be approximately equal to the lowest voltage in all the sensors plus a diode drop.

As the voltage-current dependence of a diode is exponential Vmax and Vmin will be close to the average voltage when all the sensors are about the same, but will exponentially deviate from this. As there is roughly a factor of 3 in current every 30mV of deviation, if the outputs are more than ~100mV apart, the contribution of the lower/higher voltage outputs would be negligible.

You can think of the circuit as a multi-input voltage divider (average circuit) but the non-linear diodes take the place of the resistors. If all the voltages are close to being the same (and the diodes are perfectly matched) the output is simply the average of the inputs (minus a diode drop, of course). But, the further the average deviates from any specific input the diode will exponentially reduce (or increase) its current leading whichever diode has the largest voltage across it to provide the most current to the resistor. At about 100mV differential the effect of all other diodes on the output voltage will be less than 1/10th of the effect of the dominant input.

Note that this diode structure is what you get with most interface clamping diodes. So this could be implemented with one IC and a couple resistors.

• This is really cool and looks pretty simple. I just want to make sure I'm interpreting properly: are U1, U2, ..., U4 the sensor outputs? And then probing the point labelled "Vmin" will give the minimum voltage of all the sensors and "Vmax" would likewise be the maximum? Also, could you please expand on your second last paragraph? – Capn Jack Feb 18 '19 at 22:12
• @CapnJack Yes. Those are the sensor outputs, but this circuit only works if the output impedance of the sensors is one or two orders of magnitude lower than the load resistors (~100Ω for the values shown), which should be the case for an active sensor. As with any analog circuit, it will never be perfect. This relies the diodes acting as non-linear resistors in a resistive divider. I will expand the answer to make this point clearer. – Edgar Brown Feb 18 '19 at 22:21
• Checked the data sheet, they have ~3 ohms of DC output resistance – Capn Jack Feb 18 '19 at 22:30

I suggest an analog multiplexer. You would switch between each of your sensors, use one analog in to read them all, one at a time, and do whatever calculations and make any decisions you need to. This will be way cheaper and faster than what you propose.

from CD4051 datasheet

This is nothing but a multi-position switch where you use logic signals (or a serial bus, in some cases) to determine which connection(s) is made. The CD4051 is one such IC, available in DIP. Runs less than \$1USD in quantities of 1. I'm not screening this for ANY of your needs. I'll leave that up to the asker. You read a voltage, switch channels, wait for settling, and repeat.

Obviously, you need to have at least ONE digital out to control this. Ideally, you'd have three, but if you can only spare one, you can use it to increment a counter IC to drive A, B, and C.

The path you were running down would soon result in a fairly large and expensive network of analog difference circuits and comparators.

• would you mind expanding a bit on how an analogue mux works? The root of my problem is in determining which of the 6 channels to reads from (I want the one with the greatest difference from the nominal voltage). Mux is probably a good way forward but I still don't know how to select the right channel – Capn Jack Feb 18 '19 at 18:00
• Thanks for the diagram, I understand what you're suggesting now. I'm just curious as to why this is preferred to a summing differential amplifier? It seem's like a good deal of work poll each channel, wait for it to settle, and then move to the next, when instead I could subtract the nominal from each sensor and sum the results with the differential summer. If it's just a matter of cost I'd rather splurge for the latter unless it's really that much slower. I'm only doing this once for a small area of my application. – Capn Jack Feb 18 '19 at 18:18
• @CapnJack the moment you try to lay out the circuit you're asking for, and fill a shopping cart with parts, you'll understand why this is the far simpler way to run. – Scott Seidman Feb 18 '19 at 18:20
• I can't judge "faster" or "slower" until you tell us how fast you need this to run. – Scott Seidman Feb 18 '19 at 18:20
• This sounds like the way forward possibly. I'm going to pick up a mux tomorrow and some diodes (see the other answer below) and test both methods out. I just wanted to ask: how would I determine an ample settling time? Is there a good rule of thumb here? I don't have access to a scope so I can't determine this by inspection unfortunately – Capn Jack Feb 18 '19 at 23:11

Between these two the 2.9V will "win" the output pin because it has the greatest difference from the nominal 2.5V. So I'd like to see either 2.9V on the output pin of this circuit, or 0.4V (the difference).

I'll make a working assumption that you want to know the max value, but you don't need to know which of the sensors have produced that value.

In that case, diode-OR the outputs of your sensors. The output with the greatest voltage is going to dominate the others. You can account for the diode drop in software.

I'm thinking a summer op-amp might be the right answer here but I was wondering if you guys have any other suggestions.

A summing op-amp is going to produce an average value, essentially. A summing op-amp will not "select" the max input.

p.s.

Diode-ORing might be a cheap solution. It might solve the nominal problem in the way in which its currently formulated. If you want a more flexible solution, then you might want to A/D convert each sensor individually. That would enable you do all sorts of thing in software. There are few ways to approach this: (1) select a different microcontroller with more analog inputs, (2) add an external A/D converter, (3) multiplex between the sensors and one analog input.

• It will drop below 2.5 V if the magnet poles are reversed. (See first paragraph of question.) – Transistor Feb 18 '19 at 18:35

simulate this circuit – Schematic created using CircuitLab

Figure 1. Simplest solution?

• The voltage at AIN will be the average of all the sensor outputs.
• Raising one input from the normal 2.5 V to, say, 2.9 V will raise the voltage by $$\ \Delta V_{AIN} = \frac {2.9 - 2.5}{6} = 67 \ \text {mV} \$$ and the opposite pole of the magnet will cause the voltage to fall by 67 mV.
• This represents $$\ \frac {0.067 \times 1024}{5} = 13.7 \$$ counts on a 10-bit ADC. If this is lacking sensitivity then you may be able to set the span of the analog input by adjusting the analog hi and lo reference voltages.

I'm thinking a summer op-amp might be the right answer here.

The summing amplifier will give the same results as the resistor network above although you could design in some gain if required.

simulate this circuit

Figure 2. A window comparator.

The window comparator of Figure 2 may be sufficient for your purposes. R3 adjusts the window width and R2 adjusts the span high and low. For a 2.5 V average and a ± 30 mV threshold you would adjust the pots for 2.53 on top of R3 and 2.47 on the bottom.

From the comments:

For the window comparator, what would that look like with the 6 sensors?

You can combine circuits 1 and 2.

I'm not sure what AIN means here.

AIN = Analog INput. I assumed from your "analog pins" reference that you were using a micro and that's where Figure 1's AIN is going. The alternative is to route it to Figure 2's AIN.

But that might also be a good technique, sort of like an inverted window where if any sensor exceeds 2.53 V or is under 2.47 V I get a 5V output, otherwise it's a 0 V output.

The comparator output will swing low if $$\ V_- > V_+ \$$. In the arrangement I have drawn that will happen when AIN goes outside the "window". If you want the opposite then swap the '-' and '+' inputs.

I should have mentioned that I have assumed an open collector output on each comparator. This means that the comparators' output transistors can only pull the output low. R5 pulls the output high when both outputs are 'high' (which really means open-circuit in this arrangement). That's how both comparators' outputs can be connected in parallel without damage.

Would I need one circuit per sensor or can I combine multiple inputs?

Connect Figure 1 to Figure 2.

• What if one sensor is up by 0.4 volts and another down by 0.4 volts? – uglyoldbob Feb 18 '19 at 20:40
• Average = 2.5 V then. The question is vague about this possibility. – Transistor Feb 18 '19 at 20:43
• for the window comparator, what would that look like with the 6 sensors? I'm not sure what AIN means here. But that might also be a good technique, sort of like an inverted window where if any sensor exceeds 2.53 V or is under 2.47 V I get a 5V output, otherwise it's a 0 V output. Is that what this is doing here? Would I need 1 circuit per sensor or can I combine multiple inputs? – Capn Jack Feb 18 '19 at 22:04
• See the update. – Transistor Feb 18 '19 at 22:17

The simplest and most flexible solution will be summarising by an algorithm (some few lines of code).

You may compute the maximum, minimum and mean of all sensors. You may sort the sensor's values. But you may use another method you did not think about yet.

If you want to use only one analog input, an analog multiplexer may be used for expansion as written in other answers.