Sunday, March 21, 2010

Fonera 1-wire continued... The Display

OWFS supports HD44780 character LCDs on the 1-wire bus. The most common interface is with a DS2408 8-pin GPIO to 1-Wire chip. The interface from hobby-boards runs the display in 4-bit mode, so 3 GPIO lines are left over for buttons and whatnot. I based my design on their schematic.

The SOIC8 is an NE555 in monostable mode. It provides timed backlight control. When a button is pressed the backlight will stay on for about 20 seconds then turn off.

OWFS (theoretically) supports this interface with the LCD_H module.
In ideal-land I'd hook up my hobby-boards clone and type
printf "Hello World">/ow/29.xxxxxxxxxx/LCD_H/message
and that would actually work. Well, as it turns out: Not so much.

It would seem that OWFS 2.7p13-1 has a broken LCD_H module. I've tested with 2.6.5 in an Ubuntu VM where it worked fine. With 2.7p13-1 however, all I got was garbage for the output.
There's a bug report here, that may or may not describe the same issue. If it does then it would seem that the bug has been ignored for several years. Nice!

Problem is I'm not ready to devote days to building a crosscompile environment for mips/OpenWrt because of some random bug. Since byte-based access to the GPIO-port worked it was faster to just re-implement the protocol. Which I did.. in PHP.. (it's just a testing script at this point, so adapt as needed if you wish to use it. Should be easy to figure out.)

Thursday, March 18, 2010

Fonera 1-wire continued.. The Hub

5port dumb 1-Wire hub. Made from a 5-way RJ11 splitter.
I also added a DC connector to allow powering non bus-powered devices from the same RJ connectors.
PIN1 is external Power
PIN2 & 3 are 1-Wire and GND

Wednesday, March 17, 2010

Hot wire glass bottle cutter

In a surge of boredom I did a search for glass bottle cutting. I found this page. That shows a hot-wire bottle cutter. I cloned the design. It's basically a laminate board with a couple of screws and nuts, a spring and some NiChrome wire.

I used an old AT PSU to heat up the wire. The 5v rail is loaded with a 20-something ohm 10W resistor that can't be seen on the photo. (A load on 5V is needed to stabilize the 12V rail)

It works reasonably well.

Precision depends on how straight you can get the wire around the bottle without shorting it. The rim still needs a lot of tedious work to complete a viable drinking glass which I'm definitely too lazy to do. But it was worth the 5 minutes it took to build it.

I might come up with a rim auto-sanding contraption in the future.

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)

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