Wednesday, 9 November 2011

I2C links Arduino and Beagleboard

I want to revise the design of my I2C-based LCD board. The old design works, but it's not reliable and it puts a lot of traffic on the I2C bus. I'd prefer something that created less traffic and placed fewer demands on the host.

I2C is a great protocol for connecting sensors to micro-computers, but you can also use it to link two  computers together.

The solution that I'm looking at will use an Atmel 8-bit AVR  processor to drive the LCD and act as an IC2 slave. That way the host computer needs to send just two bytes down the wire to write a character. The current design sends three or four times that many.

I'm going to develop the solution in small steps:
  1. Get the BeagleBoard talking to an Arduino over I2C with BB as master and Arduino as slave.
  2. Connect the Arduino to the LCD.
  3. Add LCD driver code to the Arduino sketch, and control it using I2C
  4. Put an ATMega8 in a DT104 board from Dontronics. I have several of each spare.
  5. Program an arduino bootloader into the ATMega8.
  6. Upload the I2C-LCD sketch to the ATMega8.
  7. Build a simple stripboard base for the LCD and the motherboard and connect them up.
VoilĂ !

Step one is done.

There's a handy I2C slave sketch among the Arduino examples, abd a good tutorial showing how to connect two Arduinos on the main website. I've programmed the Arduino slave to sit on I2C address 4.

It's safe to connect the Arduin and the BB because tincantools' Trainer-xM board shifts the Beagle's 1.8v I2C signals to the 5v required by the Arduino and vice versa.

I found a useful blog post about using the Beagleboard I2c tools to drive another kind of device; it's easy to adapt the given command to talk to the Arduino.  When I type

i2cwrite 2 4 67
on the  Beagleboard, it sends a byte value of 67 on bus 2 to the device with I2C address 4 and the character 'C' (ascii decimal 67) is received by the Arduino.

Connecting the Arduino and the LCD

I expect that Step 2 will be the most time-consuming; patching together an Arduino an LDC is fiddly, but I've done it before and there are very clear instructions from Oomlout for the LCD that they supply.

Once that's done the rest should be fairly straightforward.

No comments:

Post a Comment