Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Switching 12V vehicle headlights with Arduino / Mosfet combination

Status
Not open for further replies.

VanDerMax

Newbie
Joined
Mar 25, 2021
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
53
Quick intro: a ground level noob, started to tinker with electronics at the beginning of this year after I couldn't get any electronics shop in my town replace my bike's gauge cluster SMD LEDs. I bought a trash soldering iron and looked at few tutorials and did the job myself - surprisingly it worked, but I bought too bright SMD's and I didn't like the temperature of the color, so I thought about if there's a way to have it adjustable at all times.

I discovered addressable leds, drivers, ESP32's and all that, and eventually installed the addressable LEDs in the cluster, controlled wirelessly via phone app, and now I'm looking to make a new project.

I learned few things about mosfets, I managed to assemble a code for Arduino IDE that controls the LED the way I want, and tested the 12V 25W LED bulb on my desk with bench power supply and Arduino hooked to buck converter, with the LED bulb controlled with a breadboard size pushbutton and a mosfet. I bought the wrong (high Rds, not logic level) nMOS at first, but learned to read some specs and got IRL2203 that operates the light and keeps cool with no heatsink.

The challenge is how to install it in the vehicle while keeping the original controls intact and without adding anything extra. I am going thru YouTube vids on schematics and trying to figure out where in the "headlight circuit" should I tap in with the Arduino and mosfet. One thing that kind of worries me now, I'm starting to think I planned this wrong going with the nMOS and all, I highlighted all the headlight-relay wires and it seems that pMOS would be the correct choice to tap into these wires, and accessing ground wires for nMOS would be too challenging?

As I'm not well versed in these, please let me know what can I do here.

One idea I had was completely remove headlights from the circuit, from the relay and everything, and run a separate circuit from headlight fuse? Just thinking out loud :D Let me know how would I go about solving this :) cheers

Sy30fyW.jpg
 

I always find diagrams like that difficult to follow. I'm not sure why the red and blue wiring to the headlights follow different circuits unless they are actually going to different filaments inside the same light bulbs. Or maybe your bike has two bulbs inside one lens.

Regardless, the easiest way to modify it would be to isolate the 'G' wire to the headlights and wire the MOSFET in series with it. The existing switching would still work but it would also require the MOSFET to be turned on to complete the chassis side of the circuit.

Brian.
 

Hi,

I'm confused with that much text.

Could you please write in one or two sentences what you need to know from us?
Keep information focussed and compact.

Klaus
 

Or maybe your bike has two bulbs inside one lens.

Exactly the case - two bulbs, one headlight unit - one bulb is "low", one is "high" beam light.

Could you please write in one or two sentences what you need to know from us?
Keep information focussed and compact.

Agreed. Ok - here it goes;

- I have written and tested a code where a small pushbutton controls the 12V 25W LED
- there are two such bulbs on the bike
- my goal is to learn how to complete this project on a actual bike, using Arduino / nMOS to control those LEDs

At the moment I have doubts on how to do it and keep the functionality of bike original switches intact, as well as other things (like instrument panel led light for high beam).

Here's a rough sketch of my current idea; cut the OEM ground wire from the bulb and route it directly to the nMOS drain, with source grounded on the chassis (or on the battery ground directly) - this approach sounds like it should (again, im a newb, not sure) work? Are there any downsides to this, precautions, perhaps the mere distance from mosfet to the bulb, is that a problem?

mgvLiaH.jpg
 

If the Arduino is simply turning the headlights on or off there shouldn't be any problem but if you intend to use PWM as a dimming control you might run into problems because of high frequency pulses travelling along the wiring loom. You would have to experiment to see how it performed, predicting what would happen in individual circumstances would be almost impossible.

You will have to place the Arduino and MOSFET carefully, and be aware of the voltage drops in the wiring loom. The logic level MOSFET will become conductive with as little as 1V between it's gate and source pins. 1V isn't much when possibly 10A is flowing through the loom so beware of unexpected loss or gain of voltage between points that in theory are all at the same potential.

Brian.
 

Hi,

I still don't get the expected function.

* With a high side switch - depending on wiring - I expect OR function.
* With a low side switch I expect AND function.

And how the dashboard LED should work.
With a low side switch the LED may be ON while the headlight is OFF.

I see a lot of text but not the idea behind it - maybe I'm to dumb.
Thus I am not able to say which solution gives the expected function.

What's the use of the Arduino at all?
To make a pushbutton switch the headlights ON and OFF ... there are easier ways.

Klaus
 

@KlausST it's me who's not explaining things right, I'm new to all this so hence my lack of proper descriptive context, sorry bout that :)

So here's one plan I have;
- have Arduino listen to 12V signal on the "Passing" switch that flashes the bulb
- that signal should go to Arduino input and trigger the mosfet that would act on the headlight relay.

I think with this approach I will have most of the original wiring loom almost intact and this is one of the goals of my practice project right here. The only problem for me is how to manage the 12V signal for Arduino's 5V input, I've seen articles on various solutions such as simple voltage dividers, opto-couplers...but I have to look into those more
 

Hi,

O.K.

There is one "input", the pusbutton.
And there is one "output", the headlight.

Q1) Just for understanding. The button press, is it one short press, is it a press for ON and a second press for OFF, or is it a long press as log as you want the output to do something?

After the key press you want the output to do something. Here I see two situations:
Q2A) What do you want the headlight to do when the light was OFF before?
Q2B) What do you want the headlight to do when the light was ON before?

Klaus
 

Q1 - the Passing switch is designed as a regular pushbutton toggle, as long as you have it pressed, it's on. I've been digging into the wiring diagram of the bike last two days, althoug I'm a total noob and not well versed in this at all, but from what I can deduce from the diagram, the Passing button doesn't have a "dedicated wire" for the function going down to the main connectors, it just bridges the main "high beam" wire with a short connection inside the enclosure.

If I want Arduino to control this function, I think the simplest solution would be remove the internal connection from Passing to High Beam and route a separate Passing wire that Arduino will listen to. That way I can run the IDE to the mosfet that controls the relay.

I don't have the knowledge to make Arduino differentiate whether I pressed the Passing or the High/Low (dimmer) switch in this original wiring setup, I'm not sure if it's even possible without some actual hardware intervention, so just pulling a separate wire from Passing should do the trick.

Screenshot_3.jpg
 

Hi,
I don't have the knowledge to make Arduino differentiate whether I pressed the Passing or the High/Low (dimmer) switch in this original wiring setup, I'm not sure if it's even possible without some actual hardware intervention, so just pulling a separate wire from Passing should do the trick.
I didn't ask for a solution nor for knowledge.
Nor did I ask to dig into the wiring diagram

I asked how you want it to work...

Sadly I can't ask my questions to get the informations I need.

Klaus
 

@KlausST it's me who's not explaining things right, I'm new to all this so hence my lack of proper descriptive context, sorry bout that :)

So here's one plan I have;
- have Arduino listen to 12V signal on the "Passing" switch that flashes the bulb
- that signal should go to Arduino input and trigger the mosfet that would act on the headlight relay.

I think with this approach I will have most of the original wiring loom almost intact and this is one of the goals of my practice project right here. The only problem for me is how to manage the 12V signal for Arduino's 5V input, I've seen articles on various solutions such as simple voltage dividers, opto-couplers...but I have to look into those more


Something like this -

1616888512881.png


Diodes protect against over voltage load dump transients, R's set to translate
12V to 5V for the Arduino.

When you read the A/D it gives you 0 - 1023 for 0 - 5 Volts in. So

V = (AtoDvalue x 5V ) / 1023



Regards, Dana.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top