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

Hardware inside and outside of the ECU
User avatar
andreika
donator
donator
Posts: 461
Joined: Mon Feb 13, 2017 2:35 pm
Location: Kiev

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

Post by andreika »

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: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

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

Post by puff »

doubling the number of chips? plus I bet that would make configuring much more complicated.
User avatar
mobyfab
Posts: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

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: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

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

Post by Rhinoman »

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: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

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

Post by stefanst »

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: 2961
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

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

Post by puff »

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: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

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

Post by stefanst »

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: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

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

Post by Rhinoman »

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 »

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: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

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 »

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: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

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

Post by Rhinoman »

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: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

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: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

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/groups/sitecomm_sg/documents/training_tutorials/en528065.pdf
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

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

Post by Rhinoman »

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: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

By output I meant the opamp's which is connected to the ADC input.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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: 139
Joined: Tue Oct 29, 2013 10:09 am
Location: Versailles, France

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

Post by mobyfab »

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: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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

http://www.st.com/content/ccc/resource/technical/document/application_note/9d/56/66/74/4e/97/48/93/CD00004444.pdf/files/CD00004444.pdf/jcr:content/translations/en.CD00004444.pdf

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/3f/4c/a4/82/bd/63/4e/92/CD00211314/files/CD00211314.pdf/jcr:content/translations/en.CD00211314.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/HEAD/tree/Hardware/trunk/Stervo/misc/BTS7960_IS-toVis_simulation.sch?format=raw
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

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

Post by stefanst »

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: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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%2C113-NXP-Semiconductors-datasheet-8749550.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: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

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

Post by stefanst »

So, what would a safer way to handle 12V digital inputs be?
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

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 22360 times
Welcome to the friendlier side of internet crazy :)
stefanst
contributor
contributor
Posts: 703
Joined: Wed Feb 17, 2016 12:24 am
Location: USA 08530

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

Post by stefanst »

That makes perfect sense- thanks!
Rhinoman
contributor
contributor
Posts: 256
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK

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

Post by Rhinoman »

If its battery voltage then you need to ensure that the input pin voltage will be valid over the range of possible battery voltages. Also if you're not feeding into a schottky input then you will need to meet the minimum rise time requirement.
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

He has a digital 12V or 0V signal which needs to be captured, so he only cares about safely detecting a 1 or 0 state.
Welcome to the friendlier side of internet crazy :)
Post Reply