Go Down

Topic: Headlight control (Read 5480 times) previous topic - next topic

Ogmudbones

Then you won't need any Arduino.

...R
Do explain how i can get this to work without running wires into the cab

UKHeliBob

Maybe use the existing wires to control a relay instead of the lights and wire the relay to turn on the low beam when not energised and both beams when energised ?  There is presumably also a switch to turn the lights on and off as well as the one to set them high or low beam.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Ogmudbones

Maybe use the existing wires to control a relay instead of the lights and wire the relay to turn on the low beam when not energised and both beams when energised ?  There is presumably also a switch to turn the lights on and off as well as the one to set them high or low beam.
I had that idea but the trucks relay transition time kills that idea

UKHeliBob

Can you please explain what you mean by that ?  I cannot imagine a relay that takes more than a fraction of a second to change states and in any case you will only be switching the high beam.  The low beam stays on all the time the headlight power switch is turned on.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Ogmudbones

Can you please explain what you mean by that ?  I cannot imagine a relay that takes more than a fraction of a second to change states and in any case you will only be switching the high beam.  The low beam stays on all the time the headlight power switch is turned on.
That fraction of a second when neither relay is engaged is when your bulb loses its ignition and while that would produce a solution it would be sub optimal due to the heat cycling and repeated ignition cycles.

Ogmudbones

I'd rather not debate on alternate solutions i would just like some help writing the code to accomplish my task

UKHeliBob

There would be 3 states

1 lights off - no power to headlights
2 low beam - power to the low beam lights
3 high beam - power to the low beam lights and high beam lights.

The low beam lights would not turn off between states 2 and 3

An Arduino based solution could do the same but will only be serving to drive the relay or other switching device.  No need for any timing or even real programming because all you need to do is to read the state of an input and pass it on to an output or outputs.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Ogmudbones

There would be 3 states

1 lights off - no power to headlights
2 low beam - power to the low beam lights
3 high beam - power to the low beam lights and high beam lights.

The low beam lights would not turn off between states 2 and 3

An Arduino based solution could do the same but will only be serving to drive the relay or other switching device.  No need for any timing or even real programming because all you need to do is to read the state of an input and pass it on to an output or outputs.
Yes this is exactly what i need but i need to make sure during that transition between state 2 and 3 when both high and low beam inputs are low that the low beams stay on

TomGeorge

#38
Jun 10, 2015, 11:45 pm Last Edit: Jun 10, 2015, 11:46 pm by TomGeorge
Hi,
Have you had your installation tested to see if it is to highway code?
Are you using the old reflectors and headlight lens?
If so they  are designed for a smaller point source of light than the HID, so the focus and spread will not be the same.
It is the safety of oncoming drivers you have to consider as well.
I know in your state the authorities don't care, but I would for you and my sake, if I occupied the same bit of planet as your truck at night.

Tom..... :)
Everything runs on smoke, let the smoke out, it stops running....

Ogmudbones

Hi,
Have you had your installation tested to see if it is to highway code?
Are you using the old reflectors and headlight lens?
If so they  are designed for a smaller point source of light than the HID, so the focus and spread will not be the same.
It is the safety of oncoming drivers you have to consider as well.
I know in your state the authorities don't care, but I would for you and my sake, if I occupied the same bit of planet as your truck at night.

Tom..... :)
The bulbs are made for reflector housings no ones ever flashed me while they where installed so i think its fine.

UKHeliBob

Quote
Yes this is exactly what i need but i need to make sure during that transition between state 2 and 3 when both high and low beam inputs are low that the low beams stay on
Code: [Select]

const byte powersenseIn = 9;
const byte highbeamIn = 10;
const byte lowbeamOut = 11;
const byte highbeamOut = 12;

void setup()
{
  pinMode (powersenseIn, INPUT_PULLUP);
  pinMode (highbeamIn, INPUT_PULLUP);
  pinMode(lowbeamOut, OUTPUT);
  pinMode(highbeamOut, OUTPUT);
}

void loop()
{
  if (digitalRead(powersenseIn) == HIGH)    //if the headlights are on
  {
    digitalWrite(lowbeamOut, HIGH);  //turn on low beam
    if (digitalRead(highbeamIn) == HIGH)  //if high beam selected
    {
      digitalWrite(highbeamOut, HIGH);  //turn on high beam
    }
  }
  else  //headlights are off
  {
    digitalWrite(lowbeamOut, LOW);  //turn off low beam
    digitalWrite(highbeamOut, LOW);  //turn off high beam
  }
}

You will need to ensure that the input voltages are between 0V and 5V, that not more than a few milliamps is taken from the outputs and that the Arduino is supplied with a stable voltage that contains no spikes.

I still think that it is a waste of an Arduino.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Robin2

#41
Jun 11, 2015, 11:00 am Last Edit: Jun 11, 2015, 11:02 am by Robin2
Do explain how i can get this to work without running wires into the cab
One switch turns on the LOW beam - that would normally be on all the time.
Another switch turns the HIGH beam on and off as required.

What is the objection to running wires into the cab?
This is the first time you have mentioned this issue.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

TomGeorge

Hi,
I understand the low beam dropping out, when you switch from low to high in some vehicles, low switches off first then high turns on.
You don't want to pass extra wires through the firewall, so attached is a solution, it is untried, the values may need to be tweeked depending on the relay coil resistance.

Tom...... :)
Everything runs on smoke, let the smoke out, it stops running....

sonyhome

You want the low beams to stay on for another second when they switch off
because high beams are not on.


12V Ignition ----Regulator 5V ------ Arduino <-- Regulator 12V ----> Low beam relay

Arduino <--- low beam switch ( input signal)
Arduino -----> low beam relay (output signal, set to high for 1 second)


while low beam input is high, set low beam output to high
if low beam input transitions low, set delay to 1sec, set low beam relay output to high


If I were you I'd try to find a way to splie the switch signal to the relay AND the arduino
so that if the arduino breaks your lights still work. This means setting the low lights on with
the arduino will cause the arduino to read as input what it sets and it wil need to tell that appart
from the switch action.

Ogmudbones

You want the low beams to stay on for another second when they switch off
because high beams are not on.


12V Ignition ----Regulator 5V ------ Arduino <-- Regulator 12V ----> Low beam relay

Arduino <--- low beam switch ( input signal)
Arduino -----> low beam relay (output signal, set to high for 1 second)


while low beam input is high, set low beam output to high
if low beam input transitions low, set delay to 1sec, set low beam relay output to high


If I were you I'd try to find a way to splie the switch signal to the relay AND the arduino
so that if the arduino breaks your lights still work. This means setting the low lights on with
the arduino will cause the arduino to read as input what it sets and it wil need to tell that appart
from the switch action.
The relays are active low so worst comes to worst they'll be on but for simplicities sake i said active high. Its not to difficult to change code from active high to active low i dont think...or it might be...probably should have said active low to begin with.

Go Up