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

Hardware inside and outside of the ECU
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

Beware the rail to rail bits of many op-amp limit the input voltage to less than V+1, so an op-amp powered by 5V will shunt current to the 5V rail if you exceed 6V on the input. This will cause the rail to pull up from 5V if you don't have something pulling it down.
Welcome to the friendlier side of internet crazy :)
davidbuzz
Posts: 8
Joined: Thu Jan 02, 2014 7:01 am

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

Post by davidbuzz »

Is there any particularly strong reason you are using an op-amp on each input channel? I'm looking at all those, and just thinking I could do away with them, and most of the the associated circuitry ( like all those doides too). I was thinking, that if you want a high-impedance input ( so any attached circuitry like the main ECU, when you still the original in htere) by using just one mosfet, and one resistor on each channel. ( it's a buffer circuit, like an op-amp, but less passives etc).

http://en.wikipedia.org/wiki/Buffer_amplifier
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Historically the main reason was yes high impedance and using it parallel to the stock ECU. Also amplifying to make sure the ADC is charged.

The 'parallel to stock ECU' phase is mostly over, but we would still need a voltage divider on most circuits - unfortunately stm32 adc is 3.3 volts :(

As for the next step, a simpler analog input board is in the works - it would probably have op-amps is half of the channels
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
davidbuzz
Posts: 8
Joined: Thu Jan 02, 2014 7:01 am

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

Post by davidbuzz »

russian wrote:Historically the main reason was yes high impedance and using it parallel to the stock ECU. Also amplifying to make sure the ADC is charged.

The 'parallel to stock ECU' phase is mostly over, but we would still need a voltage divider on most circuits - unfortunately stm32 adc is 3.3 volts :(
..

Actually, a mosfet does away the need for a voltage divider too. a common-drain mosfet ( http://en.wikipedia.org/wiki/Common_drain ) , where V+ is 3.3v would be adequate, so long as the chosen mosfet's V[sub]GS[/sub] is rated to allow the appropriate input voltages ( ie you can put any nominally high voltage on the mosfet's input, and it's output will only go between 0 and 3.3v). All the mosfet needs to be considered "on" is an arbitrary voltage called V[sub]GS[/sub] , which can be quite varied, depending on the mosfet ( typically anywhere from 2 to 20 volts ) , which essentially means "above that voltage is ON, below that voltage is off". I'd think that if the rotary sensors are nominally outputing a 5v pulse, then anything over 2 volts ( or 3, or 4, whatever ) could be considered "on"...?
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

When you have an 8V or 12V analog signal with little chance of exceeding 12V, a resistor divider or the common drain amplifier would work well, as you are looking just for a scaling, or impedance matching. For most automotive analog sensors, I don't know the impedance and it seems relatively non-important, so for simplicity sake I would generally use a resistor divider, followed by a clamp and low pass filter. One place this falls a bit short, is when you have a signal that can get much higher. For example, an injector driven by a voltage clamped MOSFET. The injector is 12V however the MOSFET voltage protection is often clamped around 40V to 70V. If you use a resistor divider followed by a clamp, when the clamp activates you have a low impedance, which shunts energy away from the signal wire and skews the signal being read. The issue was that we needed to look at a 12V signal with potentially up to 100V spikes.

The solution that was sought out was to use an op-amp which allows for a much higher impedance. A MCU ADC with 10k series resistor will not produce good results. However an opamp with 10k series will impedance match good enough. This meant that when the a larger signal was present on the input, and the clamp activated, the impedance was still 10K instead of 1K or less. The 10k impedance prevented manipulation of the signal, and allowed russian to work in parallel with the OEM ECU. I helped russian with the board layout for this op-amp based analog input, but I wasn't a huge fan. I prefer a much simpler approach when you know the signal, and I prefer a more universal input when you need a more universal input.

For the simpler analog inputs like TPS, ICT, ect, I prefer what I have posted in this schematic http://daecu.googlecode.com/svn/Hardware/trunk/KICAD_Project_TRK-MPC5634_P3-P4-ETPU_IO_proto/TRK-MPC5634_ETPU_IO-board-sch_RA.pdf on page 3, top left 4 circuits. I don't like the diode clamps as they shunt energy to the + rail, which can cause the + rail to rise if there is no load to pull it down. In that design, op-amp U26B was connected to a precision 5V reference such that the 5V was push/pulled to 5V and would not lift when 20mA was shunted to the + rail by the diodes when clamping. Those circuits are looking to be safe when connect to 14V like you might see if you make a mistake in wiring and wired the battery direct to an input pin, while the signal that is normally looked at is between 0-5V. So voltages between 0-5V pass with only a little 1kHz low pass filtering, while above 12V is reasonably low impedance shunted away, limiting the input to 5.3V max.

I have what I believe is a better clamp circuit, which I plan to use instead of that U26B op-amp. I have posted that clamp here http://daecu.googlecode.com/svn/Hardware/trunk/MCU_pin_protect_PCB_1channel/IO_protect_1x_schematic.pdf see middle section with Q1 and Q2. I have physically built that and I am trying to get in the basement to test it out, but have had issues with time constraints. I have my fingers crossed again to get a chance this weekend.

If that clamp circuit preforms as my simulations claims it will, it's my plan to spin a more refined analog board for russian. One that includes the above mentioned 4 circuits (with revised clamp circuit), plus a couple universal input circuits as noted in the second link.
Welcome to the friendlier side of internet crazy :)
User avatar
hasse.69
donator
donator
Posts: 77
Joined: Wed Dec 04, 2013 3:34 pm
Location: Sweden Linkoping/Vadstena

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

Post by hasse.69 »

Your da man KB1GTT.
The more i read the more i understand i need to know more.
But your schematics with examples is nothing short of brilliant.
Kudos to you for explaining.
=)
Very best regards , Hasse.
"Electronically challenged of the world, unite!"
davidbuzz
Posts: 8
Joined: Thu Jan 02, 2014 7:01 am

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

Post by davidbuzz »

Am I correct in saying that the use of optoisolators driving the injectors, and op-aps on the inputs becomes less of a concern, if you aren't trying to actually *read* high-voltage signals on a digital input or ADC? I've got no plans to connect the 12v side of the injectors ( which has noisy high-voltage back EMF, agreed ) to any of the microcontroller inputs, so I'm just still not seeing that it's "essential" to the operation of a as-basic-as-possible setup....? Of course I do think opto-isolating the injectors from the microcontroller is a cheap protection against bad wiring ( 8ft of 14ga wiring on an injector? Just make it 10ga wire, or make it 1/2 the length, and the problem's gone. )
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

Thanks for the pat on the back. I try to document not only what is needed to manufacture a device, but I also put some effort into documenting the design intent. I see it like comments in a program.

For the injector, it depends on if you are trying to control an injector, or measure an injector. When controlling an injector, you generally need to be concerned with the high-ish currents lifting the low side, which can change when the injector pintel actually delivers fuel. So lets say you have a 5mS pulse, and you drive it with 3.3V, and if the MOSET needs 2.5V at the gate referenced to the drain, if you lift the low side by .7V due to a small wire, you'll fail to turn on at all. Or if you only lift by say .5V, the on and off edges are typically rounded, and this .5V lift can cause a 5mS pulse from the MCU turn into a real world 4mS pulse at the injector. Those are two common reasons to use a MOSFET driver or opto coupler to buffer the MCU. An opto coupler can often drive a much higher voltage, or maintain a more consistent real world pulse at the injector. Another reason for the buffer is to increase the isolation voltage. The MOSFET is a single failure mode before voltage spikes can propagate up to the MCU. Opto couplers can offer a second layer before upstream issues happen. It can be better for one injector to fail, and allow the ECU to shut things down, than it is to let a spike cause unknown things to happen.

However that's not how this applies to this tread top "analog inputs" op-amp + divider - Russian". What russian was trying to do was to measure the pulses on the OEM system, then create the same pulses with his software. The issue he had was that the input had to be 100V tolerant, while he was looking for a 12V signal. He started with the shunt diodes, however that cause the injectors to fail to work. The issue was two fold. One was that when the injectors fired which caused a kick back, or over voltage protected event, the diodes would go low impedance which would manipulate the injector pulse. As well the injectors energy was dumped into the + rail which cause a variety of problems. The solution was to make a circuit that was high impedance and 100V tolerant, such that when the diodes clamped the voltage, the energy drawn away from the injector was minimal and the energy dumped to the + rail was minimal. This caused the problems to go away.

So now that russian has it working an engine, and he is no longer sniffing the injectors, he can use different simpler circuits. I've nearly got a draft ready for him to review, yippee snow day finally giving me a chance get some stuff done. I'm looking to offer the typical inputs for TPS, temperature, ect. Then also offer some universal inputs that can be used to sniff up to 500V which means you can measure the primary side of a coil. My goal is to make a development IO board that allows a developer to measure unknown signals. This generic input circuit is well protected and can easily measure from low mV signals to larger 500V signals.
Welcome to the friendlier side of internet crazy :)
User avatar
hasse.69
donator
donator
Posts: 77
Joined: Wed Dec 04, 2013 3:34 pm
Location: Sweden Linkoping/Vadstena

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

Post by hasse.69 »

So now i have ordered version 2.
Maybe i should have waited...... :?

//Hasse.
"Electronically challenged of the world, unite!"
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

hasse.69 wrote:Maybe i should have waited...... :?
Why? v 0.02 is pretty cool & powerful.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
hasse.69
donator
donator
Posts: 77
Joined: Wed Dec 04, 2013 3:34 pm
Location: Sweden Linkoping/Vadstena

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

Post by hasse.69 »

Ok , i thought that Jared was up to some new construction.
I have the resistors but where do i get hold of the op-amps.
Like this?
http://www.aliexpress.com/item/Free-shipping-VNS14NV04-40V-12A-8-SOIC-VNS14NV0-14NV-VNS14N-14NV0-VNS14-14NV04/1570042497.html
I think i will have to do a step by step for us electronically challenged :roll:
//Hasse.
"Electronically challenged of the world, unite!"
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

For 0.2 - this one - you would need three quad rail-to-rail op-amps in 14-SOIC package (quad means four channels per chip, not dual as in v 0.1)
The official one would be LMV324ID (LMV324IDR is the same thing)

"Electronically challenged of the world, unite!"
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
hasse.69
donator
donator
Posts: 77
Joined: Wed Dec 04, 2013 3:34 pm
Location: Sweden Linkoping/Vadstena

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

Post by hasse.69 »

C230 and D230 what is that.
Yes i know they are capacitor and some sort of diod.
But links pliiiiiiiiiiis.
As you can se down here :lol:
I
I
I
I
\/
"Electronically challenged of the world, unite!"
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

hasse.69 wrote:C230 and D230 what is that.http://i.imgur.com/v7T4Ps0.png
Image
This picture answers the C230 question and we would need a smarter person to elaborate on D230.
Good thing is that D230 (and other diodes) it is optional, it is just for protection. As long as you promise me not to put +12 on the input pins you should be fine.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

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

Post by abecedarian »

russian wrote:For 0.2 - this one - you would need three quad rail-to-rail op-amps in 14-SOIC package (quad means four channels per chip, not dual as in v 0.1)
The official one would be LMV324ID (LMV324IDR is the same thing)

"Electronically challenged of the world, unite!"
Any particular advantage to that op-amp as opposed to AD8659?
I mean other than the latter is around $4 in small quantity (AD does offer samples though so one could probably get enough for the board for free), and it can be powered by up to 18v which would alleviate some of Jared's concerns about getting too close to the upper rail and dumping power back to the MCU supply rail.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

The LMV324ID was chosen because it's on Seeedstudio's OPL list, as well it's available in many common sources like digikey and is often found in local electronics shops. It's widely available with good enough specs and low cost. That's why it was chosen. I'm sure other op-amps can be used but the pin outs will need to be verified before it can work.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

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

Post by abecedarian »

My question was more about functional differences than if the fab could install them, since you have mentioned concerns here and elsewhere about using 5v VCC rail-rail ops.
I did check the pin-outs and they were the same; both are 14 lead SOIC.

But I forgot you were using Seeed and their assembly services. Did you ever check in to Elecrow? They can do parts sourcing if needed.
You can lead the horticulture but you can't make them think.
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

I forget exactly why, but I got shaky in the knee's with http://www.elecrow.com/ I seem to recall they had some complaints on the internet about quality, and I seem to recall they were un-clear about what exactly there part sourcing entailed. For example, it doesn't appear they will put those parts on a PCB, but perhaps it does. I can't tell from here.
Welcome to the friendlier side of internet crazy :)
User avatar
abecedarian
Posts: 386
Joined: Fri Nov 15, 2013 10:49 am

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

Post by abecedarian »

They had decent reviews by people over on 43oh.com as an alternative to Osh, Seeed and others.

Anyhow, it was just a thought that if they can source any part and assemble boards it might open up some design options. ;)
You can lead the horticulture but you can't make them think.
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Digikey BOM added to the top post
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
kb1gtt
contributor
contributor
Posts: 3777
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

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

Post by kb1gtt »

Digikey BOM updated to correct buggered diodes. Digikey BOM found here https://www.digikey.com/classic/RegisteredUser/BOMBillOfMaterials.aspx?path=1&exist=1&id=1504225 replacement diode is BAS70-04FILM
Welcome to the friendlier side of internet crazy :)
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Q: What is the purpose of the OP AMPs on this board?

A: two reasons:
1) op-amp isolates the voltage divider from the input circuitry - this way we are not affecting whatever is going on in the input wire, this means we can attach this input board in a slave mode with the original ECU still on while we want to just sniff what's going on. This case we are not using the pull-up or pull-down resistors, we are just following and divinding the input voltage.
2) extra protection for the MCU ADC
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Ops:
We have an issue with the schematics: op-amp channel #3 pinout is wrong:
Image
but we have
Image
and this is wrong:
Image

This affects the 'Adc Amp 12ch rev 0.2' module, but this DOES NOT affect Frankenstein because on Frankenstein apparently the board does not follow the schematics:
Image
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
mobyfab
Posts: 141
Joined: Tue Oct 29, 2013 10:09 am
Location: Le Mans, France

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

Post by mobyfab »

Why did you put the divider after the opamp ?

The higher output resistance might affect the ADC. (but no much)
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

mobyfab wrote:Why did you put the divider after the op-amp?
So that I can use this schematic to sniff wires while the stock ECU is running the engine.

These resistor values should be fine four stm32 ADC.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
mobyfab
Posts: 141
Joined: Tue Oct 29, 2013 10:09 am
Location: Le Mans, France

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

Post by mobyfab »

I see :)

Yeah the ADC has 1kohm/8pF input so it should not affect it too much.
User avatar
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

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

Post by UnaClocker »

Why use op amps at all? Just adds more cost to the BOM and more complexity to the build of the board. More components to fail (as you've already experienced). You can simply use voltage dividers. ECM's all over the world have had 5v CPU's for decades, and 12v electrical systems, they simply use a voltage divider to get the 12v down to 5v. You can do the same thing to get down inside the 3.3v range. Even with 0-5v signals coming in like the TPS (if you can't just run the TPS off 3.3v) or a wideband O2 sensor (you can recalibrate some of them to give a 0-3.3v signal).
That's about the only signals that you're going to get that are over 3.3v, everything else is based off the reference voltage you feed to it (coolant/air temp sensors, crank sensors (which would come in as digital anyways), etc)..
edit: also, as for protecting the MCU, just put a 10k inline between the voltage divider and the MCU, it'll prevent enough current from flowing to damage the chip.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
User avatar
UnaClocker
Posts: 46
Joined: Tue May 13, 2014 12:14 am
Location: Tacoma, WA

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

Post by UnaClocker »

Yeah, I only read page 1, didn't notice the extra pages before replying. Fair enough.
Brian from Tacoma, WA
84 Dodge Rampage
01 PT Cruiser
User avatar
AndreyB
Site Admin
Posts: 14727
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

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

Post by AndreyB »

Question about the rail-to-railness of out op-amps.

Supply voltage is 4.5v (board powered via USB), input is a 10K pull-up - to the same 4.5v
What is the expected op-amp output? Because I am getting 3.9v, is that expected, or is it supposed to be higher? Wonder if the cheap op-amps do not perform well or if that's in my head.

The datasheet is @ http://www.ti.com/lit/ds/symlink/lmv324.pdf but after 120 seconds of reading I cannot produce the answer.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Post Reply