Author Topic: How to detect automotive brake 12v signal for feeding into microcontroller?  (Read 1809 times)

0 Members and 1 Guest are viewing this topic.

Offline HeisenTopic starter

  • Contributor
  • Posts: 42
  • Country: in
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 pin
2. The Arduino (ATmega) will report LOW if: a voltage less than 1.5V is present at the pin

As 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.
 

Offline Alti

  • Frequent Contributor
  • **
  • Posts: 404
  • Country: 00
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #1 on: September 15, 2020, 05:22:24 pm »
CAN.
 

Online jfiresto

  • Frequent Contributor
  • **
  • Posts: 875
  • Country: de
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #2 on: September 15, 2020, 05:36:23 pm »
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.

-John
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17117
  • Country: us
  • DavidH
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #3 on: September 15, 2020, 06:07:49 pm »
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.
 
The following users thanked this post: Heisen

Offline HeisenTopic starter

  • Contributor
  • Posts: 42
  • Country: in
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #4 on: September 15, 2020, 06:40:58 pm »
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?

 

Offline HeisenTopic starter

  • Contributor
  • Posts: 42
  • Country: in
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #5 on: September 15, 2020, 06:42:47 pm »
CAN?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19920
  • Country: gb
  • 0999
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #6 on: September 15, 2020, 06:43:38 pm »
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?


Just 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
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #7 on: September 15, 2020, 09:41:54 pm »
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.
 
The following users thanked this post: Heisen

Offline Circlotron

  • Super Contributor
  • ***
  • Posts: 3319
  • Country: au
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #8 on: September 15, 2020, 10:10:20 pm »
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.
 
The following users thanked this post: Heisen

Offline HeisenTopic starter

  • Contributor
  • Posts: 42
  • Country: in
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #9 on: September 16, 2020, 11:46:37 am »
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.

Thanks 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.

« Last Edit: September 16, 2020, 12:09:42 pm by Heisen »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13076
Re: How to detect automotive brake 12v signal for feeding into microcontroller?
« Reply #10 on: September 16, 2020, 12:30:44 pm »
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.
 
The following users thanked this post: Heisen


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf