Pages

Showing posts with label Leds. Show all posts
Showing posts with label Leds. Show all posts

Saturday, 30 December 2023

Automatic Backup Lighting - V2.0 Details

 

 Description

This project  provides automatic backup lighting whenever the mains power is lost. 

Using high power white leds the lighting allows me to safely move about.

Multiple lights can be daisy chained via the power connectors marked AB in the schematic below. I only fitted one connector to the PCB pictured since it was a prototype.

Use of the bridge rectifier means I become agnostic on the power source used. AC or DC from a wall wart, 9V to 24V is fine.

Because the STM8S003 does not have a bandgap reference voltage I simply use a 3.08V reset chip to monitor the battery voltage and provide a go/no-go signal to the micro.

Picture of finished Prototype


Rough but it works really well.

 Schematic

 


Software

Here is the barebones V2 code. It runs on a STM8003 flashed with STM8 eForth. I didn't bother trying to minimise the current drawn by the micro beyond that achieved by simply slowing down the clock, resulting in around 1mA of current drawn by the CPU.

For the version with the button fitted please contact me and I will upload it. I would need to tidy up my comments in the listing before uploading.

\ If Pwr? Pin is high turn off light after 20 seconds
\ If Pwr? is low turn off light after 5 minutes

RESET
NVM

Variable 'Toff \ time light is on when power fails
Variable 'Ton  \ time light stays on when power restored

\ Port C Pins
6 CONSTANT _Pwr?
7 CONSTANT _LedEn

\ Port D pins
2 CONSTANT _LowBatt?

: setup_pins  ( -- )
   \ Port C inputs are floating, no interrupts enabled
   [ _LedEn PC_DDR ]C!  \ Port c outputs
   [ 0 PB_DDR _LowBatt? ]B! \ set as an input
   [ 1 PB_CR1 _LowBatt? ]B! \ enable pull-up
;

: _LEDon ( --- ) [ 1 PC_ODR _LEDEn ]B! ;
: _LEDoff [ 0 PC_ODR _LEDEn ]B! ;
: LowBatt? [ PD_IDR _LowBatt ]B? ;

: Light?
   Pwr?
   if   1800 'Toff !
       'Ton @
        If      _LEDon -1 'Ton +!
        Else    _LEDoff
        Then
    Else
        90 'Ton !
        'Toff @
        If   _LEDon -1 'Toff +!
        Else _LEDoff
        Then
    Then
;

: MAIN   
   SETUP_PINS
   [ $35 C, $1F C,  $50 C, $C6 C, ]     \ Clock CPU at 15.625kHz
   BEGIN
      LIGHT?
   AGAIN
;

RAM   
NVM
' MAIN 'Boot !
RAM


Saturday, 7 October 2023

Automatic Backup Lighting - V2.0

After several months of not needing backup lighting we suffered a week of regular power interruptions due to an equipment failure on the grid feeding our suburb. While very inconvenient it did highlight how useful automatic backup lighting can be. 

I have made the following changes since V1.0:

  1. switched to LiFePO4
  2. swapped to a STM8S003 running STM8eForth
  3. tried a variety of Leds. 

LiFePO4 Batteries

Switching to the LiFePO4 battery was a mixed blessing. The run time is impressively long though I could have achieved this with a different Li-Ion battery. And potentially the life in cycles means the backup lights might last for at least my lifetime.

For a while I had more lights than I could keep on charge. So I was forever having to manually connect and disconnect. Once I forgot to do this and the battery dropped below 3.0V. Which meant the micro wouldn't trigger the charging circuit and the cell kept going flat even though I thought it was on charge. The result was a ruined LiFePO4 battery. A change in hardware fixed this.

Most of all I slept easy knowing there would be no spontaneous combustion risk, unlike a li-ion battery which has a very small risk of bursting into fire.

STM8S003 running STM8eForth

This is almost perfect. Only a few cents more expensive than an ATTINY device and presently has better  availability. The ability to reprogram or adjust parameters via a serial cable as needed was a huge improvement over the ATTINY development landscape of assembly language and write / burn cycles.

The only downside was a battery voltage below 3V means it goes into reset which prevents the battery charging since the micro was controlling a pass transistor. That's been fixed. The presence of a charging voltage now turns on the pass transistor and the micro is not involved. The micro merely senses the charging voltage is present and controls the lighting accordingly. 

It meant I could alter things like on and off periods very easily by connecting the light to a serial port. And the button could be programmed to do one thing while on charge and another when there was no power as I thought up new applications. 

The CPU clock is now down to 15kHz which means the micro draws only 0.5mA. So once the battery voltage falls through 3.1V and the light is held off, the battery can run for a long time before the micro goes into reset and halts. Once power is restored and the battery voltage rises everything goes back to how it should be.

Leds

This proved to be the most frustrating part of V2.0 due to tolerances. By which I mean the led driver, supposedly turns off at 27V but in practice it can be lower due to tolerances. Using 3 high intensity leds with a 9V rating doesn't mean they clamp to a 27V level. It depends on the current being forced into the leds. More current means a higher voltage.

Once I realised this was why sometimes a board would work and other times it refused to it was a lot smoother sailing!


Conclusion

I think I have all the bugs resolved now. In the New Year I hope to write up this project in more detail.

A really bright backup light can prove immensely useful. And being able to unplug the light to use as an inspection lamp or similar has been proved to be very useful. The only thing I would change if it were possible would be to use a LiFePO4 battery more like the form factor shown below. The large cylindrical LiFePO4 cell constrains the sort of case I can use.

 

Saturday, 19 August 2023

Joule Smasher Led FLasher - Flat CR2032 Results

So this trial was meant to be testing a NEW CR2032 cell. I initially expected it would last about 2.5 years. So imagine my surprise after 90 days when the voltage was dropping quickly:


Close inspection of the battery revealed it was not one of the new batch I had brought. Rather, it was probably the battery I changed out of a car or garage remote. Like my eyesight, my memory fails me!

Anyway. I'll let it run for another day or two till it stops then put in a fresh new battery. It is encouraging that a flat battery ran for over 3 months since it makes my estimate of 30 months from a CR2032 cell look readily achievable.

Meanwhile, the AA battery just keeps powering along on track for 10 years of life. 

 

Update - my maths was wrong. A new CR2032 should last perhaps 6 months. And a fresh AG3 cell perhaps 28 days. 

Sunday, 29 January 2023

Joule Smasher Led Flasher - Changes for Improved Life

I was building up another JSLF and before I finished populating the board I wanted to confirm how suitable the diode and moulded choke were.

With a 330R resistor tacked on the output for a 10mA load I  measured a current of 68mA for an efficiency of about 33%. This is well short of the roughly 80% suggested by the datasheet. The 330R was swapped to one giving a load of 4uA, the sleeping micro's consumption. The overall efficiency with the 4uA load was 30%.

When I apply the duty cycle of the current drawn I get a disappointing 33% result.

Swapping the schottky diode with some other general purpose shottky types showed no real change. I put some fast recovery type diodes on the list of things to order.

Turning my attention to the inductor I swapped in a 22mH power inductor. This gave an immediate improvement. Without boring you with the finer details the overall efficiency was now 74%. 

I was stunned that the moulded choke was so poor yet the life I was getting was amazing. I didn't have many of those 22mH power inductors and they were too large an inductance according to the application notes in the datasheet so I chose a physically large and plentiful in my parts bin 100uH as the new standard. 

Will the doubling in efficiency lead to twice the battery life?  It's too early to tell but after one day the battery voltage of the updated JSLF with a fresh AG3 battery is ~50mV higher than the previous 4 trials.

There is one more change to mention. 

Since the boost IC has an enable pin can it should be possible to get a few more percent in overall efficiency by only enabling the Boost IC when the LED and Micro are active. When the micro is asleep and the led is off the sleep current can easily be met by the capacitor on the 3.3V rail. This avoids the 30% efficient state for 99.5% of the overall flash cycle and should lift overall efficiency to around 80%.

So I now have a desk with 6 flashing LEDs nearby. In a week I should see the impact of these changes.

Update:

After 2 days I wasn't seeing the improvement I expected. I initially assumed it was battery characteristics but after the curves between trial 5 and 6 kept diverging I investigated and found that I was enabling the boost during the inefficient led off time period. 

With that fixed I expect to see curve (C) develop into a plateau and cross above curve (B) in due course.

Monday, 9 January 2023

Joule Smasher Led Flasher - 2 Days from a Dead AAA (0.76V Opencircuit)

I took a very flat AAA battery from a discrete led flasher that had stopped flashing and used it to power a Joule Smasher Led Flasher. It ran for 48 hours supporting the case for how good the Joule Smasher Led Flasher is.

The boost IC worked really well. It started with a battery voltage of 0.76v and delivered full brightness flashes down to 0.5V. Somewhere between 0.54V and 0.25V it could no longer boost to 3.3V so the LED brightness diminished. At 0.25V the led was still visible but the boost voltage had fallen to 1.75V so it wasn't very bright. RiP you poor AAA.

But what a remarkable result. It supports the battery life expectation from a fresh AA of 6-8 years and a end of life estimate of 0.4V for the battery. A similar trial is running on a AAA that started at 1.013V and after 16 days it reads 1.002V. I believe I'm watching grass grow!