Project: Automatic bike light (School project)

Discussion in 'The Completed Projects Collection' started by tom66, Jul 7, 2010.

  1. tom66

    Thread Starter Senior Member

    May 9, 2009
    Unfortunately I don't have a picture as this was my final year project at my school and I haven't been given it back yet, but anyway, here goes. Hopefully it'll get me my GCSE A* in Electronics...

    For the project I decided to design a bike light which would automatically switch on when light levels got below a certain level. Essentially it consisted of three boards, one board with the light sensing circuitry, one board with a PICAXE micro, and one board with six LEDs on it. All boards were tightly packed in a plastic case, and the circuit was powered by 3x or 4x AA cells, rechargeable batteries being an option. All boards were stripboard, designed in a CAD program and soldered by hand, and the components were all chosen to be commodity components. I used a PICAXE micro because that was all my school had. I had a PICkit2 at home and a few PIC's (mostly PIC16F690's); I considered programming my own micros in C or assembly, but I decided just to use flowcharts+PICAXE as those were the norm and the school had all the gear...

    I have attached a schematic drawn from memory.

    The circuit uses the 555 timer as an inverting Schmitt trigger. The capacitor C2 and the resistors LDR1, R1, and R2 add an element of delay. The rate of delay changes depending on the light levels. Recall that a 555 switches on at 2/3rd supply and off at 1/3rd. I could have also used an opamp, but a 555 was simpler, cheaper, and more familiar, plus it had lower power consumption with the CMOS variant.

    If for example you enter a tunnel the output will switch on quickly (<1 sec) and when you exit the tunnel the output will switch off quickly (<1 sec). However if the light change is less sudden, for example going under a diffused street light the delay will be about 5 seconds, and if you are just riding past them then it will not usually trigger.

    This feature obviously has safety benefits as you do not have to remember to switch your bike light on and you do not need to worry if the batteries are flat because you left the light on by mistake. (Of course, in the standby mode, the device draws a small current, so the batteries will eventually go flat, after about 6 months.)

    The main purpose of capacitor C2 is to slow down the Schmitt trigger, which makes the output relatively slow to change. It will not suddenly change unless an extreme change of light is sensed, like going from darkness to full brightness. This means that if you are cycling along and it is just getting dark it will not switch on and off as the light level varies because of e.g. clouds, your position or even if the LEDs themselves contribute to illuminate the sensor.

    The output of the timer goes through a NPN transistor because the TLC555 cannot pass the 50 mA or so needed by the PICAXE + LEDs. Now importantly the NPN drops voltage. So running at 3 volts it drops about 0.7 volts. Which means the PIC only gets 2.3 volts or so, and the LEDs only get 2 volts (because of the poor Rds(on) of the PIC's output MOSFETs... about 20 ohms.) The PIC is rated to go down to 2 volts and I have seen one working on a single AA at 1.5 volts, but the LEDs generally require 3 volts to work brightly, which is why I chose to work from 4.5 volts or 6 volts. It will still work at 3 volts, it just won't be very bright.

    The pattern is chosen by pressing the pattern change button. All buttons, the main power switch and battery pack were hidden in an old water bottle, wires coming out of the lid. An idea I had was to add the option of a dynamo board, which would convert AC from a 12 volt dynamo into the 4.5 to 6 volts required by the circuit, essentially making it always functional (no need to check the batteries), but I did not have time.

    Most of this circuit could have been supplemented by using the PICAXE's ADCs, however I decided to aim for a dual analog-digital design for some extra marks. So don't expect to see something like this in a production bike light.

    Enjoy, I welcome feedback...
    Last edited by a moderator: Dec 27, 2011
  2. tom66

    Thread Starter Senior Member

    May 9, 2009
    Correction on the schematic, resistors R6 through R11 should all be 56 ohms, not 560 ohms!

    One thing I noticed is that when running the bike light the resistors all got slightly warm (not very hot, just warm to the touch.) Probably because I was using them near their power dissipation rating. So either 1/2W resistors would be used in a future versions, or perhaps an LED driver for maximum efficiency.
  3. Markd77

    Senior Member

    Sep 7, 2009
    A nice addition would be a vibration sensor so that the light would not turn on if the bike wasn't moving in the last 5 minutes. I have a feeling I would forget to turn it off at night when I wasn't using it and would end up with flat batteries.
    Overall pretty good project and should get a decent grade.
  4. tom66

    Thread Starter Senior Member

    May 9, 2009
    That would be cool, but it might make the circuit too complicated. By that point I might as well use a quad opamp and average the tilt sensor. Then I would have to integrate it and compare it to reach the 5 minute timer. By then, it would be getting too complex, and would probably have to be done using the PICAXE.

    Or I could use a missing pulse detector using a 555, or use a 556 dual timer.

    But still, I'm kind of mumbling now so I'll be quiet.

    The advantage of the analog circuit I built is also lower power consumption. Unfortunately the locked down PICAXE chips appear not to have any power save options. So running an infinite wait loop would not be a possibility - it would consume about 5mA, which is massive for some AA batteries. The 555 circuit consumes ~0.4mA, still quite a lot but it's much better than 5mA!
    Last edited: Jul 8, 2010
  5. tom66

    Thread Starter Senior Member

    May 9, 2009
    Because of the positioning of the sensor (on top or on the side) nothing will happen...

    But if somehow the LDR is exposed to the full beam them the lights will go off, but hopefully the headlights will make the bike visible.
  6. bertus


    Apr 5, 2008

    To avoid the light of going off by the headlights of a car, you could build in a delay of about 30 seconds.
    By the time the car has passed the light will still burn.

  7. tom66

    Thread Starter Senior Member

    May 9, 2009
    I was not worried about it due to the positioning of the sensor.
  8. hgmjr


    Jan 28, 2005
    I am wondering if you could eliminate the 555 timer all together and connect the LDR and an appropriately sized pull up resistor directly to the PICAXE ADC input. The PICAXE should have not problem at all generating the timing needed to flash the LEDs as a function of the voltage present at the ADC intput. This would simplify your circuit and reduce the power consumption all in one stroke.

  9. tom66

    Thread Starter Senior Member

    May 9, 2009
    I made a note of this.

    1. I was trying to get good marks so I created a combined analog and digital circuit.
    2. The PICAXE has limited interrupt capability and no standby modes, so it would consume ~5mA running off the 7.37MHz oscillator, which is too much power on batteries.