Sensing automotive 12v with Rpi - opto? - Page 1
Forum section: electronics / beginners

author: Heppie
author_rank: Newbie
timestamp: December 16, 2015, 05:35:50 pm
content: 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?

author: rx8pilot
author_rank: Super Contributor
timestamp: December 16, 2015, 05:38:59 pm
content: Why are you avoiding the divider?Sent from my SAMSUNG-SM-G890A using Tapatalk

author: Heppie
author_rank: Newbie
timestamp: December 16, 2015, 05:51:17 pm
content: 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.

author: rx8pilot
author_rank: Super Contributor
timestamp: December 16, 2015, 06:02:35 pm
content: 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?

author: Heppie
author_rank: Newbie
timestamp: December 16, 2015, 06:07:17 pm
content: 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.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: December 16, 2015, 06:15:24 pm
content: 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).

author: rx8pilot
author_rank: Super Contributor
timestamp: December 16, 2015, 06:16:05 pm
content: 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.

author: rx8pilot
author_rank: Super Contributor
timestamp: December 16, 2015, 06:22:14 pm
content: Quote from: 0xdeadbeef on December 16, 2015, 06:15:24 pmTrue, 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.

author: Gyro
author_rank: Super Contributor
timestamp: December 16, 2015, 06:44:46 pm
content: 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.

author: rx8pilot
author_rank: Super Contributor
timestamp: December 16, 2015, 06:55:38 pm
content: Quote from: Gyro on December 16, 2015, 06:44:46 pmTotally agree. I would only avoid them from a reliability and cost perspective.