Standlight tweaking and pack-ugh-ing
November 27, 2010
I’m still tweaking the software. Latest mistake on my part was getting the numbers backwards for the on/off counter, so right now it is a little too happy to turn on. This doesn’t necessarily run down the battery; if the battery comes on when the bike is moving “too fast”, the effect is to dim the lights slightly as the system voltage drains into the battery, and the batteries are (slightly) charged.
I added a switch to allow me to force the batteries on; in theory I could use the bike as a battery charger, though it would take hours, but the main goal is to permit the lights to stay on arbitrarily long if you need light (fixing something by the side of the road, for example). With the bike stopped, toggling the switch off-on-off turns the lights off immediately. Usually.
“Debouncing” the circuit has been a little tricky. When the microcontroller decides to “turn off” the lights, it is really turning off its own power, as well as the power to a beefy trio of capacitors, an op-amp, and a little switching power supply. It doesn’t just go to sleep, and sometimes thinks it sees signals as things settle unevenly towards zero (somewhat like HAL singing Daisy). So, timers and wheel turns are taken on faith as they occur, but for purposes of detecting switch movement, and for resetting the software to its on-the-road state, there are counters. A net of 313 (1/10th second) samples must agree before the switch is judged to have a value. For purposes of deciding that the bike is no longer sitting still, 8 zero crossings (one foot of motion, can be back-and-forth) must occur. This is partly necessary because there can still be voltage to the microprocessor even when the lights are out (surprise!) as the big caps slowly drain.
Packaging has been a pain. Originally I had intended to pot the controller in wax, but when I did that, for some reason it didn’t work. It half-worked, but I couldn’t get the lights to go on. Quite depressed, I got it out of the wax, checked the wax to see if it was conductive (shouldn’t be, but you never know), and discovered that now everything was working perfectly. Maybe I goofed somehow on the light test.
So, instead, and especially for this one where I am still taking it apart and putting it together again (mostly to swap out the microcontroller), things are held in place with elastic cord. I’m not entirely happy with the bulk, though part of the problem is that the bike I am testing on has no water bottle cage. An 8-pack of AA cells is probably too big, especially given that the batteries are only used intermittently.
The rear light is a win. That is a P-clamp, plus some aluminum angle stock, plus a bare LED on puck for a taillight, all but the lens painted with nail polish to keep the weather out.
I think the front light would be acceptable if I had a better place for the cylinder-o-circuits. The light bracket is made from two bell mounts, two longs bolts or screws, some aluminum stock, a mirror (to cut off some glare from other cyclists and pedestrians) and some mounting nuts. The cutoff is not good enough; I think that low beams (amber, either down low or aimed low, mounted on aluminum angle stock) will be necessary.
I imagine it would be tidier if the blue, orange, and green wires came out the bottom of the circular PCB, through aligned holes in the bottom, additional (blue, red, black, white) ran up to the battery switch, and then an AAA battery pack was cradled in something squishy below the switch.
Wow. (Been experimenting with tweaks.) I think a few noise-reducing capacitors might be in order. Sometimes a few taps on the bike are enough to turn the lights on.