Saturday, March 6, 2010

Fonera 1-wire MicroLAN extension

I wanted to add a 1-wire bus to one of my Foneras. I already flashed it to DD-WRT some time ago, but realized that I can't disable the serial system console or the shell so there's no way to use the serial port for anything else. I searched around and it seemed like Gargoyle might be a better solution. It's a firmware based on OpenWRT. I flashed it, only to realize that the same restriction applies to the system console part. It seems all Fonera firmwares ignore the kernel command string set in RedBoot and just work with a hardcoded one. Which usually contains console=/dev/ttyS0 making the serial port useless.
A post on the Gargoyle forums refers me to setconsole, which isn't included in either version (stable/testing) anymore. I tried with several setconsole compiles of my own only to get an assortment of error messages. Because compiling a whole new firmware is entirely too much of a pain for something as simple as freeing up a serial port i ended up unpacking the kernel image and modifying the hardcoded string with a hex editor. Then repacking, padding, and flashing the modified image to the Fonera. (modify the string to console=/dev/null)
The LZMA SDK from 7zip can be used for the compression.
Make note of the kernel image size before unpacking, and pad with null bytes to that exact size after repack. This is not optional. Flashing will fail otherwise.

This worked, so I proceeded to disable the shell in /etc/inittab making the serial port usable again.
Thanks to the OpenWRT roots the rest was pretty easy on the software side.
the commands
opkg update
opkg install owfs
opkg install owhttpd
gave me all the tools I needed to work with 1-wire.
And ..
opkg install php4-cli
opkg install php4-mod-gd
gave me what I needed to code up web interfaces.

The CLI compile is required because the CGI one is Apache specific. Gargoyle has a small httpd lacking most of Apache's features. The CGI compile will error out however the CLI release can be made to work. There are certain annoyances like a missing $_GET/$_POST and the requirement to send a \n before page content and after headers, but they are not that serious.
( to fix get: parse_str($SERVER["QUERY_STRING"],$_GET) )

On the hardware side I opted to use a DS2480B 1-Wire Line Driver chip. This chip is used in the DS9097U adapters so it's basically the standard in UART to 1-Wire interfacing. I wanted to include fancy things on the board like a software controlled power switch and an activity LED, but in the end I abandoned both. The power switch didn't work out, and the LED was pretty useless due to the low activity on the bus. Because of this the original board is ugly and overkill. It is however extremely simple to hook this chip up. There are no external component requirements. POL VPP and VDD needs to be connected to together. Rest is obvious. (TXD,RXD, 1-w DQ and GNDs to appropriate holes/solderpads on the interface board, then TXD,RXD,GND to Fonera, and DQ and GND to some sort of connector for the 1-Wire bus. You can also get the 5V for the interface board by soldering to the Fonera's PSU connector)
Here's a simplified interface board:


eagle brd here

I opted to use an RJ9 connector simply because I had one on hand, and because it fit right next to the Ethernet's RJ45.


You might want to consider including the Fonera's 5V on your connector. It could become handy if you want to attach non-parasitic devices in the future. I opted not to do so. I will be building a "powered hub" out of a 5way phone-line splitter later.

For testing I used iButtons hooked up as seen below.
RJ11 Blue dot receptor -> Ghetto RJ9<->RJ11 cable -> Fonera


Simple OWFS testing: (connecting and removing iButton)


Success!
Now I have a LAN/WLAN/MicroLAN router :)

Tuesday, February 23, 2010

EEE Car Charger

I have an Eee 701 that I find extremely practical to have around. About a week ago I needed a car charger for the machine, and decided to buy one. There doesn't seem to be much choice in the matter. You either go with Asus's $50+ thing or get a chinese one. I got a chinese one, which lasted all of 30 minutes. It got extremely hot, then blew the fuse. I replaced it with a new one, which it immediately blew out as well. When I got home after some considerable trouble I took the damn thing apart (It was partly glued, yay.) and was staring down at a switch-mode DC DC converter.
I tried replacing pretty much every component besides the PWM controller chip but it still kept blowing the fuse.

I gave up shortly afterward and decided to build a PSU myself. I wanted to use things I had on hand so I went with the MAX668 that I used in the Laptop powered from SLA project. This is a Step-Up converter but it supports a SEPIC topology which would make it work in both Step-Up and Step-Down modes.

I designed the board, carefully hand-wound the SEPIC dual-power inductor, soldered it all together




And failed miserably in my attempts to get it working right.

I've tried 3 different FETs, 5 different inductors (both dual windings and separate cores), 4 different filter cap configurations, 3 different SEPIC coupling capacitors and 3 different Schottky diodes. I've replaced ALL of the components at least three times, yet my best result was an over 4Volt drop with a 2 Amp load. To sum it up in one word "Useless". At this point I wasted 2 days trying to track down the problem. I've compared the board layout to the schematic, and the schematic to example designs about a dozen times and I couldn't find the reason for the drop. I was not ready to waste any more time on it.

Determined to not waste more money either, especially on a chinese charger that might last under an hour again I asked around and managed to get a UA78HGASC part. This blast from the past is an adjustable 5 Amp Low-Drop-Out Linear Regulator in the TO-3 package. I've seen it mentioned in hobby electronics publications from 1987. From what I understand it's also a relatively rare part.


For anyone who'd slam this because LDOs are inefficient consider the following.
According to this LDO efficiency equation:
% Efficiency = [(VOUT) / (VIN)] * 100
The efficiency of this circuit, if we use 13V for Vin (as a voltage average for SLA) and 9.8V for Vout, is around 75%.
Theoretically a 90% efficiency can be achieved with switching regulators. A measured efficiency of around 80% was achieved by the good people who've come up with the reference designs for MAX668 SEPIC configurations. (The efficiency also declines as the load increases, but let's not think about that) So around 80% using Ultra Low RDS-On FETs, Ultra-Low ESR capacitors and taking all board design rules and recommendations into account. I have neither of those custom components, and buying them would cost more than a chinese car charger. Not to mention that I can't even BUY the kinds of ceramic caps that most of the reference designs require. It is because of this that I probably can't achieve efficiency even close to 80% with a home-built switching regulator. BUT let's say I did. Even then is 5% worth all the extra trouble/time/components?

So back to the LDO.
I had the perfect project box for this. The heat sink fit perfectly on top of it. I soldered it all together. It only needs 2 small caps and 2 resistors, as opposed to all the things a switching circuit does. I just put those on a piece of stripboard. Set the voltage. Did a load test at 50Watts. Voltage Drop.. 0.06 Volts. Things were looking great. I plug it in and... the Eee doesn't charge.
At this point I was close to setting both attempts and the Chinese charger on fire but on a whim I measured the voltage on the SLA battery I was using for testing and I got 14 Volts. Wait.. what? 14Volts is too much even for a fully charged AGM SLA, and this one was nowhere near fully charged.

So after the inevitable realization that my multimeter is measuring around 1.5volts more than the actual voltage of things because it's battery was dead, and raising the output voltage of the regulator accordingly the Eee gave in and started charging like it should. Finally.. after several days I had a car-charger. I don't know about other laptops or netbooks but the Eee 701s can run off their chargers with the battery removed. This also effectively turns this charger into a way to run the Eee off an SLA battery directly.

I feel that I should add a little bit of info on the Eee charging voltage.
On the sticker, and on the AC charger it says 9.5V @ 2.135A.
This is wrong. In fact something around 9.8 is preferred, and that's still 0.2Volts LESS than the AC charger outputs while running the Eee directly off it, without a battery.
Other people have also confirmed that their AC chargers drop only to around 9.8 - 10 Volts while powering the Eee. In fact, it seems like anything below 9.8 is insufficient (Eee shuts down, charging led blinks on-off). Best way to make sure is to measure the charger voltage while running the machine off it. YMMV but 9.8 worked out perfectly for me.

The end result:


Monday, February 1, 2010

Water Pipe Anti-Freeze Heating

UPDATE:

Check out V2 of this project here. Simpler and much less overkill :)



We have 2 buildings on our property: the house and an office building. Between the two is a semi-open garage. Through this garage runs the water pipe to the office building which is exposed to outside temperatures.
The usual procedure for this pipe during winter was to completely drain and disconnect it so that it doesn't freeze in. This has become somewhat of a pain as I needed the water during winter so solving this has become a project of mine.
I managed to acquire a bit of heating cable that I could run in pair along the length of the pipe.
One "channel" at 12volts came out to about 47ish Watts for the entire length of the cable.
I wasn't sure at first if this would suffice, but I gave it a try. The heating cable was taped to the underside of the pipe with PVC tape and copper tape where I assumed it would matter (I would've done it with copper tape along the entire length but it's expensive :) ) The pipe was then covered in foam insulation.


A DS1621 temp. probe was installed (marked with yellow tape on the picture) on the top of the pipe. (The heating cable running at the bottom should ensure that the probe isn't being heated directly by the cable, which would make measurements useless.)
Both the cable for the probe and the heating cable go into the boiler room that is accessible from the garage.
I designed a controller from what I had on hand. An old ATX PSU and an ATMega8(overkill). The AtMega is powered by the standby voltage of the PSU (5VSB). PSON is connected to PORTB.0 so the AtMega can switch the ATX PSU ON or OFF depending on temperature. (The PSU turns on when PSON is pulled low). The heating cables are hooked up to a 4pin Molex Connector.

I admit I didn't make exact measurements of the pipe temperature with the heating on, but the day after I finished this project we had -16 degrees Celsius and the pipe didn't freeze in. Good enough test for me, as we didn't have anything colder in the past 10 years. The controller sits on top of the ATX psu
in a cheap electrical box. 2 LEDs were installed, one shows that there's standby voltage, the other is a heating status / error led.



I use only 1 channel for now, since it seems to have been enough to keep the pipe from freezing in at -16C. The other channel is used as a load for the 5v rail of the PSU (at 5V it doesn't provide much in terms of heating) As it turns out, the 5V rail has to be loaded to stabilize the 12V rail, otherwise there will be huge voltage drop.

The DS1621 was actually a thermostat IC and I was considering using it in a standalone configuration but sadly that can't be done as the thermostat
functionality doesn't start until a "Start Convert" command is sent to the chip through I2c. That meant a microcontroller was mandatory, so instead of
relying on the internal functionality of the chip I just implemented the thermostat function in code. This also meant I only had to run 4 wires from the
temp probe instead of 5, and I had 4 wire telephone cable lying around.

One could use an Arduino for this, or any other dev board. Since I had an ATmega8 lying around, and my 2051 programmer was out of commission I used that. If I need the Mega8 in the future I'll probably end up replacing the controller with a 2051.

Update Feb. 01:

A few days ago I noticed some weirdness while running the tap, so I checked on the controller. The LED was flashing meaning there was an error condition, and the heating was off. The pipe was beginning to freeze in. There were 2 possible places in the code that could produce that. Either the temp. probe didn't respond or a measurement returned a value greater than 25C (which would be a bad measurement as temperatures were mostly sub-zero that day). It was probably a random hiccup as it continued to work fine after a power cycle. This however convinced me that the code needed to be more resilient. So now it retries if the temp. probe doesn't answer or if the measurement is out of bounds. Only after 3 subsequent failures does it go into the error condition. I also added a speaker that beeps out an error code if that happens, making it easier to notice. I took a picture of the controller after I reflashed it with the new version. It has become somewhat of wiring chaos, especially now that the speaker was added. The board design is a modification of this project. I didn't intend to use it here. It just happened to be the easiest solution at the time.


And the speaker on a strip of mounting tape:


You can find the controller code here. (BASCOM/AVR)



SATA Power Switch

There is a useful project at this site that I duplicated. It's a switch that selects between 2 SATA HDDs (it switches power between two SATA power connectors so that only 1 is active).
It's great for testing alternative operating systems or having a quick-boot surfing system on one hdd and a work related system on the other for example.

The build process is pretty much outlined on the site. Here's how mine looks using a big old 2 deck rotary switch


I had to saw quite a bit off the shaft and spraypaint the knob for it look passable. This is how it looked beforehand: