Author Topic: Sequential Taillight using Arduino Pro Mini (Thread Change from 555 Delay Timer)  (Read 51134 times)

0 Members and 2 Guests are viewing this topic.

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #25 on: January 07, 2016, 08:57:09 am »
How will the NANO or Pro MINI react to having it's power constantly disconnected? As in when the Turn signals or hazards are activated?  I'd really rather NOT run a dedicated wire to the back If I don't have to, and also, The Arduino would still see frequent disconnects when he turns on and off his truck.  The dedicated wire would need to be tapped into his ignition wire, so there would be no power draw when truck is off.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #26 on: January 07, 2016, 09:05:51 am »
That's what I'd be doing - supply the micro from the ignition +12V (filtered)...
One +V wire - which you would have needed anyway to supply the relays (and a transistor stage to sink the relay coil current).

If you want to have hazards / stop lights etc available when the ignition is turned off, you need to look at using unswitched +12V, and limiting / modifying the flasher behavior when +ignition is 'off'.

In this case the micro can be put into low-power sleep when the ignition is off, and just wake up every second to check if the environment (switches, ignition etc) has changed.  Virtually no load on the battery unless the lights are actually 'on' during their flash cycles.

EDIT: Not worded very well, but you'll get what I meant!
BTW micro with PWM means you could fade the lights in sequence, or dim at night / bright during the day - just like real cars!
« Last Edit: January 07, 2016, 09:08:19 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #27 on: January 07, 2016, 09:14:08 am »
I understand. Forgot about Hazards needing to be on when Engine is off.  That one wire that is switched for the Brake/Turn/Hazard does supply power with engine off if the Hazards are turned on or brakes are applied. The turn signals only work if the ignition is on.

This may be a good circuit to learn Arduino on. That other circuit we are working on MC is just over my head right now. :P

I will order a couple NANO's, Logic Level mosFETS, and....what else you think I need to order for this?  Do I need anything to program the Arduino? I am not sure where to even get the software or where to learn up on it yet.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #28 on: January 07, 2016, 09:15:46 am »
And something like this maybe

http://www.ebay.com/itm/Waterproof-Plastic-Electronic-Project-Box-Enclosure-Case-100x68x50mm-L-W-H-SWTP-/331746356647?hash=item4d3d9fada7:g:ja0AAOSwFGNWTlYU

to keep water/dirt/moisture from getting in?  Drill and seal a hole for the wires to come in.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #29 on: January 07, 2016, 09:26:28 am »
If you go with Arduino - the software and learning is free - all downloadable and online.  You can program directly from your PC.

You can ask for help almost anywhere on the net (not always good help, but help nonetheless...!  Just like EEVblog!))

As this is a 'mission critical' (safety focused) application - you should test it thoroughly before bolting it into the car.

Other than the basic Arduino and MOSFET drivers - the main concerns will be the power conditioning (over-voltage & spike suppresion etc), and the enclosure.
If it's within the engine bay - heat will cook an Arduino, and any plastic will become brittle in a UV exposed environment within a couple of years.

Grommets are no good in themselves - you'be surprised what can get in!
And epoxy potting only works well if you plan, test and execute it properly.  e.g. multi-core cables will either wick the epoxy internally, or become a superhighway for water and bugs to crawl into the electronics!

ADDED:  LED bulbs will also reduce the power demand for the whole design - but factor in that someone may accidentally replace a LED with a normal bulb in the future - for emergency use etc)
« Last Edit: January 07, 2016, 09:28:21 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #30 on: January 07, 2016, 09:32:20 am »
ya, I have experienced the wick thing. Made the cable Extremely stiff about 1 inch into it.

The box would be under the truck. Only way UV light would get to it, is if he Rolled the truck and it was upside down. (I expect him to do that at some point.  :-DD )

I could put in an over voltage circuit, as well as a reverse polarity one.  However, that will get tricky with the brake/turn/hazard wire.

I was thinking of maybe running the wires through a hole, and either epoxy or hotmelt glue them in. However, hotmelt glue does go bad after awhile.

The main thing I am worried about, is condensation. His LED lights are suppose to be sealed, yet, they have water in them now.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #31 on: January 07, 2016, 09:54:10 am »
For the voltage protection - run google across
automotive surge suppression or protection

For the micro - soething simpe like this
https://forum.sparkfun.com/viewtopic.php?f=5&t=36534

For the individual switch / signal inputs a simple zener & resistor should be enough (plus maybe a small value capacitor)
If you use the unswitched +12V, the filter is only needed on that. 
The +ignition will only act as a a signal input - not actually powering the circuit.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: 555 Delay Timer.
« Reply #32 on: January 07, 2016, 01:37:41 pm »
FWIW.... Arduino sketch for both sides, brakes and turn signals.  Tested on ProMini with LEDs on outputs, pushbuttons emulating Brake/TurnSignal wire inputs.

Code: [Select]
/*--------------------------------------------------------------------------------------//
           3-Light Sequential Brake/Turn Signal Actuation
           (Both Left and Right sides)
//--------------------------------------------------------------------------------------*/

int delayOn = 333;  // set sequence delay time in ms here
boolean Rstate=0, Lstate=0;

void setup() {
  pinMode (10, OUTPUT);   // Right: connect LEDs, relay drivers or mosfet Gates here
  pinMode (11, OUTPUT);
  pinMode (12, OUTPUT);

  pinMode (3, OUTPUT);    // Left: connect LEDs, relay drivers or mosfet Gates here
  pinMode (4, OUTPUT);
  pinMode (5, OUTPUT);

  //  connect Brake/Turn signal here (through divider or regulator to give ~4-5V when ON)
  pinMode (7, INPUT); // Right ts/b
  pinMode (8, INPUT); // Left ts/b       
}

void loop() {
  while (digitalRead(7)==LOW && digitalRead(8)==LOW) {
    // do nothing, wait for signal to go HIGH
    delay(20);     // short pause to allow read/writes to proceed without interference
  }
  if (!Rstate) {   // If lights are already on, skip turning them on again
    delay(20);    // short pause to allow read/writes to proceed without interference
    // when Right signal goes High, actuate R outputs in sequence
    if (digitalRead(7)==HIGH && digitalRead(8)==LOW) {
      Rstate=1;
      digitalWrite(12, HIGH);
      delay(delayOn);
      digitalWrite(11, HIGH);
      delay (delayOn);
      digitalWrite(10, HIGH); 
    }
  }
  if (!Lstate) {   // If lights are already on, skip turning them on again
    delay(20);    // short pause to allow read/writes to proceed without interference
    // when Left signal goes High, actuate L outputs in sequence
    if (digitalRead(7)==LOW && digitalRead(8)==HIGH) {
      Lstate=1;
      digitalWrite(3, HIGH);
      delay(delayOn);
      digitalWrite(4, HIGH);
      delay (delayOn);
      digitalWrite(5, HIGH); 
    }
  }
  if ((!Rstate) || (!Lstate)) {    // If lights are already on, skip turning them on again
    // when Brake (both) signal goes High, actuate R and L outputs in sequence
    if (digitalRead(7)==HIGH && digitalRead(8)==HIGH) {
      Rstate=1;
      Lstate=1;
      digitalWrite(12, HIGH);
      digitalWrite(3, HIGH);
      delay(delayOn);
      digitalWrite(11, HIGH);
      digitalWrite(4, HIGH);
      delay (delayOn);
      digitalWrite(10, HIGH);
      digitalWrite(5, HIGH); 
    }
  }
  delay(20);  // short pause to allow read/writes to proceed without interference

  // when signal goes LOW turn off all outputs
  if (digitalRead(7)==LOW) {
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    Rstate=0;
  }
  if (digitalRead(8)==LOW) {
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    Lstate=0;
  }
}



 :-/O
« Last Edit: January 07, 2016, 01:44:24 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: 555 Delay Timer.
« Reply #33 on: January 07, 2016, 03:04:14 pm »
I have a fondness for simple as much as anyone.  Would like to remind everyone that a three lead LM431 makes a dandy RC timer that will drive a small relay.  Just think of it as a op amp, voltage reference and driver.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #34 on: January 07, 2016, 09:57:50 pm »
FWIW.... Arduino sketch for both sides, brakes and turn signals. 
hehe thanks... :-+
I was going to do something similar if the OP asked!
My only comments would be to 'name' the I/O pins to help the OP understand the logic, and eliminate those delays in favour of a timed state machine...

Blocking delays are bad!  Good to learn and play... bad for almost everything else.
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #35 on: January 07, 2016, 10:14:59 pm »
well, I spent all morning trying to understand.


Here's my simulation, though, it's not video.

First of all, The simulatyion didn't have a pro mini. But it did have a micro.  I connect to the Dpins as stated in the code.
The 555 timer is just to simulate the 1Hz (as in the flashing relay). That will not actually be there in the circuit design.


The middle tactile switch is bake. That works right. When I press the button, the left and right LED's sequence, overriding the turn signal flashing, then stay on steady. That is what I need done. Good!

However, when the simulation first starts, both left and right LED's sequence. Pressing the left and right tactile buttons do nothing. The lights should be off at start of simulation and then only turn on when a tactile button is pressed.

I am trying to figure it out, but just saw MC post, so thought I'd comment.

Also, I so far like the ease of use. It's easy to change the frequency. Just change the Int Delay = 333 to any number
« Last Edit: January 07, 2016, 10:18:32 pm by Falcon69 »
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #36 on: January 07, 2016, 10:17:17 pm »
I know you said that a pot is probably a bad idea, but I'm not sure what to do. I think I am going to need one. I need to be able to adjust the timing frequency of this once it's hooked up to the truck.

I would I put in a Potentiometer to change the int delay = value?
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #37 on: January 07, 2016, 10:20:24 pm »
hmm, just noticed. when i push the left or right tactile switch, it slows down the blinking, but doesn't turn them off (actually, they should be off, only turn on when pressed).  by the way, both sides flash, regardless is button is pushed or not for either one
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #38 on: January 07, 2016, 10:20:45 pm »
That's a good starting point - and great that you're learning to harness the micro.

My comment about the delays was a harsh but important part of learning to 'have control' of your code. 

At the very least, when you take you foot off the brake (or whatever), the micro has to finish a whole flash cycle before it can do anything else - like turn the brake lights on.

If you use a state machine... you simply jump to the idle state, or to the new operating state immediately - e.g. a child runs out and you hit the brakes... no good if the brake lights don't come on for a second and a half!

Good work & good luck!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #39 on: January 07, 2016, 10:23:48 pm »
p.s.Perhaps an up/down button to step between desired speeds?
Or a DIP switch if they are semi permanent?
Remember these will get shaken around and dirty etc - so must be idiot (and fool) proof!
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #40 on: January 07, 2016, 10:26:40 pm »
okay, so erase all the "delay(delayOn);" ?

And yes, a couple of waterproof switches for up/down would work. I could cut the mounting holes for them into the box and seal them from the elements. Maybe make it in 1k increments?
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: 555 Delay Timer.
« Reply #41 on: January 07, 2016, 10:41:44 pm »
Well... the code works for me without all those problems. The lights are off until a signal appears on one or both of the input lines.  There is no delay when pressing on the brakes. The only problem is that a very short tap on the brakes produces almost one full cycle before the lights turn back off.

The easiest person to fool is yourself. -- Richard Feynman
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #42 on: January 07, 2016, 10:50:00 pm »
that's exactly what I need, but with the ability to control the speed of the lights.

I must have something wired wrong in my simulation.

I see you have a diode going to the gnd pin of the Arduino,I'm assuming it is for reverse polarity protection?

I also see a cap, I'm assuming is a 0.01uF, connecting the GND and RESET pin.

I also see another Cap, Assuming it is 100uF, across the power supply GND +5v?

I will try that, maybe that is what is wrong with mine.

Oh, and I see resistors on the Tactile Switches. 1k?
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #43 on: January 07, 2016, 10:59:34 pm »
@alsetalomin
no ones saying it won't work, just that it's not the 'best' way to code stuff like that.
op
If you go with up/down switches - you can choose as many steps or any frequency you need. The period is generated on the fly in the code.   So for simplicity, you may have slow, medium and fast.
Each time you press the button it steps between the 'modes', and could rapidly flash one of the three turn signal for half a second to indicate which value is 'active' - and saved in eeprom.

The options are endless
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #44 on: January 08, 2016, 12:45:20 am »
okay, I can't figure it out.  I tried to wire it like in the video.

The Nano thinks that Pin 7 and 8 or HIGH all the time. Don't know how to fix it. Ideas?

 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #45 on: January 08, 2016, 02:10:35 am »
Figured it out. I need to add a pulldown resistor to the switches. The Arduino Micro didn't know what to do, so it sent all those pins to high.

Now, to figure out the switch button thing to control the frequency, and what MC was talking about the block delays?
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #46 on: January 08, 2016, 02:51:27 am »
i'm tryin to understand that code.  How does arduino know that if only the left button is held high, to cycle once and turn off all led's and stay off, yet, if the brake is applied (high to both sides) then all LEDs cycle and stay lit?

I would think that if the turn signal didn't flash, then the led's on that side would cycle (sequence) then stay lit?  I mean, the code is the way I want it, it works for those LED's, but I'm just trying to understand the code.
 

Offline SL4P

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
  • There's more value if you figure it out yourself!
Re: 555 Delay Timer.
« Reply #47 on: January 08, 2016, 03:02:26 am »
Hi there
I was looking at those drawings, and although I'm not familiar with that particular drawing tool, where do the switches pull down to OV?  Theres seems to be a pull-up to +5, which is not strictly needed with internal pull-ups, but I can't see the push button 'pull down' when pressed...?

Of course this is inverted logic, and in the case of car wiring, pull-up when 'on' is probably more likely in the final software... but nothing else changes.

Is there a schematic anywhere that you can put up, so we can review the actual design, rather than just the breadboard simulation diagram?

added: I just looked at the video... when you press the brake button, the lights come on sequentially...  is that correct (or legal)?  I would have expected the brake lights to come on simultaneously.
« Last Edit: January 08, 2016, 03:06:45 am by SL4P »
Don't ask a question if you aren't willing to listen to the answer.
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #48 on: January 08, 2016, 03:08:15 am »
no schematic yet. The simulator is from 123d

Right now, I'm trying to figure out how to change all those delays to millis()

That's what you were talking about, right MC?

Not sure this link works yet...
https://123d.circuits.io/circuits/1439224-sequential-taillights/edit
 

Offline Falcon69Topic starter

  • Super Contributor
  • ***
  • Posts: 1482
  • Country: us
Re: 555 Delay Timer.
« Reply #49 on: January 08, 2016, 03:17:39 am »
MC,

It is legal as long as the brakes stay on steady after the first initial Sequence. 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf