Wednesday, April 4, 2012

Powering speakers, etc with a bike dynamo

I recently got rid of an old Pioneer receiver in favour of a tiny Class D amplifier. The class D amp is more efficient, sounds better and is approximately 10x cheaper. Did I mention, it's tiny?

While shopping for a variable voltage regulator for a power supply I discovered that EBay sells fun-looking 1.5V-26V regulators...for $10. I've been eyeing the Busch + Müller E-WERK universal power supply(up to 13.5V) for a while now, but those sell for $110. It's no fun spending a hundred bucks on a bike accessory that may not prove useful. I had no choice but to buy the EBay regulator.

As my first experiment I tried powering a 12V MR16 light... it worked, but flickered like mad. A fat capacitor on the regulated side calmed the flicker. Great, now I can use indoor lights to illuminate my outdoor bike rides.

Next I tried a 1-meter 12V LED strip, the strip uses a lot less current than the light bulb so it was quite happy.

Then I wondered...could I power decent speakers using dynamo power? $8 ebay amp later...yes I can!
Recipe: dynamo -> rectifier bridge -> high voltage smoothing capacitors -> regulator -> 16V 0.1F cap -> (optional voltmeter) -> ta2024 amp -> speaker[s]

By the way, do not buy this ta2024 amp, spend a few dollars extra and get a board with proper audio in. I had to desolder the weirdo 3pin connector and solder on a home-made audio cable. It also comes with extremely crappy capacitors and crappy terminals for remaining connections (vs decent stuff on the $14 ta204 amp).

I think this voltage regulator will prove very handy for bike touring + camping. Should be especially fun once I combine the dynamo with a 3.5W solar panel. Buck/boost will prove very handy indeed.

Thursday, March 29, 2012

Home automation via Mi Casa Verde Vera 3 + Z-Wave

Our baby girl was born recently. We had the house heat off while we stayed at the birth center.

Because we live in the future, we were able to to turn on the house heat(& unlock front door) from the car while driving home. The house got down to 10C (50F) while we were away. Thanks to technology, we did not have to endure that temperature upon return :)


So far I have my thermostat, door lock, audio amp and some lights hooked up via Z-Wave. Mi Casa Verde Vera 3 controller is the brains of the operation. It took a couple years before I got everything hooked up because the Vera 3 controller is the only viable option, yet is so damn expensive (fair cost should be ~$100).
I waited on opensource stuff to get good (ie LinuxMCE + openzwave), but it seems like Z-Wave will be obsolete before there is any useful open source support for it.

So far controlling the thermostat from my phone/laptop is the killer feature of the system. We like to keep our house barely warm enough. Unfortunately we have an idiotic gas-powered hot air heating system which guarantees that some rooms are too hot while others are freezing. We can finally adjust house temperate depending on what room in the house we are using without running back/forth to the thermostat.
This became even more valuable once the baby arrived. Ellen can control temperature/light with one hand without yelling at me to help :)

Controlling lights is cool, but it wasn't a life-changer.  Time taken for unlocking phone, connecting to the controller + execution lag are fairly similar to walking over to the damn light switch. I suspect Ellen will appreciate this more while she has her hands full with baby and can't move easily.

Same goes for the door lock. We have a code lock on one side of the house and a z-wave/code lock on the other. Frankly it takes longer to open the door via phone than to punch in the code. We haven't used house-keys since we moved into the house...cos keys are a pain. Z-Wave makes it easy to change lock combination, check that the door is locked, etc, so it's somewhat valuable.

The coolest part of the system is ability to group individual device actions. We have a "house off" command that locks the door, turns off thermostat, turns of various lights/etc. It's great to crawl into bed, poke at the phone and hear various things around the house shutting off.

The Vera controller supports a lot more than just Z-Wave. It can do X10, custom scripts, respond to UPnP commands, schedule commands based on sun-set/rise times, etc. Various Z-Wave doodads also act as status indicators. In the future I plan to setup the thermostat to turn off while the door is open, open/close windows + turn on fans based of indoor/outdoor temp + time of night, etc. It is also possible to have the DHCP server on my lan report for when my phone appears/disappears so vera can turn off thermostat/lights automagically when we leave the house.

I probably spent $300 of real money on various Z-Wave gear + $300 of money suckered out of credit cards on this setup. There are alternatives.

Lots of time approach: I think one can do a lot of this on the cheap with xbee + atmega + relays. The thermostat is a little trickier, door lock is harder yet. This will involve reinventing the state machine behind Vera and interfacing with android, web, etc clients. I think it would be cool if open source people moved in this even made some noise about android-controlled light bulbs(and went quiet), but at the moment one would  have to start from scratch.

I do what TV tells me: People with more money than sense can pay Verizon/etc a monthly fee to do a lot of this. Verizon supports a strict subset of what the Vera controller does..but hey, they have TV ads.

Less-weird-stuff approach: There are a couple different wifi thermostats on the market atm. This one seems like a cheap way to go. Wifi is a lot less weird and proprietary than Z-Wave, but this gets you no closer to controlling lights, doors :)

Now that the initial time/$$$ investment is made, I look forward to tightly coupling my security video, door bell, phone, sound, cooling systems. Motorized blind/window control is stupidly-expensive, so I'll probably be rolling my own. There is lots of room left for energy savings + coolness factor improvements.

Wednesday, January 4, 2012


As people get older they gain clout, respect and other sorts of undeserved credibility. One way to get rid of such credibility is to try to predict the future (and get it wrong). I feel like a new year is a good opportunity to take a stab at this.

Tablets are an evolutionary dead end
Remember RAZR phones, palm pilots? Tablets will evoke the same sort of memories in a couple of years.

LCD/OLED as a window into the internet will be laughed at

I read a great book about the history of cocaine. When cocaine was discovered, it was a local anesthetic, virility potion, steroid, cure for nymphomania, cure for addiction, etc. This all looks quite silly in retrospect, but it really reminds me of the hype over internet connected screen touting devices. "People used to think that the best way to stay connected is to scorch eyeballs with awkward square flashlights with graphics on them".
It blows my mind that even though humans have a multitude of senses, we've settled on something that destroys eyesight and ties one to a desk. Even best of breed phones, tablets are still tied to an access point, cell tower and are useless in sunlight. Instead of communicating directly, devices prefer to channel themselves via amazon or apple servers.

I think the future is in wrapping information flow around the many senses (seeing, hearing, tactile feedback etc). I think the future will be shaped more by odd-ball hackers and less by tech messiahs & their knockoffs repackaging the same thing every 18months. Hopefully B2G is the first step in that direction. Perhaps it will result in extremely promis^H^H^H^H connected devices that will mate with every device around. I know we have the right people working on this :)

Tuesday, November 22, 2011

How to run a bare ATMEGA328-PU with an internal oscilator (at 8Mhz)

Arduino Ecosystem rocks
Arduino is a great way to minimize the amount of variables when getting into microcontrollers. Flashing, cross-compilation, libraries, dongles are much easier(and cheaper!) when standardized.

I bought an expensive  arduino nano v3, I got comfortable enough with it to blink an led and do with pwm. Unfortunately arduinos(except lilypad) feature lame 5V voltage regulators which require 6.2V to do anything useful; though atmega chips will supposedly run at as low as 1.8V. End result was that the NanoV3 did not run properly when hooked up to my 5V power supply on the bike.

So in the in the interests of not building a new power supply and not using a board with a whole bunch of pointless components I bought some straight-up ATMEGA328-PUs and a USB flasher.

The rest of this post documents various gotchas.

Pinout on Sparkfun is mirrored!
Red stripe on the cable indicates top. However the pinout is mirrored. One is supposed to look at it with the stripe on top and holes facing away.

I wondered why seemingly identical chips were selling for a different price. P in 328P stands for picopower and as far as I can tell it allows one to turn off brownout protection. In my case brownout protection is something I want. However, fucking avrdude does not recognize ATMEGA328(without P) and bitches that one should pass -F when specifying -p atmega328p(there is no atmega328). This prevents Arduino IDE from functioning. In order to get a functioning IDE I needed to:
  1. Modify signature for atmega328p in avrdude.conf:

    - signature       = 0x1e 0x95 0x0F;
    + signature       = 0x1e 0x95 0x14;

    (Obviously the proper thing to do here is to add the new chip to avrdude)
  2. Use from as an inspiration for the following boards.txt entry:[usbtinyisp]ATmega328 8mhz



  3. Burn bootloader with tools->burn bootloader->UsbTinyIsp
  4. Assemble board as per One does not need to hook up GND(pin 22) or AVCC(pin 20). Connect ATMEGA RESET(pin 1), VCC(pin 7), GND(pin 8), MISO, MOSI, SCK(pin 19) to the flasher.
  5. Check the pin mapping. Note that Arduino software pins do not match physical pins(this cost me a few hours).
  6. Proceed to use Arduino tools with a convenient $2.82 chip* + $15 programmer rather than an inconvenient/overpriced Arduino board.
     * I would've spent an extra $1 to get the ATMEGA328P had I known the many hours of agony it would've avoided.

      Saturday, July 16, 2011

      My NAS is smaller than yours

       I once blogged that ARM devices are useless and how one shouldn't buy them cos they run weird forked kernels on weird bootloaders. I also blogged on how awesome and low power my Atom box was.

      Since then my Atom box died (probably the power supply), so faced with the option of rebuying various components until I find one that broke I decided that I'd rather forgo that. Instead I got an $40 Seagate Goflex.

      The atom box idled at 13W and maxed out around 20W, which was pretty impressive. Goflex can idle at 4W and maxes out at 7W. The 1ghz CPU is no x86 in speed, but it can keep up.

      Clever people developed a fully-featured Uboot bootloader for it so it takes care of that typical non-x86 suck. I opted to run arch linux for arm since Debian support isn't particularly mature. In some ways Arch is better, it doesn't play games with proprietary firmware and stays up to date better.

      So yeah with a $40 pricepoint, dual native sata, 4W idle even I will run ARM :)

      Bonus: In theory I should be able to run the static binaries I compile on the goflex on my android phones.

      Saturday, May 14, 2011

      Cheap solar power for my phone

      My phone is useful for doing GPSey things and staying connected. Unfortunately expecting more than a day of use is unrealistic. So I set out on a quest for portable power.

      I spent way too much time choosing a dynamo hub, building a wheel, having a friend build a circuit so I could charge my phone while away from home.

      One day I was randomly surfing dealextreme/ebay and stumbled on something that was unbelievably awesome: cheapass solar power. Turns out a $25 solar panel and a spliced usb cable is enough.

      At this point the main benefit of a dynamo hub is that it works all year long(24x7 as long as I'm biking). Dynamo also has a benefit of being a bunch of metal that's part of the bike. Attaching a solar panel will require some cleverness to avoid smashing it the first time the bike falls over.

      On the other hand the solar panel is light and will work great for camping while off the bike. It's good to have options.

      • I've had this for a while now. This solar panel is amazing. It is exactly as the seller claims: 5V and provides up to 700mA of current. There is a problem where if the panel gets in the shade, the current level drops off and stupid charging circutry on my Vibrant continues to try to charge. I documented it in this forum post.
      • ebay listing I bought this from.

      Saturday, March 5, 2011

      I have road disc and you do not...neener!

      I always found sidepull brakes to be pathetic. The current generation of road brakes are much better than the old style mount-bike I've used before, but they still suck. Unfortunately most roadies are imitation whores and will never ever sport components that a pro rider wouldn't ride(which they can't cos of stupidly conservative racing rules). As a result no road carbon forks on the market feature disc brakes. So I suffered and suffered. I refused to buy stupidly expensive brake pads to make up for sidepull suck.

      After years of suffering the indignity of under-performing brakes, I met my friend Adam. Adam got mad carbon skills. He turned my oldish carbon fork into a sexy postmount disc fork.