Computing stuff tied to the physical world

Archive for November 2008


In AVR, Hardware on Nov 30, 2008 at 01:06

The iDwarf system is a wireless 2.4 GHz radio module with an ATmega168 inside. The starter kit comes with two sensor nodes with built-in battery holder and one “hub” which interfaces to (and runs off) USB:


The daughterboards showing on top are the actual modules, the rest is part of the starter kit, i.e. sensor node and hub interface boards.

Several software examples were included, with hex files ready to try. It took me a while to figure out that I had to also set up the fuse bits – as delivered, the 168 is completely empty:


And just changing some ’s to /‘s in the source was all it took to re-compile these examples from source on MacOSX (the actual radio driver code is linked in from a library, no source, though).

Having a fully programmable chip to customize, with over half of its memory free makes this a more flexible option than XBee’s, at about the same price.

First trials indicate that the range of these little modules is a bit limited. They didn’t maintain a connection across three layers of stone & concrete (floors / walls) – a hefty requirement, but all within a single home. Still, it’s impressive what a pair of tiny on-board antennas can accomplish.

Wireless at 433 MHz

In AVR, Hardware on Nov 29, 2008 at 01:03

This was an experiment to learn about low-power / low-range wireless communication using a 433 Mhz transmitter / receiver set from Conrad. The transmitter was tied to an RBBB board and accessed via an FTDI-USB cable:


The receiver was mounted on a proto shield with breadboard, on top of a standard Arduino:


The software for this requires some attention due to the crude communication system.

Basically, the transmitter is turned on and off by a serial bit stream, i.e. this is not FM or even AM, just the presence and absence of a signal. To make this work properly and get say 20 bytes of data across, you have to go through the following sequence:

  • turn on the signal for a few milliseconds so the receiver adjust its AFC (assuming it has one)
  • send a unique bit pattern so the receiver can synchronize to receive data as individual bytes
  • send the data bytes, i.e. the “payload”
  • send a 2-byte CRC so the receiver can verify proper reception
  • turn off the signal for at least a few dozen milliseconds to avoid hogging the radio channel
  • re-send the whole packet one or more times to deal with interference and collisions

Even then, correct reception is not guaranteed – that would require a transceiver setup with two-way acknowledgement.

Data is sent using Manchester code, a phase change trick which keeps the on and off times equal, on average. The signalling rate is only 1000 baud (i.e. 1 millisecond per bit) and even then the error rate is quite substantial.

The CRC is calculated via standard code from the avr-libc library. A little trick is used to simplify the code: when the two CRC bytes are appended in little-endian format, the receiver can calculate its CRC including these bytes and verify that the result is zero.

The C test code is in the download area – for both the transmission and the reception version. It uses busy loops for (rough) timing. An interrupt-driven version using one of the 168’s hardware counters would have been preferable, to generate a jitter-free signal and to be able to handle other tasks during reception.

The results indicate that the transmitter really needs an external antenna wire to cross more than a meter (!) or so of air. With antenna, the signal barely makes it through one (reinforced) concrete wall in the house, which is insufficient for my purposes, but an 868 MHz version will probably overcome this limitation.

Interface Woes

In Uncategorized on Nov 25, 2008 at 00:59

Ouch. It looks like there are two different Arduino Mini Pro’s around – a 5V @ 16 MHz and a 3.3V @ 8 MHz version. I thought I had the latter, but a quick check tells me otherwise. Which is no good when you’re trying to hook up 3.3V modules that do not tolerate 5V levels!

Oh well, just order the right one and wait for it to arrive…

Meanwhile, here’s another kind of impedance mismatch:


The obnoxious 2 mm vs. 2.54 mm pinout. Yuck.

Sequential Clock

In AVR on Nov 24, 2008 at 00:58

Here’s a little clock project with a twist – it displays the current time on a single large 7-segment LED display, by briefly showing each of the digits one after the other.


Note the transition from 12:20 to 12:21. The little red blinking light at the bottom is the actual DCF77 radio signal, one pulse each second, with a long/short duration to encode each bit.

This project uses a Boarduino as brains, a DCF77 radio receiver, a large Kingbright 7-segment display, a 2981 LED driver, a bunch of 470 Ω current limiting resistors (1K for the decimal point), and a 6..12V DC power supply:


On the left are the power plug and 5V regulator, on the right of the Boarduino you can see the reset button, 2×3-pin ICSP header, and 6-pin header used for programming with a USB-FTDI cable. On the far right is the 2981 chip used to drive the LED segments with 8..14V.

The radio print is soldered directly to the Boarduino (digital I/O pins 2..5) in such a way that the reception antenna with L/C circuit fits is snugly between the radio print and the display module. For simplicity, the radio’s +5V and ground are also provided by the Boarduino via digital I/O pins – they are fixed on startup as “1” and “0” outputs, respectively.

I used wire-wrap wire to make the connections because it’s so thin and solders very easily:


One nice software gimmick is that the clock starts by displaying a personalized greeting, since this project was made as birthday gift for a friend. Once the proper DCF77 radio signal has been decoded, the display switches to showing the current time; this usually takes two to three minutes after power-up. The clock will continue to run on its own with ≈ 0.5% accuracy in the absence of valid radio signals.

The C source code can be downloaded here. It decodes the DCF signal and encodes / drives the 7-segment display in a continuous loop.


In AVR on Nov 23, 2008 at 00:56

Several times now, I had to use an Arduino board to program an ATmega chip via the ICSP socket (to change fuse bytes or to set up / change the bootloader). Which works fine, but at some point the IC socket is probably going to wear out.

So I made this ZIF-socketed board, just for ICSP programming use:


The LED and 16 MHz resonator are not strictly needed, but this way the board also lets me run a test program at full speed and report its status via the LED.

XBee Adapters

In Hardware on Nov 21, 2008 at 00:55

Apart from the XBee shield, there are several other options to hook into that module with its non-standard 2-mm connector.

The simplest is a little breakout board which brings things back to “normal” 2.54 mm PCB units:


Next up is AdaFruit’s adapter which connects to an FTDI cable or plugs into a breadboard:


Finally, there is the Xbee Explorer USB which ties it directly to a slave USB port:


The adapter is probably the most convenient to embed and to use stand-alone, since it does all the voltage regulation and conversion in a simple package.


In AVR on Nov 19, 2008 at 00:54

The AVR Raven is an interesting successor to the AVR Butterfly. It has two ATmega processors on board, one drives an advanced transceiver for wireless use. This explains the double set of ICSP/JTAG headers:


Haven’t had much chance to play with it yet, other than to verify that the Ravens and the USB-stick base station work (current software requires a Windows server).

Mini Pro

In AVR on Nov 16, 2008 at 00:53

The Mini Pro Arduino (specs) is another way to embed an ATmega168 processor:


I added the pin headers, though one could also use this as a very flat embedded module by wiring directly to the circuit pads.

This one runs at 8 MHz and uses a 3.3V regulator (which means the I/O pins are also at that level). It’s not a kit, due to the use of SMD components.


In AVR on Nov 14, 2008 at 00:51

The USBtinyISP is a kit for a USB-connected AVR compatible ICSP programmer:


On the left are two cables, with 6-pin and 10-pin ICSP plugs, respectively. Inside is a pre-programmed ATtiny chip plus some level converters for use with 3.3V hosts (do need to remove a jumper for that).

Built into avrdude by using the “-c usbtiny” option. No need to specify port or baudrate (unlike some other programmers). To make this the default programmer, I added this line to my ~/.avrduderc:

        default_programmer = “usbtiny”;

This little device works really well.

Arduino on Lithium

In AVR on Nov 13, 2008 at 00:50

LiquidWare has a Lithium Backpack which goes underneath an Arduino:


It needs two wires to feed the regulated 5V power + ground lines directly into the Arduino (I could have also connected them to the ICSP header). The switch on the battery board which is just visible in the lower left corner let’s you select between using and charging the Li-Ion battery.

Which is good, given that Lithium batteries can be a bit, ehm, finecky to deal with…


Pololu 3π

In AVR on Nov 12, 2008 at 00:47

Pololu produces the robot, with two independently driven wheels plus ball caster, an ATmega 168 for smarts, and on-board power that allows it to autonomously move around. The 3pi comes pre-assembled, and is smaller and much more maneuverable than the Asuro kit I built recently.

There’s an impressive intro on the Pololu site:

The nice thing about the 3π is that it is fully Arduino-compatible and that it comes with two nice programs, for advanced line-following and maze searching, respectively.

So I set up a little track in a drawing program and printed it out, taping the 3 x 4 pages together to create a little track. Unfortunately, I couldn’t get 3π to successfully follow the line; perhaps the printed inkjet ink does not have sufficient contrast for its infrared eyes? The robot only barely follows the line, and goes off track into a spin all the time.

I will need to create a better track with black tape one day, as suggested on the Pololu site.

Still, this was very educational. I found out about proportional–integral–derivative (PID) controllers, and how they help create feedback-based control loops that push mechanical systems to their limits without overshoot or erratic behavior.

Update 2008-11-29 : indeed, with black masking tape 3π works just fine!

XBee shield

In AVR, Hardware on Nov 11, 2008 at 00:46

Here’s an Arduino shield for the XBee wireless 2.4 GHz module (v2, as kit from NKC Electronics):


I haven’t been able to find the hardware schematics or board layout, looks like it’s proprietary…

If you look closely, you’ll see that the board underneath it is a new Arduino Duemilanove, which auto-senses power between the plug and the USB port.


In AVR on Nov 9, 2008 at 00:45

The Wii Nunchuk controller is really just an I2C device, with a triple-axis accelerometer, an X-Y proportional joystick, and two push buttons. Breaking it out of its case allows us to connect it in ways it was never meant for:


It’s very easy to hook up to an Arduino and there’s a good example on the web to read out all the sensors. I’ve tweaked it a bit to use pins 8 and 9 as the I2C/TWI interface.

Connections above are as follows: red = +3.3..5V, white = ground, green = SDA, yellow = SCL.

Boarduino & RBBB

In AVR on Nov 7, 2008 at 00:44

The Boarduino is an Arduino clone intended for use on a breadboard (the picture below is from another project):


There’s a DC version with an FTDI connector for programming (shown above), as well as a USB version (which powers and programs the board). Since there is an ICSP header, I decided to leave out the IC socket from this kit.

The Real Bare Bones Board (RBBB) is an even lower-end version. It’s smaller than the Boarduino and omits the ICSP header:


Due to its low cost as a kit, this would be a great option for permanent embedded use.


In AVR on Nov 6, 2008 at 00:43

The AVR Butterfly is a cheap demo board for the ATmega169V with on board LCD, sensors / switches, and RS232 interface:


I added the RS232 and ICSP headers to be able to boot-load and re-program it, and successfully tried Forth on it.


In AVR on Nov 3, 2008 at 00:42

Asuro is a simple robot, which I ordered as a kit from Conrad. The mechanical construction is entirely based on an epoxy board which also holds the electrical circuit. The brains consist of a C-programmable ATmega8, the older 8 Kb version of the 168 chip used by Arduino’s.

Here’s the result of a few hours of tinkering:


Another cost saving feature is the IR-link, which can be used to re-flash the program. It does require line-of-sight to function, and has a limited range of 1 to 2 meters as far as I can tell:


The above image shows the RS232 serial board that came with the kit. I must have made a mistake while building it – because it didn’t work. Luckily, I had also ordered the ready-made USB version, which works fine.

The test program pre-loaded into the Asuro activates all elements (LEDs, front switches, motors) as a way to test proper operation of each of them. It was most useful to chase down and resolve a few small build problems. There are photo-sensors which can be mounted underneath for line-following, but I chose to add some connectors for a prototype board instead. The reasoning being that these sensors could always be added back via such a prototype board.

So, does it work? I can’t really tell.

I couldn’t find any ready-made programs to make it do anything robot-like such as driving around and dealing with obstacles, or light-seeking/-evading behavior. And it’s clear that any form of intelligent control will require some serious programming and testing. Besides, the motors were very noisy and coarsely controlled, so I doubt it really can do things with any level of grace…

But I had a good time building this thing, and learned quite a bit about what it takes to make a little autonomous robot.

Minty Boost

In Uncategorized on Nov 1, 2008 at 00:39

Intrigued by LadyAda’s description of the Minty Boost kit, I ordered and built one. It delivers a stable 5V supply from 2 AA batteries to a USB plug, so you can use it to charge/power USB devices.


Trivial to build and works as advertised.