Minimal hardware Axe LED Night Light

cebersp

New Member
Axe- LED- Night Light

This is a minimal hardware project!
It is intended to give orientation in a dark room in the night.

The LED has three (!!) functions:
1. Emit light flashes for orientation.
2. Act as reference voltage 1,67V to measure the battery voltage. If the voltage is under a limit value, then double flashes will be sent.
3. Act as light sensor – photo diode and capacity. This capacity is charged first and then will be emptied by the photo current. If the capacity is emptied fast, then no flashes and a longer sleep will occur.

21.10.2007
Have fun with the picaxe!
CWE


' LED Nachtlicht 21.10.2007 C.W.E.
' Nacht- Orientierungslicht betrieben an 2 AA Zellen
' Es wird festgestellt, ob es dunkel ist. Wenn es dunkel ist, dann leuchtet eine LED kurz auf.
' Wenn die Batteriespannung unter 2,25V sinkt, dann Doppelblitz.
' Funktionen der LED:
' 1. Leuchten; 2. Referenzspannung für Batteriespannungsmessung;
' 3. Photodiode, die ihre eigene Kapazität entlädt.
' Eigenschaften Fotodiode: C=20pF, I= 10E-6 A hell, I= 10e-12 A dunkel
' Rote LED
' Spannung an der LED 1,67V: UBat= 1,67/adc*1024



' Const
symbol LLimit = 350 '950

symbol ULimit = 2250 '2250



' Ports
symbol LEDM =1 ' Leg 6 Minuspol der LED
symbol LEDP =2 ' Leg 5 Pluspol der LED
symbol R =4 ' Leg 3 Vorwiderstand zum Pluspol der LED


' Vars
symbol UBat = w6
symbol Light = w5
symbol i = w4



Start:
for i= 1 to 10
low ledm
high r

pause 300
low r
pause 300
next i

high r
readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*40 Ubat in mV
debug

wait 5

Schleife:
Laden: ' Lichtmessung
low r
high ledm
'pause 10
nap 1
readadc10 ledm,w0
input ledm

messen:

nap 3 '5
readadc10 ledm,Light
debug

if Light>LLimit then 'Dunkel: Licht einschalten
low ledm
high r

readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*4 Ubat in mV

nap 1

low r

nap 2

if UBat<ULimit then
high r
nap 1
low r
endif

low r ' Diode umpolen für Messung
high ledm
nap 5

else
sleep 10 '*2,3 s

endif


goto Schleife

end
 

Attachments

Mycroft2152

Senior Member
Nicely done!

The use of the LED as both a sensor and a display is very clever.

To reduce the power requirements, you might consider slowng the clock down, though you may have to adjust the LED sensor time accordingly.
 

cebersp

New Member
Slowing down?

Thank you for the feedback, mycroft!

Slowing down is a good idea, but I thought this was not possible with 8M type?

Best regards,
Christof
 

Mycroft2152

Senior Member
Hi Christof,

There have been a number of posts about reducing the power by underclocking an 08M and disabling the BOD (Brown Out Detector). Combined with making sure all inputs are tied to ground, a signicant power savings can be acheived. It is a great technique for certain applications.

Based on the forum's posts, Technical added a new command to disable the BOD in the 08M. This was a great example of Technical's response.

An 08M normally running at 4mHz can be underclocked to 32kHz, with the corresponding execution speed drop for ~2000 instructions per second.

Myc

http://www.picaxeforum.co.uk/showthread.php?t=4826&highlight=clock+speed+08*

http://www.picaxeforum.co.uk/showthread.php?t=2292&highlight=clock+speed+08*

http://www.picaxeforum.co.uk/showthread.php?t=7143&highlight=lower+clock+speed
 
Top