Author Topic: How to make an analog circuit to proportionally scale a sensor output voltage?  (Read 6689 times)

0 Members and 1 Guest are viewing this topic.

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: gb
I have this device that takes an input from an air pressure sensor. The sensor gets a 5V reference, and the device's MCU reads the sensor's output voltage using its ADC. The sensor reads up to 2.5 Bar.

However, this particular sensor is expensive and hard to get, so I have been thinking about the possibility of substituting it with something more commonly available. My mind turned to automotive MAP sensors, which are ubiquitous and cheap. In particular, the common GM 3 Bar MAP sensor would be a great candidate. But, of course, it works over a different pressure range (2.5 versus 3), so therefore the output voltage will not match for any given pressure.

I found spec sheets for both my existing sensor and a Delphi-brand GM sensor, and made a graph of pressure vs. voltage using the provided transfer functions:



Existing sensor is in green, GM 3 Bar in dark red. As you can see, the voltage difference is proportional to pressure; for example, at 2.5 Bar the GM one is approx. 82% of the other, but 87% at 1 Bar.

The obvious solution might be to say "modify the MCU firmware with different sensor calibration data", but I can't because I didn't make the device and I can't re-program it. :)

So, my question: is there some way, using purely analog means (i.e. no MCU/ADC/DAC), that I can scale the voltage from the new sensor to match the output of the old one? Ideally, I would be able to add the circuitry in-line in between the sensor and the device.
 

Offline Mr.B

  • Supporter
  • ****
  • Posts: 1249
  • Country: nz
An op amp with 1.1875 times gain?
4.75v / 4.0v = 1.1875 times higher for the old sensor than the new sensor at the same pressure.
Where are we going, and why are we in a handbasket?
 
The following users thanked this post: rs20

Offline Dundarave

  • Regular Contributor
  • *
  • Posts: 160
  • Country: ca
Interesting problem...  If the curve of the original sensor was completely linear, it should be relatively easy to use an op-amp with a gain that matched the difference in slopes between the two curves.

But since there is an inflection point at 0.5 Bar, it makes things a bit more complicated.  However, I noticed that at 0.5 Bar, the output of the original looks to be 0.7ish volts, which brings to mind the voltage drop of a diode...  Perhaps by arranging the feedback gain resistance in the op-amp circuit so that below 0.7 v, a fixed resistance (calibrated for the initial slope) is used, with a parallel second resister + diode (which would thus conduct at 0.7 v) to handle the slope (i.e. gain) difference for the rest of the curve.

It's been a long time since I've played around with op-amp configurations, but perhaps this might give you (or others with greater op-amp expertise) an idea to run with.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: au
Let's take a step back here: both of these sensors are probably specced and supposed to be nominally linear with 0 bar = 0 volts. So the fact that there is not a strict proportional relationship between the two is due to an imperfection in one of these sensors.

Here's the important question: do we actually WANT to emulate this crappiness? Does this application require such precision that modelling that slight inflection point at 0.5 Bar is really necessary? The OP and reply #2 here are latching on to the mathematical challenge of mapping one slightly nonlinear or offset function to another, but this is a real world problem where such efforts may be at best a waste of time, and at worse, result in successfully replicating an undesired behaviour. Stop looking at every pixel in the graph and think about the broader picture. What is this device? Could you please link these spec sheets you found?
 
The following users thanked this post: Mr.B

Offline Mr.B

  • Supporter
  • ****
  • Posts: 1249
  • Country: nz
Let's take a step back here...
Stop looking at every pixel in the graph...

This.

The curves look linear enough to simply use an op amp to translate through a simple gain.
If the accuracy is that important then buy the more expensive original sensor.
If you are looking to cut cost you may have to sacrifice a little accuracy in the low end pressures.
Where are we going, and why are we in a handbasket?
 

Offline SparkyFX

  • Frequent Contributor
  • **
  • Posts: 676
  • Country: de
Here's the important question: do we actually WANT to emulate this crappiness? Does this application require such precision that modelling that slight inflection point at 0.5 Bar is really necessary?
In a turbo engine you rarely see negative pressure that far down. (it´s a manifold absolute pressure sensor)
Support your local planet.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Let's take a step back here...
Stop looking at every pixel in the graph...

This.

The curves look linear enough to simply use an op amp to translate through a simple gain.
If the accuracy is that important then buy the more expensive original sensor.
If you are looking to cut cost you may have to sacrifice a little accuracy in the low end pressures.

I agree here and would ask one question, "What is the application?"  Upon thinking about this a little more, the slopes of the output curves are different, so just a single scale factor won't work.  At 2.5 Bar, Original at 4.75 V and GM at 4 V; at 1 Bar, original at ~1.8V and GM at 1.55 V.  Therefore if you scale for 2.5 Bar, multiplier is 1.1875; at 1 Bar multiplier is 1.16.  That's about a 2.5% error.  That may be acceptable to your application.  :-//
« Last Edit: July 04, 2019, 03:26:17 pm by GerryR »
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Here's the important question: do we actually WANT to emulate this crappiness? Does this application require such precision that modelling that slight inflection point at 0.5 Bar is really necessary?
In a turbo engine you rarely see negative pressure that far down. (it´s a manifold absolute pressure sensor)
In an automotive application, at idle and partial throttle low cruise (which is pretty common), you will see intake manifold pressures under atmospheric (what the automotive world calls "vacuum")
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
Could you feed the GM MAP sensor with a 6V reference voltage and dispense with the op amp?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
Here's the important question: do we actually WANT to emulate this crappiness? Does this application require such precision that modelling that slight inflection point at 0.5 Bar is really necessary?
In a turbo engine you rarely see negative pressure that far down. (it´s a manifold absolute pressure sensor)
In an automotive application, at idle and partial throttle low cruise (which is pretty common), you will see intake manifold pressures under atmospheric (what the automotive world calls "vacuum")

Also on the overrun (e.g. downhill with closed or almost closed throttle) the manifold pressure can drop to 0.3 bar or so irrespective of being a turbocharged or normally aspirated engine.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7855
  • Country: au
As an analog person from way back, it pains me to say that you would be better off doing it digitally.
Use an ADC, then in software, modify the result to your requirement.
Obviously, it can be done in analog, but it gets fairly messy quickly.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Could you feed the GM MAP sensor with a 6V reference voltage and dispense with the op amp?

That's a very clever scaling solution;  I like clever!!
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17428
  • Country: us
  • DavidH
Scaling and offset with a single operational amplifier is simple enough but if that non-linearity has to be corrected, then a break-point in the transfer function would be required.  That can be done with diodes or transistors within the feedback or input network.  Analog Devices has a lot of application notes on this subject.

Today a tiny and inexpensive microcontroller with ADC and DAC could also do it depending on the resolution requirements.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Here's the important question: do we actually WANT to emulate this crappiness? Does this application require such precision that modelling that slight inflection point at 0.5 Bar is really necessary?
In a turbo engine you rarely see negative pressure that far down. (it´s a manifold absolute pressure sensor)

I've had cars with turbo engines for ~20 years now, and when at low throttle and especially idle the MAP is the same as on a naturally aspirated engine. The turbo only really does anything once you are producing enough exhaust gas to spool it up and start boosting the pressure. During normal driving the boost gauge is in the vacuum region.
 

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: gb
But since there is an inflection point at 0.5 Bar, it makes things a bit more complicated.  However, I noticed that at 0.5 Bar, the output of the original looks to be 0.7ish volts...

Yes, I screwed up the original graph which made this crucial attribute not obvious. The figure for 0 Bar on the original sensor actually comes out to -0.2V according to the transfer function, but seeing as the sensor can't actually output a negative voltage, I manually entered zero, inadvertently making the graph slightly misleading. :palm: Correct graph below.



Which leads to...

Upon thinking about this a little more, the slopes of the output curves are different, so just a single scale factor won't work.  At 2.5 Bar, Original at 4.75 V and GM at 4 V; at 1 Bar, original at ~1.8V and GM at 1.55 V.  Therefore if you scale for 2.5 Bar, multiplier is 1.1875; at 1 Bar multiplier is 1.16.  That's about a 2.5% error.

The multipliers across the pressure range are specifically as follows:

Bar:0.51.01.52.02.5
Multiplier:1.0291.1451.1831.2021.213

So yes, quite a large difference in gain between 0.5 Bar and 3.0, and a single scaling factor (e.g. 1.1875) wouldn't work properly. This is what I was trying, but failed, to put across in my original post - I really shouldn't do these things late when I'm tired ^-^.

Now, the question of whether I need to handle the case of values beyond the inflection point, below 0.5 Bar, is a good one. The honest answer right now is that I don't really know. I do know that some vacuum (i.e. < 1.0) will be seen, but I don't know by how much.

If it turns out that vacuum figures will not matter, then maybe, just maybe I can fudge around and find a good compromise single gain figure that works across the range and only introduces as little percentage error as possible.

Could you feed the GM MAP sensor with a 6V reference voltage and dispense with the op amp?

No, I only have the 5V reference supply to work with.

...which brings to mind the voltage drop of a diode...  Perhaps by arranging the feedback gain resistance in the op-amp circuit so that below 0.7 v, a fixed resistance (calibrated for the initial slope) is used, with a parallel second resister + diode (which would thus conduct at 0.7 v) to handle the slope (i.e. gain) difference for the rest of the curve.

I'm having trouble visualising what you're talking about here. Could you possibly illustrate it?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
That makes things much easier, a simple diff amp will do the job.  This shows the general idea, but is not a complete design.

Getting the gain and offset reasonably accurate will need low tolerance resistors, but I don't know how much error is acceptable.  Deriving the offset from the 5v rail should be ok as this is a reference supply for the sensors on an engine management system, so should be well regulated.
« Last Edit: July 04, 2019, 06:26:40 pm by mikerj »
 
The following users thanked this post: HwAoRrDk

Offline SparkyFX

  • Frequent Contributor
  • **
  • Posts: 676
  • Country: de
In an automotive application, at idle and partial throttle low cruise (which is pretty common), you will see intake manifold pressures under atmospheric (what the automotive world calls "vacuum")
Vacuum relative to the absolute pressure of 1 bar... the limitation of > 0.5bar is therefore not that bad, because it´s purpose is to check and limit the turbo function and check for intake manifold leakage (air drawn into a cracked hose/gasket). In other words it is more relevant on the upper end.

Anyway, just as a reminder: the more modern ones have a built in SENT bus...
Support your local planet.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
In many cases the MAP sensor is not directly related to the turbo at all, it is used to measure air flow which is used to control the amount of fuel injected. When you know the absolute pressure in the intake manifold, the temperature of the air and the characteristics of the engine you can calculate the amount of air being ingested.
 

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: gb
That makes things much easier, a simple diff amp will do the job.  This shows the general idea, but is not a complete design.

Getting the gain and offset reasonably accurate will need low tolerance resistors, but I don't know how much error is acceptable.  Deriving the offset from the 5v rail should be ok as this is a reference supply for the sensors on an engine management system, so should be well regulated.

Wow! Thank you very much. :clap: I would not have been able to come up with something like this on my own!

I'm no good with LTSpice, so I recreated it in the Falstad simulator, and it works great! To test it, I made the addition of a voltage-controlled-voltage-source node to simulate the voltage output of the GM sensor by taking the node's voltage input as pressure instead of volts, and setting the output to be the transfer function of the sensor.

A few questions about this circuit:

- I see that the parallel 470k/130k pairs give a combined resistance of 101.8k. I suppose one could use instead a series pair of 100k and 1K, but was the parallel arrangement made to get exactly 101.8k, or is it something to do with tolerance error? Because, as I make it, if one were to use 1% grade resistors, the series pair has lower overall tolerance error than the parallel pair - assuming you don't need exactly 101.8K.

- I looked up the LT1782, and it is described as an 'over-the-top' op-amp, where inputs can exceed the supply. I presume this has no bearing on the circuit, seeing as both inputs are ultimately derived from the same 5V reference supply as the op-amp has, so can never exceed it. Is this the case, and almost any rail-to-rail-input-output op-amp could be used? For example, MCP6001.

- Extra protection of the op-amp inputs is not needed, right? Because the high resistance values used will limit current greatly? So, if for example the sensor input was accidentally shorted to +12V, the protection diodes of the op-amp should be able to handle it?

Finally, could you explain a bit about how it works? Also how you derived the appropriate resistance values?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
The resistor combination matched almost perfectly (to something like 5 decimal places) the ratio required (or at least the ratio I derived by squinting at your chart!) and are E24 series values.  As mentioned this doesn't mean much if you use normal 1% resistors as the error will stack up.

The LT1782 is simply a really nice Linear Tech RRIO op-amp that is included in LTSpice, so anyone can download the model and run it without any third party component models.  AN MCP6001 will probably work ok, but has a limited supply voltage of not much over 5v, so you'll need to provide some protection to ensure it's not destroyed by small spikes.  The input offset voltage range is also not the best IIRC.

The reason for the high resistance values is so that the potential divider supplying the offset voltage isn't loaded much, you'll see the potential divider resistors are lower by a couple of orders of magnitude.  If the offset voltage was buffered I would use lower value resistors around the diff amp, but the offset voltage is small enough that even a RRIO op-amp is going to be almost saturated.

Supply decoupling/filtering, overvoltage protection and input and output protection would really ideally be needed to make this reliable for automotive use.
« Last Edit: July 04, 2019, 09:38:15 pm by mikerj »
 

Offline Dundarave

  • Regular Contributor
  • *
  • Posts: 160
  • Country: ca

...which brings to mind the voltage drop of a diode...  Perhaps by arranging the feedback gain resistance in the op-amp circuit so that below 0.7 v, a fixed resistance (calibrated for the initial slope) is used, with a parallel second resister + diode (which would thus conduct at 0.7 v) to handle the slope (i.e. gain) difference for the rest of the curve.

I'm having trouble visualising what you're talking about here. Could you possibly illustrate it?

The change in the graph data rendered the diode idea irrelevant, but it looks like @mikerj's solution has you well sorted!  :-+
 

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: gb
Supply decoupling/filtering, overvoltage protection and input and output protection would really ideally be needed to make this reliable for automotive use.

With regard to protection, if input signal over-voltage (e.g. in case of short to +12V) is not a problem and can be handled due to the large-value series resistance on the inputs to the op-amp, what about if the 5V reference going out to the sensor is shorted to either ground or +12V? Obviously nothing good will happen if the op-amp is suddenly hit with 12V on VCC! Especially if I am going to use something like an MCP6001, which is only rated for absolute max of 6V supply.

I had a thought: what about using a protective smart high-side switch IC on the outgoing 5V reference line? Maybe the kind commonly used on USB ports, as they're geared for 5V operation.

After a bit of browsing around, I came across the ON Semi NCP380. It has short-circuit, over-current, UVLO and reverse-voltage protection. It also allows to set a custom current limit using a resistor. So I thought maybe use one of these with the EN input tied to VIN (although not directly, as the datasheet warns against that - says to use an RC delay instead) and set a really low current limit with a resistor in the region of 100k-200k. As I understand it, GM MAP sensors consume about 20mA at most, so a current limit in the region of 50mA is probably okay.

How does this sound? Or are there better options?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
That quite a nice part, but I don't think it provides any over-voltage protection and it's voltage operating range is lower than the MCP6001.  I'd think I'd choose an op-amp with a wider supply range and then use a TVS and maybe a polyfuse for protection.  You'll want to add some resistance on the op-amp output to limit current if that is connected to something bad, it can go before the feedback resistor so any voltage drop is compensated.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1327
  • Country: gb
    • bitdynamics
The question i'd ask is "how much money are you saving"?

Making long term automotive electronics robust is actually quite hard (i should know, i do it for a living...) and yes, you could probably knock together some circuit to modify the MAP signal to the ecu, but if that messing around takes hours of your time, and leads to a car with poor reliability, then you'll wish you just bought the "expensive" MAP sensor......
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 20361
  • Country: gb
  • 0999
That quite a nice part, but I don't think it provides any over-voltage protection and it's voltage operating range is lower than the MCP6001.  I'd think I'd choose an op-amp with a wider supply range and then use a TVS and maybe a polyfuse for protection.  You'll want to add some resistance on the op-amp output to limit current if that is connected to something bad, it can go before the feedback resistor so any voltage drop is compensated.
If 12V is available anyway, then why not use the cheap and cheerful LM358?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf