Computing stuff tied to the physical world

Archive for November 2008

iDwarf

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:

FF9594F6-CC35-447F-B154-1DA8EA2E60D2.jpg

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:

5155AE0B-173E-4E88-BB6C-A065628E2F7F.jpg

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:

22545025-0C64-4DBE-9519-A1CC31BB8891.jpg

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

F5812B9B-C1D7-41EF-AD8F-E66AC4BE54A1.jpg

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:

AA303983-E727-4ADA-BC8F-FB6F93F40E20.jpg

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.

[youtube=http://www.youtube.com/watch?v=V6v_k74JX1s&hl=en&fs=1]

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:

7FCA442F-4941-4FE3-83D7-165DDDF08616.jpg

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:

B90EEE26-03CD-4A1C-B5BB-6941278B450C.jpg

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.

ZIF-ICSP

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:

1A90CF83-C68E-4668-9253-2807033D872B.jpg

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:

E7BB993A-F73F-4F65-BF0A-F433463AA494.jpg

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

E3660697-2BFA-4E23-B5A7-50762746D780.jpg

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

9610D76F-4ED5-4409-BDB9-B5C8E417C10B.jpg

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.

Raven

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:

F2777F55-E2C1-4AFE-AF6A-20CF6DD1A424.jpg

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:

A3B2E20D-0457-4B1E-B1D4-FFB39FF4ECF1.jpg

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.

USBtinyISP

In AVR on Nov 14, 2008 at 00:51

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

D1FE8EDE-CE2E-4C59-9DB1-F01E30160FE7.jpg

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:

F074CFE8-38C4-4C26-8E77-102853E17928.jpg

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…

[youtube=http://www.youtube.com/watch?v=dOMfdH76oi0&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1]

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):

1210A577-DF1B-4397-A0C1-AD1F36E86F86.jpg

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.

Nunchuk

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:

EC19CAFA-DD22-4B24-8A54-DD7B726365D1.jpg

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):

DE0B0236-5C25-4581-86F3-7C78A4DC152E.jpg

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:

82E0DC14-A626-4ECD-BC8E-D577F4089A66.jpg

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

Butterfly

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:

B8B516FA-7F69-4405-94A7-11585FCEB0AC.jpg

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

Asuro

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:

03BE6F57-ECD4-46E9-A9A5-72F116770B40.jpg

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:

IMG_2617.jpg

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.

7BAF910A-D457-4B2E-B5AC-4C05E1587D3C.jpg

Trivial to build and works as advertised.