Author Topic: Sensing automotive 12v with Rpi - opto?  (Read 2792 times)

0 Members and 1 Guest are viewing this topic.

Offline HeppieTopic starter

  • Newbie
  • Posts: 5
  • Country: gb
Sensing automotive 12v with Rpi - opto?
« on: December 16, 2015, 05:35:50 pm »
I'm looking to make a dashcam with a Raspberry pi but with a video overlay of braking/indicator status. I was looking at voltage divider circuitry but for sheer simplicity a multi channel opto May be better. The issue I'm having is identifying the correct type. I keep finding the opposite to what I need e.g. 3.3v switching 12v but obviously I need one that switches 3.3 with 12v. What should I be searching for? Or am I on the wrong track?
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Sensing automotive 12v with Rpi - opto?
« Reply #1 on: December 16, 2015, 05:38:59 pm »
Why are you avoiding the divider?

Sent from my SAMSUNG-SM-G890A using Tapatalk

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline HeppieTopic starter

  • Newbie
  • Posts: 5
  • Country: gb
Re: Sensing automotive 12v with Rpi - opto?
« Reply #2 on: December 16, 2015, 05:51:17 pm »
 I need to sense 3 lines so thought a single chip would be neater and from reading up about voltage dividers and the voltage range and noise on a cars "12v" supply worries me as a beginner (programmer by training). If it's a better solution and someone could explain to me how it handles the variable voltage I'll try it.
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Sensing automotive 12v with Rpi - opto?
« Reply #3 on: December 16, 2015, 06:02:35 pm »
A resistive divider is exceptionally simple and predictable. The voltage output is directly and linearly proportional to the input. In an automotive environment you have certainly have all kinds of noise and voltage excursions that would need to be filtered and clamped based on what it is you are trying to sense. It sounds like you simply want to know when the brakes are on/off and not necessarily looking for a proportional indication. If that is true, A resistor divider and a TVS diode is all you really need. The divider get the voltage close and severly limits the current. The TVS diode clamps the voltage so that it cannot go over a specified voltage even when exposed to a big 60V spike.

Does that seem like I am interpreting the question right?
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline HeppieTopic starter

  • Newbie
  • Posts: 5
  • Country: gb
Re: Sensing automotive 12v with Rpi - opto?
« Reply #4 on: December 16, 2015, 06:07:17 pm »
You're spot on with the interpretation. I just need to know whether the brake light line is off(0v) or on(11-15v) on a Rpi's 3.3v GPIO.
 

Offline 0xdeadbeef

  • Super Contributor
  • ***
  • Posts: 1572
  • Country: de
Re: Sensing automotive 12v with Rpi - opto?
« Reply #5 on: December 16, 2015, 06:15:24 pm »
For the sake of completeness I might add that usually 9V to 16V is considered the "normal" voltage range in a car with 12V battery.
Also automobile stuff is usually supposed to work up to 28V and survive reverse battery (like -13.5V at least).
Trying is the first step towards failure - Homer J. Simpson
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Sensing automotive 12v with Rpi - opto?
« Reply #6 on: December 16, 2015, 06:16:05 pm »
For that, I would not bother with the opto unless you had some very specific need for isolation. If it was my project, I would use a resistor divider to get 12v=3.3v, use a TVS to keep it at 3.3 and make sure it can handle the potential for load dump - 100v maybe, then add a capacitor to filter some of the noise as close to the input as practical. Before connecting it to the Rpi, I would test to make sure the voltage never exceeds 3.3v and is not too noisy to get a reliable trigger. You will almost assuredly need some de-bounce code to clean up the signal.

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Sensing automotive 12v with Rpi - opto?
« Reply #7 on: December 16, 2015, 06:22:14 pm »
For the sake of completeness I might add that usually 9V to 16V is considered the "normal" voltage range in a car with 12V battery.
Also automobile stuff is usually supposed to work up to 28V and survive reverse battery (like -13.5V at least).

True, although the 9v range would only likely be seen during starting. For the reverse, I am not sure what the max negative input allowed on Rpi is. The TVS would clamp it it early but it may need a small schottky for the reverse voltage case.

EDIT: I will amend my suggestion a little to using a Zener to regulate the 3.3v (much more precise voltage) and the TVS to protect.
« Last Edit: December 16, 2015, 06:25:47 pm by rx8pilot »
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 9480
  • Country: gb
Re: Sensing automotive 12v with Rpi - opto?
« Reply #8 on: December 16, 2015, 06:44:46 pm »
At the same time, there's no actual harm in using an opto, you just need a basic led - phototransistor one (not a specific !2V - 3v3 one). To protect it you'd want to put a reverse polarity diode directly across the opto input and then use a reasonable series (as high as you can get away with) resistor to the brake light or indicator. On the output side of the opto you just need a pullup resistor on the collector.

An opto is probably overkill but at the same time it does usefully isolate the inputs without needing to worry too much about getting the input protection (including return paths for TVS etc) just right. It would be wise to do some 'debounce' in s/w.
Best Regards, Chris
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3634
  • Country: us
  • If you want more money, be more valuable.
Re: Sensing automotive 12v with Rpi - opto?
« Reply #9 on: December 16, 2015, 06:55:38 pm »
At the same time, there's no actual harm in using an opto,

Totally agree. I would only avoid them from a reliability and cost perspective.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf