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

0 Members and 1 Guest are viewing this topic.

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.
If 12V is available anyway, then why not use the cheap and cheerful LM358?

12v typically isn't available on the sensor wiring, they run from a 5v reference.  He could run another wire but a module that just sits inline with the sensor would be much neater.
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7855
  • Country: au
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.

The OP isn't using it in an automotive application, see part of post I emphasised in red.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
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.


Could you explain your circuit a little.  I see how you offset the voltage and match the gain of the original sensor, but don't see how you modified the output (slope) to make the GM sensor match the original sensor.  Please explain; sometimes I can be a little slow.  Thanks.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4705
  • Country: au
  • Question Everything... Except This Statement
Here is the breakdown, it is a normal differential amplifier summed with a fixed offset voltage,
« Last Edit: July 05, 2019, 11:19:23 am by Rerouter »
 
The following users thanked this post: HwAoRrDk

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
Could you explain your circuit a little.  I see how you offset the voltage and match the gain of the original sensor, but don't see how you modified the output (slope) to make the GM sensor match the original sensor.  Please explain; sometimes I can be a little slow.  Thanks.

Gain and slope are effectively the same thing, the higher the gain of the amplifier, the steeper the slope at the output.  The gain we need is = Slope Original / Slope GM ~ 1.277
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
The multipliers across the pressure range are specifically as follows:

Bar:             0.5             1.0            1.5            2.0             2.5
Multiplier:   1.029   1.145   1.183   1.202   1.213

I'm probably complicating this more than necessary, but from the chart, above, given by the OP, the sensor output requires a different multiplier (gain) at the different pressures in order for the new sensor to match the original sensor output.  A fixed multiplier would seem to address the output difference at only one point.  It would seem that a variable gain amp, or as a previous poster stated, a MPU with a look-up table, to set the output per the new input levels, would be what's needed???  What am I missing?  (I told you I can be a little slow.)  Thank you.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline sokoloff

  • Super Contributor
  • ***
  • Posts: 1799
  • Country: us
The multipliers across the pressure range are specifically as follows:

Bar:             0.5             1.0            1.5            2.0             2.5
Multiplier:   1.029   1.145   1.183   1.202   1.213

I'm probably complicating this more than necessary, but from the chart, above, given by the OP, the sensor output requires a different multiplier (gain) at the different pressures in order for the new sensor to match the original sensor output.  A fixed multiplier would seem to address the output difference at only one point.  It would seem that a variable gain amp, or as a previous poster stated, a MPU with a look-up table, to set the output per the new input levels, would be what's needed???  What am I missing?  (I told you I can be a little slow.)  Thank you.

Probably just missing this later update from OP:

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.

 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: au
The multipliers across the pressure range are specifically as follows:

Bar:             0.5             1.0            1.5            2.0             2.5
Multiplier:   1.029   1.145   1.183   1.202   1.213

I'm probably complicating this more than necessary, but from the chart, above, given by the OP, the sensor output requires a different multiplier (gain) at the different pressures in order for the new sensor to match the original sensor output.

You are right in that you would have to mess with different gain values for different pressures IF all you had was gain. But mikerj's circuit has gain AND OFFSET.  You're missing the offset part. With a fixed gain and a fixed offset, a nearly perfect conversion is achieved.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Got it!! :-+
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1327
  • Country: gb
    • bitdynamics
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.

The OP isn't using it in an automotive application, see part of post I emphasised in red.

er, the OP hasn't actually said what the application is have they? All the talk has been about "engine vacuum" and "boost pressure" etc, so i was thinking the application is automotive??
 

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • 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.

It does provide over-voltage protection: "An internal reverse-voltage detection comparator disables the power-switch if the output voltage is higher than the input voltage to protect devices on the input side of the switch." I found it because it is one of the few USB-focused high-side switches that actually does that; most only give reverse-current protection when off and don't prevent the output going higher than input.

I'm not concerned with over-voltage on the 5V reference supply feeding this circuit. The existing sensor is actually contained within the device's enclosure (have to run a hose to it, which is inconvenient, thus part of my motivation for replacing it), and this add-on circuitry, while 'in-line', would live there too, so there is no possibility of wire shorts, etc. between the device and it. And if the device's 5V rail goes over-voltage, then the device itself has probably had the magic smoke escape, so the continued functionality of this op-amp circuitry becomes immaterial! :) With a new external remote pressure sensor however, there becomes a risk of incorrect connection, shorts, etc. on wiring so I think it is indeed right to give attention to some protection, but only that side.

Oh, also, the device itself already has some series resistance on the sensor input signal (and hence to be on op-amp's output): a 1K/470pF low-pass filter. Not much, but it's something.
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
Just because I'm nosy, and after all this, and if it's not a big secret, what is the application??  :-//   Just very Curious.
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Online HighVoltage

  • Super Contributor
  • ***
  • Posts: 5560
  • Country: de
Some of the modern automotive pressure sensors are no longer analog.
The new types are digital and can be programmed.
And they run at about 1000 Hz update rate.
Many of them even have a temperature compensation.

 
There are 3 kinds of people in this world, those who can count and those who can not.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1327
  • Country: gb
    • bitdynamics
Some of the modern automotive pressure sensors are no longer analog.
The new types are digital and can be programmed.
And they run at about 1000 Hz update rate.
Many of them even have a temperature compensation.

https://en.wikipedia.org/wiki/SENT_(protocol)

 

Offline JustMeHere

  • Frequent Contributor
  • **
  • Posts: 826
  • Country: us
Micro with ADC and DAC. Then let the micro do the math.
« Last Edit: July 07, 2019, 02:46:26 am by JustMeHere »
 

Offline HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1607
  • Country: gb
Back at looking at this again after the weekend, and I thought I would knuckle down and get my brain in gear to try and understand how the resistance values mikerj arrived at for the differential op-amp circuit were calculated.

Once it twigged about the relationship between slope of the line and gain (i.e. they're the same thing - and mikerj basically said so already! :palm:), and that I could calculate the slope trivially using a spreadsheet function, I thought I would work out exactly what the gain figure should be for the differential amplification. It worked out to be a slightly different value: 1.258, versus the 1.277 mikerj estimated. Using this new figure in a diff. op-amp circuit calculator, I came out with resistor values of 120k & 150k.

However, simulating the circuit with these new resistance values actually gave a slightly greater error than the original. However, the, err... parallelism? of the line on the graph matched that of the original sensor's much better; the old values actually had worsening error towards the bottom of the pressure range (as much as 5% at 0.25 Bar). All it appeared I needed to do to get a better match was to bump the output up a tad, and so I guess this is where the offset voltage divider comes in. After playing around a bit, I settled on changing the 6.8k to 7.5k, which netted me <1% error across the board. :D

Here's a graph of the results:



I'm still not clear about how the offset voltage figure was arrived at, though. Is it simply the distance on the graph between where the original sensor intersects zero on the Y-axis and the Y-value of the same horizontal point for the GM sensor? That appears to be around 0.15V, which matches what a 6.8k/220R divider gives when supplied with 5V. But the 7.5k/220R I experimentally ended up with is kind of away from that, at 0.142V... :-//
 

Offline GerryR

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: us
My guess would be that the sensor outputs are not as "linear" as indicated on the data sheets, and the values given are more nominal than exact.  I think your method of measuring, and then adjusting to suit, is the best approach. 
Still learning; good judgment comes from experience, which comes from bad judgment!!
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: gb
Back at looking at this again after the weekend, and I thought I would knuckle down and get my brain in gear to try and understand how the resistance values mikerj arrived at for the differential op-amp circuit were calculated.

Once it twigged about the relationship between slope of the line and gain (i.e. they're the same thing - and mikerj basically said so already! :palm:), and that I could calculate the slope trivially using a spreadsheet function, I thought I would work out exactly what the gain figure should be for the differential amplification. It worked out to be a slightly different value: 1.258, versus the 1.277 mikerj estimated. Using this new figure in a diff. op-amp circuit calculator, I came out with resistor values of 120k & 150k.

I did say I got the gains from eyeballing the charts!  If you have raw data you can fit a line to, it will be far more accurate.

I'm still not clear about how the offset voltage figure was arrived at, though. Is it simply the distance on the graph between where the original sensor intersects zero on the Y-axis and the Y-value of the same horizontal point for the GM sensor? That appears to be around 0.15V, which matches what a 6.8k/220R divider gives when supplied with 5V. But the 7.5k/220R I experimentally ended up with is kind of away from that, at 0.142V... :-//

Look at the diff-amp circuit and imagine the MAP sensor input is held at a fixed voltage.  The other arm which the divider is connected to is effectively an inverting amplifier, and it's gain is greater than unity (1.25 in this case) so whatever voltage you provide from the divider will be amplified by that gain.  In other words if you change the gain you will have to change the voltage at the divider to maintain the same offset voltage.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf