analog inputs: op-amp + divider - Russian - now MCP6004

Hardware inside and outside of the ECU
User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by mobyfab » Mon Apr 10, 2017 9:47 am

kb1gtt wrote:The input can go for that range, the issue is the output. That ST chip is much better about actually being a rail to rail chip. Is .2V either rail close enough? See page 6 for VCC = 5V found in aneox's link. Snippet below.
ST_LMV324_rail.PNG
Using the same opamp on my design, I have the same behavior, about .2V.
Also using 10K resistors dividers driving the STM32 ADC on the output reduces the GBWP to around 100kHz.

MCP6294 seems a better choice but it's like 3 times the cost.

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Mon Apr 10, 2017 10:21 am

Yeah, this entire rail to rail is not really rail to rail is kind of a pain. If we were to look at the dynamic accuracy, not just the DC accuracy, we would likely see some skewing as we approach the rails. Basically if you run like a 10kHz 1mVp-p signal at 0.2Vdc you'll likely see some skewing, even though your DC issues happen at a lower voltage. We luck out as this skewing is not a huge deal for our low frequency inputs.

I seem to recall that I tested like 4 or 5 op-amps when we made the decision to switch to what we have now. I recall we found one that was something like 20mV or 50mV closer to the rail, but was like 4X the cost. I also seem to recall it was the same pin-out so if someone wanted to spend an extra couple bucks they could change to that op-amp and get slightly closer to the rails. However we decided that for the extra couple bucks, the difference of 0.200V vs 0.180V to 0.150V was not worth the money. Especially sense most signals are 1V away from the rails any how.

I also recall that there are some op-amps out there that have very small internal rail voltage generating circuits, such that they generate like 1V above and below the provided rails. By creating this internal virtual rails, allows those near rail circuits to be true rail to rail. Basically it allows them to deal with bias currents, which is what causes the issues at the rails. However those are rare and very costly. I recall they were like 20X the cost and hard to find. Also good luck that they don't go obsolete and have sourcing issues.
Welcome to the friendlier side of internet crazy :)

User avatar
andreika
donator
donator
Posts: 417
Joined: Mon Feb 13, 2017 2:35 pm
Location: Kiev

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by andreika » Mon Apr 10, 2017 10:47 am

kb1gtt wrote:there are some op-amps out there that have very small internal rail voltage generating circuits
There's also an option to use an external negative bias circuit like LM7705 - it's not that expensive...

puff
contributor
contributor
Posts: 2738
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by puff » Mon Apr 10, 2017 11:17 am

doubling the number of chips? plus I bet that would make configuring much more complicated.

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by mobyfab » Mon Apr 10, 2017 1:34 pm

andreika wrote:
kb1gtt wrote:there are some op-amps out there that have very small internal rail voltage generating circuits
There's also an option to use an external negative bias circuit like LM7705 - it's not that expensive...
That might actually work.
Especially that you don't need one per channel.

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by Rhinoman » Mon Apr 10, 2017 2:55 pm

rail-to-rail isn't usually needed because most sensors won't go that close to the rails, anything near to rail is generally flagged as short-circuit or open-circuit. For digital inputs you should really be using comparators, those are usually open-collector so the output can be pulled up whatever voltage is appropriate.

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Mon Apr 10, 2017 6:26 pm

The LM7705 is interesting. I'd be concerned about creating a large virtual ground. I guess the first item that would need to be answered, is do we need complete rail to rail? Is someone having a problem with the rails?
Welcome to the friendlier side of internet crazy :)

stefanst
contributor
contributor
Posts: 579
Joined: Wed Feb 17, 2016 12:24 am

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by stefanst » Mon Apr 10, 2017 6:52 pm

Temperature sensors and Vbatt under even remotely normal conditions should not get close to the rails. The only "normal" sensors where I could see us getting close would be TPS, MAP and wideband EGO. So far I have not seen any evidence that getting close to the rails is an issue with standard frankenso hardware.

puff
contributor
contributor
Posts: 2738
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by puff » Mon Apr 10, 2017 7:09 pm

What about short and open circuit conditions as indicators of nasty connector or faulty sensor?
Some wideband o2 implementations seem to have those rail voltages as normal output..

stefanst
contributor
contributor
Posts: 579
Joined: Wed Feb 17, 2016 12:24 am

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by stefanst » Mon Apr 10, 2017 8:01 pm

For WB EGO I would like to reject any extreme values anyway and default to turning off closed loop behavior if we get close to the edge (i.E lambda < 10 or >19).

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Mon Apr 10, 2017 9:14 pm

Frankenso has pull down resistors which should pull to an extreme if a wire is broken, ect. This might technically not be 0 on the ADC reading, but it would be reasonably close and consistent. Then your normal operation ADC values are not likely to come close to this extreme value.
Welcome to the friendlier side of internet crazy :)

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by Rhinoman » Tue Apr 11, 2017 7:53 am

stefanst wrote:Temperature sensors and Vbatt under even remotely normal conditions should not get close to the rails. The only "normal" sensors where I could see us getting close would be TPS, MAP and wideband EGO. So far I have not seen any evidence that getting close to the rails is an issue with standard frankenso hardware.
In my experience TPS is usually less than a 4V swing and MAP is 0.25V to 4.75V.

DaWaN
Posts: 51
Joined: Sat Sep 20, 2014 6:54 pm
Location: Benschop, Netherlands

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by DaWaN » Tue Apr 11, 2017 11:38 am

mobyfab wrote:
kb1gtt wrote:The input can go for that range, the issue is the output. That ST chip is much better about actually being a rail to rail chip. Is .2V either rail close enough? See page 6 for VCC = 5V found in aneox's link. Snippet below.
ST_LMV324_rail.PNG
Using the same opamp on my design, I have the same behavior, about .2V.
Also using 10K resistors dividers driving the STM32 ADC on the output reduces the GBWP to around 100kHz.

MCP6294 seems a better choice but it's like 3 times the cost.
I am wondering why you would need such a huge GBWP from the opamp. Most sensors are very slow and I would assume the GBWP of 1MHz of the MCP6004 would be sufficient here?
kb1gtt wrote:The LM7705 is interesting. I'd be concerned about creating a large virtual ground. I guess the first item that would need to be answered, is do we need complete rail to rail? Is someone having a problem with the rails?
I think the current opamp will do fine. As already said by others: it is best to avoid using sensors near the rails. Most sensors which have some sort of logic / amplification internally rarely output voltages up/down to the rails.

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by mobyfab » Tue Apr 11, 2017 1:16 pm

DaWaN wrote:
mobyfab wrote:
kb1gtt wrote:The input can go for that range, the issue is the output. That ST chip is much better about actually being a rail to rail chip. Is .2V either rail close enough? See page 6 for VCC = 5V found in aneox's link. Snippet below.
ST_LMV324_rail.PNG
Using the same opamp on my design, I have the same behavior, about .2V.
Also using 10K resistors dividers driving the STM32 ADC on the output reduces the GBWP to around 100kHz.

MCP6294 seems a better choice but it's like 3 times the cost.
I am wondering why you would need such a huge GBWP from the opamp. Most sensors are very slow and I would assume the GBWP of 1MHz of the MCP6004 would be sufficient here?
kb1gtt wrote:The LM7705 is interesting. I'd be concerned about creating a large virtual ground. I guess the first item that would need to be answered, is do we need complete rail to rail? Is someone having a problem with the rails?
I think the current opamp will do fine. As already said by others: it is best to avoid using sensors near the rails. Most sensors which have some sort of logic / amplification internally rarely output voltages up/down to the rails.
I need it for the knock sensor (sampling at 115kHz), but in this case the GBWP is more than sufficient indeed.
I agree, we should not care about values near the rails, as the sensors should not go anywhere near that, it should be used to detect open loops.

DaWaN
Posts: 51
Joined: Sat Sep 20, 2014 6:54 pm
Location: Benschop, Netherlands

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by DaWaN » Tue Apr 11, 2017 2:03 pm

mobyfab wrote: I need it for the knock sensor (sampling at 115kHz), but in this case the GBWP is more than sufficient indeed.
I agree, we should not care about values near the rails, as the sensors should not go anywhere near that, it should be used to detect open loops.
I would not use the same topology for knock sensors as for the rest of the sensors.
You probably want to ditch DC and create some sort of band pass filter for the knock sensor: this already solves your rail-to-rail problem as you can bias this circuit at 2.5V.
I would also design the circuit to accept a differential input and not use the ground of the engine block as it would be electrically noisy.
Not sure what (OEM) application you are using: but if I would be building from scratch I would run a shielded wire with two conductors from the knock sensor to the ECU.

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by Rhinoman » Tue Apr 11, 2017 2:53 pm

mobyfab wrote:I need it for the knock sensor (sampling at 115kHz), but in this case the GBWP is more than sufficient indeed.
What is the bandwidth of the ADC?

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - LMV324IDT

Post by mobyfab » Tue Apr 11, 2017 3:20 pm

DaWaN wrote:
mobyfab wrote: I need it for the knock sensor (sampling at 115kHz), but in this case the GBWP is more than sufficient indeed.
I agree, we should not care about values near the rails, as the sensors should not go anywhere near that, it should be used to detect open loops.
I would not use the same topology for knock sensors as for the rest of the sensors.
You probably want to ditch DC and create some sort of band pass filter for the knock sensor: this already solves your rail-to-rail problem as you can bias this circuit at 2.5V.
I would also design the circuit to accept a differential input and not use the ground of the engine block as it would be electrically noisy.
Not sure what (OEM) application you are using: but if I would be building from scratch I would run a shielded wire with two conductors from the knock sensor to the ECU.
I did most of that. There's a DC blocking cap, it's biased at 1.65v, there's no resistor on the output except the one inside the ADC (1k, 8pF sampling cap)
I still use the chassis ground, maybe I'll change that.
I use the OEM knock sensor from a Honda bike, it has a shielded wire, ground and signal.
So far so good.

Image
Rhinoman wrote:
mobyfab wrote:I need it for the knock sensor (sampling at 115kHz), but in this case the GBWP is more than sufficient indeed.
What is the bandwidth of the ADC?
Not sure about the bandwidth since it probably depends on the opamp output, but the sampling rate it 5.14Mhz max on one ADC.

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by mobyfab » Thu Apr 20, 2017 12:39 pm

Image

I'm not sure about which resistors you are using on output (if you are using any) but this might help.

Currently I have a 400mV headroom on my sensors output, using a 1/2k bridge (5v->3.33v)
Since the sampling is at only 1kHz I will try to increase those to 10/20k and see if it improves according to the graph.

http://www.microchip.com/stellent/group ... 528065.pdf

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Thu Apr 20, 2017 11:05 pm

Frankenso does not have any analog outputs. It has several analog inputs, but no outputs.

What is an application which would need an analog output?
Welcome to the friendlier side of internet crazy :)

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by Rhinoman » Fri Apr 21, 2017 7:59 am

kb1gtt wrote:Frankenso does not have any analog outputs. It has several analog inputs, but no outputs.
What is an application which would need an analog output?
I don't know why you asked this but in the past when I've needed to generate an analogue signal then I've just feed a PWM signal into an integrator. One example was an ECU that needed variable thresholds for the peak-hold drivers to support different injectors

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Fri Apr 21, 2017 10:30 am

I've done similar for analog outputs, but I generally follow it with an op-amp such that you have a controlled impedance for the low pass filter. I still don't know why an ECU needs an analog output.
Welcome to the friendlier side of internet crazy :)

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by mobyfab » Fri Apr 21, 2017 11:31 am

By output I meant the opamp's which is connected to the ADC input.

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Fri Apr 21, 2017 11:11 pm

I seem to recall the STM32's impedance varies from 1k to 10k depending mostly on the ADC's clock frequency. We are using 2x series 1.5k, so the op-amp is seeing something below 3k.
Welcome to the friendlier side of internet crazy :)

User avatar
mobyfab
Posts: 138
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France
Soldering skill: yes
Coding skill?: yes

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by mobyfab » Sat Apr 22, 2017 1:17 am

The ADC is always 1K/8pF as far as I know.

So increasing resistor values might help here. ;)

Edit: it's up to 6k, at 1.8V. Gets lower as VDD increases. Sampling cap is 4pF for F405 devices.
It does not change with frequency. (maybe you are referring to "Rain" which is the max source impedance for a given frequency)

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Sat Apr 22, 2017 9:39 am

See "Rain" and "Radc" in the below PDF's.

http://www.st.com/content/ccc/resource/ ... 004444.pdf

http://www.st.com/content/ccc/resource/ ... 211314.pdf

Also keep in mind that the clamping diode leakage and diode capacitance also skews the ADC readings. Theoretically you could post-warp your ADC readings to get a more accurate representation of what is happening in the real world.

For a different project, I did this QUCS simulation. I was looking to predict the readings that I would get from a particular current sensor, that is intergrate into a motor driving chip.
ImageSource QUCS file found here https://sourceforge.net/p/daecu/code/HE ... format=raw
Welcome to the friendlier side of internet crazy :)

stefanst
contributor
contributor
Posts: 579
Joined: Wed Feb 17, 2016 12:24 am

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by stefanst » Sun Jul 30, 2017 1:44 am

I need some digital high-side-switched inputs. Is there any reason not to use a simple resistor/zener-diode arrangement?

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Sun Jul 30, 2017 1:39 pm

Speed of the zener will be important. Keep in mind the STM32's inputs have fast rail clamping diodes, so if you exceed the rail voltage it will dump energy to one of the +V rails. I'm assuming that's the 5V rail, but it could be the 3V rail. If the zener doesn't kick in fast enough, then the STM's +V will dump the energy. This energy on your +V rail will likely skew your analog signals, and perhaps it would do other odd things.

How much heat will it make? Running 12V at 1mA which is clamped by a 5V zener will be 5V * 1mA = 5mW. Is 1mA enough current? Would the diode have good enough heat sinking to keep the temperature down with what ever it's dissipated watts are?

If the zener fails for some reason, you'll destroy the STM32, and who knows what will happen to the outputs if a port is blown. So keep in mind the failure modes. AKA does a failed port cause fuel injectors go to 100%, or does it cause the analog MAP to register as 100%?

Also keep in mind you'll probably need a 4.7V or perhaps lower zener to get 5V protection. I seem to recall that 4.7V is what you get at 10mA, and if you run 1mA, your voltage will be higher, perhaps close to 5V. Keep an eye on the diode's curve. Also keep in mind that curve changes with temperature. So bench top vs hot day of operation will change that curve. You might want to check the datasheet for the specific pin you plan to use. I believe most IO will trigger as a guaranteed digital 1 at like 2.7V. So you probably want a 4.1V zener. AKA if it gets hot and wanders lower you are still OK, and if wanders higher for some reason you still have head room before the STM32's ESD diodes kick in.

See figure 2 at the below. Notice how the voltage changes if you get warm.
http://datasheet.octopart.com/1N4728A%2 ... 749550.pdf

I would say you can probably get it to physically work, but you might be a bit weak on failure modes.
Welcome to the friendlier side of internet crazy :)

stefanst
contributor
contributor
Posts: 579
Joined: Wed Feb 17, 2016 12:24 am

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by stefanst » Sun Jul 30, 2017 11:32 pm

So, what would a safer way to handle 12V digital inputs be?

User avatar
kb1gtt
contributor
contributor
Posts: 3488
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by kb1gtt » Mon Jul 31, 2017 1:31 am

I would suggest cutting and pasting from the op-amp circuit. See this marked up version which is based on the 12V battery sensing circuit. Basically it's 1mA resistor divider, followed by current limiting 10k resistor, rail dumping diodes, and low pass filter. Also note that if you do not have any thing connected to the circuit, it will pull to 0V. I'm not sure if this works for you, but it will probably get you started. I like the resistor divider as those have better temperature stability. I generally also try to make it such that a failed wire connection an be detected via analog MUX. However that's not likely to be implemented in software for this.
Attachments
Untitled.png
Untitled.png (13.55 KiB) Viewed 2482 times
Welcome to the friendlier side of internet crazy :)

stefanst
contributor
contributor
Posts: 579
Joined: Wed Feb 17, 2016 12:24 am

Re: analog inputs: op-amp + divider - Russian - now MCP6004

Post by stefanst » Mon Jul 31, 2017 3:25 pm

That makes perfect sense- thanks!

Post Reply