I am working on a project for a cruise control device activation using my cars oem buttons with an aftermarket ecu. I want to have as robust system as possible and I am creating my own PCB for this solution. Now the reason of robustness is that I do not want to activate the cruise control by accident (of course there are a lot of safety features that can be added from the car ECU directy but regardless I want my control (on/off) module to also be safe).
The setup:
The important piece is that i have 3 inputs ,
12+ voltage
ground
Steering wheel Button Signal
Then I use a voltage regulator that turns 12V to 5V for the ATMEGA.
The ATMEGA based on the input signal it sets the state of a pin to high. This pin (D10) activates an LED for now but in reality this will be setting a high signal to the car ECU.
The problem:
Everything works as expected and it is flawless - have been running this on my desk for few days and all looks good. However when I remove the input ground (simulating a wiring fault) them all the pins of the ATMEGA turn to high. so basically from what I can tell is that it is closing loop via the grounded LED that is connected to the output pin.
My explored solution:
Try to avoid closing the loop using an optocoupler but that makes the setup messier. it is very common in automotive for all devices to use the car chassis as the common ground. How other devices avoid closing loop via an unwanted path and using a singe wire to communicate from device A to device B?
Welcome to the wonderful world of automotive electronics. That is what I would expect. Try measuring from the Arduino ground to the output, that should be your reference ground not the chassis ground. I expect at that point it will be zero but the port pin will be high when referencing the chassis ground. There are a lot more things hiding in the corner waiting to bite you. Also if that is considered a safety device in your country there are a lot of laws and regulations in place you need to follow. For me I have seen them fail and it is not nice. Here is some reading for you:
CC_SIGN is the signal from pressing the button. However that is somewhat irrelevant as the main issue is that without ground all pins are activate / high as they are grounded via the output pin
The output is D10 - thats where I have an LED connected and then to GND. This is not shown on the diagram as the LED is used just for testing and it is not part of the original diagram
They are not active, they are being pulled high by the ESD protection diodes. You need a voltage potential to turn on the internal processor FET, with out ground you do not have that. Basically each pin has a diode to + and another to ground to limit the ESD transients etc to the power rails. Many times they now run a separate ground wire because as the body corrodes its resistance increases, this decreases the noise margin of the electronics. Where are you going to mount your module?
They also do high side switching because if there is a short most probably to the chassis the load will not turn on.
Thank you for the explanation in regards to the ESD diodes. Do you have a recommendation on how to avoid this? I had some success where the output is connected to optocoupler so that the loop does not close if the ground is not present but keen to know what people think the right solution is.
The device will be mounted behind the steering wheel column under the dash, in the car.
Well generally you want to disconnect when there is no GND, so a simple solution would be to put a (power) PNP transistor between the 12v and the 5v regulator and drive this with a resistor to the GND of the ATmega.
I would also anyway add an extra (high current) diode like a 1N4001 (or 1N4007) between the GND of the ATmega and the car chassis to prevent inverted voltage.
I tried this with a p channel mosfet but the current that leaks from the output pin activates the mosfet (at it grounds it externally) - I assume the same will happen with relays
Shouldn't this diode be at the entry point of the circuit to protect all?
I had a look, I added some TVS in my entry point - However I am wondering in modern cars after 2000 they use BCM (body control module) and that powers other modules. Wouldn't the BCM take care of electric surge etc so that the lines after the BCM are safe to tap in?
Well yes, i suppose. At the entry point of the entire circuit.
This grounded LED is part of the entire circuit. All of the GND's of this circuit can not be disconnected individually
That would mean you remove all GND's from the circuit. If there is a LED that just uses Chassis GND then you should use an Opto-coupler that does use circuit GND to drive this 'external' LED
A Mosfet may remain open if not explicitly closed.
Firstly the voltage regulator emits current even without ground, however it is not regulated correctly , I,e not 5 Volts.
To solve that I used a P channel mosfet after the regulator that is off when the ground is not connected.
Then I observed that with this solution the problem was reverse voltage leaking from both (or at least one - the one that is connected) the mosfet gate that connects to ground via the voltage divider or the regulator and that was feeding the ATMEGA328... my temp solution was to use a diode on the ground line that feeds the ATMEGA328 and this seems to work, however I had more that one component that are grounded (logic buffers ICs, and another ATMEGA328 etc)...
I would assume that the correct solution is to use 2 diodes , on for the regulator ground and one for the mosfet gate instead of one at every single IC component.. Is that the way to go? what would you suggest?