Close

RonaldBoard: ISP programming + I2C communication

A project log for Coffee machine v2

Automatic Slow Coffee Machine | home information device | music player

ronaldRonald 07/14/2016 at 14:000 Comments

At the time when I started this project, there was no single project I could find, that combined ISP and I2C communication. So I decided to do it myself. Since everything needs to be enboxed and I still want to be able to upgrade firmware from SSH, ISP needs to be possible "without hands".

warning - warning - warning - warning - warning - warning - warning - warning - warning - warning

This can kill your Rasbperry Pi, be especially careful with 5V-lines

For the coffee machine this board will handle PWM and ADC, things an ATMega8 is better capable of than a Raspberry Pi.

Since Gert named his expansion board GertBoard, I decided to name mine RonaldBoard (as a fellow Dutchman? At least Gert's name sounds Dutch...).

All that's needed is: a Raspberry Pi, At*, and wires. For the Pi I chose the ATMega8 rather than ATTiny45 because of having some more cheap I/O.

The design is as follows:

Note! While the pin numbering is okay, the GPIO numbering is wrong! Check [1] for correct info

Note that because PB1 is used by the Pi when programming the ATTiny, it probably shouldn't be used to e.g. drive a Servo using PWM.

For Pi <=> Atmega8 communication I chose for I2C, because at the time, I couldn't get (non-bit-banging) SPI working. For the Tiny45 the pins are the same; for my ATmega8 this cost me two additional pins...

Set up

If you want to use this in your own project, be sure you have the following:

programmer
  id    = "gpio2";
  desc  = "Use sysfs interface to bitbang GPIO lines";
  type  = gpio;
  reset = 25;
  sck = 3;
  mosi = 2;
  miso  = 9;
;

Usage

Before the first run after boot, be sure pigpiod is running and you have the i2c module loaded. I made the following script:

sudo ./modprobes

After all is set up, flash the RonaldBoard:
make
sudo make fuse
sudo make flash

The Makefile makes sure the GPIO's for I2C communication are set to read again, using pigs-commands.

Then test it:

./i2ctest

You should see something like this in your terminal window:

i2cdetect:
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- 26 -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
test in getting the value of register 0x42:
0x42
testing ADC read:
0xc0
0xd5
0xb7
testing PWM.

Furthermore, the LED should turn off and then shine brighter and brighter.

Used work

Eagle libs for the ATTiny & Pi (both modified afterwards in Inkscape, but very useful for the basic symbol):

Libraries:

Discussions