Author Topic: Microcontroller 12v bulb check  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Microcontroller 12v bulb check
« on: October 17, 2022, 09:54:41 pm »
I've been racking my brain over the best way to do this for a few days now, and you guys are a lot smarter than me, here's the situation:

Backstory:
We converted our car to electric, a 24V Nissan Patrol. We decided to switch to 12V due to ease of sourcing components.
Now the harnass is all still the 24v wires which means, double the current through said wires. Eventhough I'm sure the super rugged and overbuilt Nissan could handle it, I think a CAN bus conversion would be fun, and useful for checking the bulbs on our terrible trailers.

I came up with:
A custom PCB with some microcontroller (probably STM32 or Atmega32u4 or something similar)
17 MOSFETs (4 for left, 4 for right and 5 for trailer, I chose 1 per bulb for future flexibility/fun animations etc)
And some sort of resistance or current measurement to notify the driver of any broken bulbs.

In the spirit of the vehicle being a Patrol, I want to do this as foolproof as possible (I primarily have overvoltage and over current scenario's in my mind), but still as simple as possible (price isn't as big of a concern within reasonable limits). So in the spirit of that I sourced an aluminium ECU type case with some fake ampseal connectors I can use to wire up every light and the trailer plug.

(I thought giving as much information as possible would be helpful in case I'm overseeing something huge here)

TL;DR
I have a MOSFET controlling a lightbulb, and I want to be able to detect if said lightbulb goes out, in the most unbreakable way possible.

Thanks!
*Insert cool inspirational text here*
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1178
  • Country: ca
Re: Microcontroller 12v bulb check
« Reply #1 on: October 17, 2022, 10:29:47 pm »
Add a 1R or 0R5 sense resistor to each MOSFET source pin.  Then measure its voltage drop through a mux to an ADC or comparator.  Choose resistor based on load expected. See attachment.

Assuming 1.1V Vref for the ADC, a 1R sense resistor will measure up to 1A (using an 8W bulb on a 12V battery).  Zener protection assumes 5V MPU.

Play with it here: http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEAmB0FksgHGAbAOyRHLKR4gKSWXUICmAtGGAFABmIAzGSghQBZ8fCj3Doo0AJyoZCOQtTZWAJxBCKyAsnXCuCHdTYBzXaINnuebFCiruvVJoHUntzJFYAZFC5HgZfyMQdgBDABsAZ3pwak8wXEtkPw1wAQFbZDwBKWhSSC4wWWxsKTACEBsiyUgMmFrWACVLKUFhbNtqP2q4yQRWLiIWtoowdPBO1gB3SmqtHXkdebsAB0pA5cXuCwg41lMt-QXArmtJtVTNue13eAGMgC96ADt6FUYBaC4JsGgCMaOuBkuHgyCYFVcsHg0JhkGwGU+3zYD1mOiOqJQNx0T1e70R+wx6IwaLOexmW2WeH4mMMrAAHiBCEsCBQCH4tFJ1OAbAAVAD2AB1IgBZACqAA16ZQstwxpQ8KJylyEuovgA1KWFKpSGxcAQ2MgQDIq7AAdVYawEHTGCI6yWCZPU1vGqRtdhmVoy9qSfk8QA

EDIT: Updated attachment and simulator link for 12V
« Last Edit: October 17, 2022, 10:45:25 pm by pqass »
 

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Re: Microcontroller 12v bulb check
« Reply #2 on: October 17, 2022, 10:39:19 pm »
So like a shunt? I looked into this, but shunts for 7-10a are far from SMD or even PCB mountable at all, which is why I started thinking more in a resistance measurement while the light is off for example.

Also the system is 12v right now, and will stay so.
Thanks for the reply!
*Insert cool inspirational text here*
 


Offline james_s

  • Super Contributor
  • ***
  • Posts: 21608
  • Country: us
Re: Microcontroller 12v bulb check
« Reply #4 on: October 18, 2022, 12:42:53 am »
You could use a Hall based current sense IC, they're a lot more efficient for measuring currents in that range and will result in less drop and a lot less heat.
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1178
  • Country: ca
Re: Microcontroller 12v bulb check
« Reply #5 on: October 18, 2022, 01:04:15 am »
I forgot about the [ugly] nature of auto electrics - everything is grounded directly to the chassis at the load. So you're probably going to have to go with P-MOSFETs and high-side current sensing instead. 

See attachment.
Note: I tried to scale down (by a third; or 4k7/(4k7+10k)) all sensed voltages through the MUX and opamps (to keep them below 5V) but not sure why scaling up in the diff-amp was it neccessary to use a different factor (3k3/(3k3+10k)).  Oh well, software will smooth all the rough edges.

http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEAmB0FksgHGAbAOyRHLKR4gKSWXUICmAtGGAFABOIAzHtiMzm69+AFj7U2AcyF8wgnrJEioUDigLJ+XTWACcmxtpWZIrADIg8y5hXz87EkADMAhgBsAzvRqmwuGeDywkbUyHgIXNC6kNgiOFxYkFwiXCCymjCQypkirABKAQJ8CvZ41OUgIhIZKjAIrFxEhXYlRhDlrAAOlXZFPRSMYuC1rADulggDQxrUg+KsAB4gBEaDSNhwoprKfiAAKgD2ADoeALIAqgAai+rU2BQJd7qV4HzYAOpd-dzbdnKyI3GIhamlaGTG33+AShpic6gMRhKhlBqTA6CgUVQ+gQ2Nxaj0CJ0+nsggk8FM4wJJOKwj6pgALoE+DZwMSWY4YHhtLoNkocVy5MhUpyECk9LxsNE9LoRM8TCAACb0VwAVzc9NY0ipEmJDlUnChLKspWM8AhwKmNOZQwp3z6SJhN10ED+K1ZL125zMADkyEkblx-CyIqlmKkdnwAGqSDwnAC2LgWRwAjkdOgB6RhkSNqC2iPg4gw28DktSF-OUYkhSpEUzSctGcvF23hS2VovzJYrCDIAjKbDIZS9ggevgAMXYBzjJwu1yBvShousjvGS+plCUKGw804a5wBc3JTJZt3h+Ea6U4hrcE1G+Ul7vlWNHXG++4CE0b+0L4mbdb8NUbpdAeLIQGA7hYmGDppHAwNlHAqoKlMTg31QWwCAoNDTTNFwt2KUCwAw7hQILbDyRQaBtxEAgCHwMRyDwXQEiQZBKNiAgP2wGi9BYZ0dnJW1UMmPCRNtQjMOE8TiOyVhcIwUEP0qTYuEU0jj3IyJsB4DQwG0PB9LibAkE07TkkYwMaIQDBUQE81lMUxDpNUIFlNA+SnNtdyEmULyeGcyg5ACNcjwhdze00f9wv8sKYgCz8qn8xyyALQLksSzYsKS2LTDk1LhKS4S1JLATuGgAU-AwZ0uDAYFZVK8rgKoar9PIUhipPJTQmEoSKGoLhHlzezP23d8an6m8UJGlSdCI6ayLrcBZsUqSj382CCNm0CW26jRljIADTCWKykEYLjf34LlRxAABlABjdx6BOBUDlGAA7I4jlepwDnYGcrhufSKCaDYRxYJAIxAd4AEt2EejxYc6WGvFe+lY0+26Dle176Fu+kocxj6UYAC0nFVJCJv7riWPwR1qgIUj4CGAHlXrcABPE5MbhhUoacJxGBcONOkJlwnHpehfrOK4Tih2MPGx+glQVG4cWeaqICMhSKGZ1mOY8DwodeyQ3DhhBIxOToXolk4PBVTpOnZwmPCJg41QVE4ACM4YVpWTm+yXZxF173Y8A5OkFzoPFYIA

« Last Edit: October 18, 2022, 02:31:56 am by pqass »
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 6138
  • Country: nl
Re: Microcontroller 12v bulb check
« Reply #6 on: October 18, 2022, 06:03:30 am »
Don't forget that in a car with a combustion engine 12V is not a steady 12V. When the motor is running the alternator will ramp up the voltage to possibly over 14V.

Quote
We converted our car to electric, a 24V Nissan Patrol. We decided to switch to 12V due to ease of sourcing components.

But if the above means you turned the car into an electrically propelled vehicle using an electric motor then it might be a different story :)


Offline james_s

  • Super Contributor
  • ***
  • Posts: 21608
  • Country: us
Re: Microcontroller 12v bulb check
« Reply #7 on: October 18, 2022, 06:18:48 am »
You can do all of this easily with a single IC per channel. Isolated so it doesn't matter if it's high side or low side, very low resistance so it runs cool and drops very little voltage, robust and easy to work with, works over a wide range of voltage, just hook it up and get an analog output proportional to the current flowing through. Here's the sort of thing I'm talking about. https://docs.broadcom.com/doc/ACHS-712x-DS
 

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Re: Microcontroller 12v bulb check
« Reply #8 on: October 18, 2022, 07:53:15 am »
This is a lot more like it, but very complicated, some others mentioned the hall effect current sensors, they seem a lot simpler
*Insert cool inspirational text here*
 

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Re: Microcontroller 12v bulb check
« Reply #9 on: October 18, 2022, 07:54:58 am »
This is true, and yes we have a DC-DC converter which essentially provides 14v ish when running, this is why I said I want it to be as foolproof as possible.
If we ever sell this thing, it is guaranteed to go to some hillbilly offroad fan, and I KNOW that he is not going to take care to protect any sensitive circuitry lol
*Insert cool inspirational text here*
 

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Re: Microcontroller 12v bulb check
« Reply #10 on: October 18, 2022, 07:56:32 am »
I think this is the ticket, I'll just have to look at some magnetic field protection for them. Seeing as they can handle a lot more current and voltage, someone could really screw up bad in the electrical system, and all would be well with the board
*Insert cool inspirational text here*
 

Offline pqass

  • Super Contributor
  • ***
  • Posts: 1178
  • Country: ca
Re: Microcontroller 12v bulb check
« Reply #11 on: October 18, 2022, 01:09:00 pm »
Don't forget about price...

Shunt: 0R1/10W (WSHP2818R1000FEA) is €1.3648 (qty25)
Hall-effect sensor: 100mV/A (ACHS-7122-000E) is €3.118 (qty25) but no stock at digikey.nl
Hall-effect sensor: 100mV/A (TMCS1108A2BQDR) is €1.9696 (qty25)

The only additional parts for the shunt implementation is a single Instrumentation amp (like INA350CDSIDDFR €0.68 MCP6N11-100E/SN €1.84; replacing buffer-amps+diff-amp+resistors) and shunt scale-down resistors (4k7+10k).  Both implementations need the P-MOSFETs, their drivers (ULN2003ADR2G €0.78), and MUXes (74HC4051D,653 €0.50)

All parts+prices are for eaches at digikey.nl
« Last Edit: October 18, 2022, 01:54:35 pm by pqass »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21608
  • Country: us
Re: Microcontroller 12v bulb check
« Reply #12 on: October 18, 2022, 03:32:47 pm »
Who cares about price? This is a one-off project, and you're not factoring in the time required to build some other solution. If the sensor ICs cost $50 instead of $5 I might try to find something else, but in this case it's cheap.
 

Offline lolimpolTopic starter

  • Contributor
  • Posts: 46
  • Country: nl
  • What level of irony are you on right now?
Re: Microcontroller 12v bulb check
« Reply #13 on: October 18, 2022, 04:20:28 pm »
Exactly this, the whole restauration + electrification was €40k so I simply just want the best available. Also I could potentially multiplex it to use one current ic maybe?
*Insert cool inspirational text here*
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 6138
  • Country: nl
Re: Microcontroller 12v bulb check
« Reply #14 on: October 18, 2022, 04:44:04 pm »
Pictures of the conversion would be interesting :)

Multiplexing the lamp driving signals would mean time multiplexing them being on and off to be able to use just a single current sensing IC. Most likely easier to get the 17 you need and either use a MCU with sufficient analog inputs or get a couple of 4051's to multiplex the analog signals before the MCU.

Online Zero999

  • Super Contributor
  • ***
  • Posts: 22477
  • Country: gb
  • 0999
Re: Microcontroller 12v bulb check
« Reply #15 on: October 18, 2022, 04:59:34 pm »
Measure the voltage across the MOSFET. It should be equal to 12V, when off and close to, but not quire zero, when on. An estimate of the voltage when on can be gained by multiplying the bulb current, by the drain resistance.

Why not use LEDs anyway?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->