How to detect automotive brake 12v signal for feeding into microcontroller? - Page 1
Forum section: electronics / beginners

author: Heisen
author_rank: Contributor
timestamp: September 15, 2020, 04:48:42 pm
content: Hi,I want to detect some 12v signals like brake, parking, turn, reverse etc in my car and feed into microcontroller.The requirements of microcontroller for detecting an input are :-1. The Arduino (ATmega) will report HIGH if: a voltage greater than 3.0V is present at the pin2. The Arduino (ATmega) will report LOW if: a voltage less than 1.5V is present at the pinAs you see I just want to detect ON/OFF signal nothing else. Also the voltage at the pin cannot be higher than 5v.Here is the circuit that I am going to use :-Using the voltage divider to half the voltage, further zener diode with breakdown voltage of 4.7V to clamp the voltage down to acceptable levels and a capacitor for smoothing the pulse.Note :- Many circuits recommend using an optocoupler for this job which I want to avoid.The problem which worries me is this :-The automotive environment is very harsh and full of noise, like you see above. The voltage can be all over the place. Is the circuit above robust enough to survive this?Thanks.

author: Alti
author_rank: Frequent Contributor
timestamp: September 15, 2020, 05:22:24 pm
content: CAN.

author: jfiresto
author_rank: Frequent Contributor
timestamp: September 15, 2020, 05:36:23 pm
content: Yes, it would be quite helpful to know the age of the target vehicle. A more modern one might have CAN or perhaps a proprietary bus, and will have a central suppressor to clamp load dumps to something like 35-40V.It might also be help to know the minimum supply current the microcontroller will draw.

author: David Hess
author_rank: Super Contributor
timestamp: September 15, 2020, 06:07:49 pm
content: What you suggest will work, but I like to use an optocoupler for that sort of thing even though galvanic isolation is not required because it will better protect against ESD and EMI.

author: Heisen
author_rank: Contributor
timestamp: September 15, 2020, 06:40:58 pm
content: The minimum supply current the microcontroller will draw will be 7uA in sleep mode and 17mA in running mode.Car is from 2004 skoda octavia mk1.What does CAN mean?

author: Heisen
author_rank: Contributor
timestamp: September 15, 2020, 06:42:47 pm
content: CAN?

author: Zero999
author_rank: Super Contributor
timestamp: September 15, 2020, 06:43:38 pm
content: Quote from: Heisen on September 15, 2020, 06:40:58 pmJust use higher value resistors and skip the zener diode. If you want a zener put it across the MCU's power supply rails, along with plenty of decoupling, across the MCU's supply and the internal ESD protection diodes will protect the input.CAN bus is a type of communication network used in automotive systems.https://en.wikipedia.org/wiki/CAN_bus

author: Ian.M
author_rank: Super Contributor
timestamp: September 15, 2020, 09:41:54 pm
content: I'd keep the Zener and add a 1K resistor between it and the MCU pin to limit the current into the MCU's internal protection diodes during surges that may take the signal outside the rails even with the Zener clamping.

author: Circlotron
author_rank: Super Contributor
timestamp: September 15, 2020, 10:10:20 pm
content: For a micro with a 5V supply make R1 = 100K, R2 = 56K, C1 = 100nF. No zener. 10K from input to ground just in case nothing is connected. I’ve built thousands of boards like that over many years and never had one failure. They were for use in race cars, hot rods and similar where the end user would install it and apply a +12V signal for various purposes like you are doing, and sometimes those +12V signals are very very rude! Never had one single failure, ever.

author: Heisen
author_rank: Contributor
timestamp: September 16, 2020, 11:46:37 am
content: Quote from: Ian.M on September 15, 2020, 09:41:54 pmThanks for the input.Question :- When there is no signal will R2 act as pull down resistor to prevent the MCU pin from floating, or do I have to add another 10k pull down near the GPIO? People are suggesting me to use bigger value resistors for R1 and R2. Are these okay? Or do I need to go even bigger?I added 1k resistor like you suggested. I am using 5V MCU.

author: Ian.M
author_rank: Super Contributor
timestamp: September 16, 2020, 12:30:44 pm
content: It may be worth increasing R1 and R2 to reduce the dissipation in R1 during a load dump. Making R1 47K would get the peak dissipation under 1/4W. If you also make R2 33K, you'll get approx 5V to the MCU when the 12V signal is at 12V. With a well charged battery and the engine running it will be closer to 14V, but D1 should clamp it near enough to 5V. You don't need a separate pulldown after R3 for a CMOS MCU or CMOS logic.