Sunday, January 13, 2013

The Raspberry Pi needs a home

While out shopping for a book case I saw a classic old tape deck. I have not got any cassettes so it was of no value for playing tapes but the retro appeal had me thinking. Easily large enough for a Raspberry Pi and some relay boards. This is the case mod that I need to house my project.

Pioneer CT-F500 Stereo Cassette Tape Deck.
After pulling the case off I was impressed with the internals. I can re-use the power socket and switch. The transformer is easily removed and provides a small earthed shelf where I can mount my new power supplies from DX.

Next to make some more room in there. I wanted to keep as many wires as possible to make it easier to use the existing plugs, switches & outputs. Needless to say, this puppy won't be playing any more tapes!

After pulling out some boards labelled 'Dolby' I though, 'I wonder how much they are worth?' And then I though, 'I wonder how much a working unit is worth?' A quick google showed that in the right condition and for the right buyer it might be worth a few hundred dollars. Well we will never know if this unit worked (although I assume that it did). It seems to be in extremely good condition (a bit of finger grime and a price tag on the front should clean off easily). When I am finished with it, I think it will be priceless.

First I hooked up the 5v power to make sure that it works. Yes it does!
Raspberry Pi getting to know it's new home.


Next I set about wiring in the 5v and 12v power trying to keep it neat and safe. The two power supplies fit side by side like it was designed that way. Then I wrestled in some 240v wires and presto, working power. I think it needs some tape though to keep things safe.

5v and 12v power installed and working.
Next I think the cassette motor needs to come out to make some more room.

Thursday, January 10, 2013

I2C 16bit IO extender

The PCA9555 is a 16 bit IO chip which interfaces with I2C. Each of the 16 bits can be individually configured as a digital input or digital output.

PCA9555 demo board. GPIO pins are on the top.


I will be using this to control a bank of relays from my Raspberry Pi. If you are not familiar with I2C on the RPI you might want to look at my posts about the PCA8591.

This time I bought the chip mounted to a board from ebay. I had to solder the header pins to the board so I could connect all the inputs & outputs.

jnewbigin@raspberrypi:~$ i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --          

As expected, the chip shows up at address 0x20. The PCA9555 is programmed by a set of registers. The registers are split up into ports or banks which operate on 8 bits at a time. The registers are:

  • 0x00 Select Input values for bank 0
  • 0x01 Select Input values for bank 1
  • 0x02 Select Output values for bank 0
  • 0x03 Select Output values for bank 1
  • 0x04 Select Polarity Inversion for bank 0
  • 0x05 Select Polarity Inversion for bank 1
  • 0x06 Select IO Configuration for bank 0
    (set/1 = input (default), clear/0 = output)
  • 0x07 Select IO Configuration for bank 1
    (set/1 = input (default), clear/0 = output)

To read the first 8 inputs
i2cset -y 1 0x20 0x00
i2cget -y 1 0x20


To read the next 8 inputs
i2cset -y 1 0x20 0x01
i2cget -y 1 0x20

To set the first 8 bits to be outputs
i2cset -y 1 0x20 0x06 0x00
And to turn all the outputs on
i2cset -y 1 0x20 0x02 0xff

My next job is to hook up the relay boards but that requires setting up a more permanent power supply which can run the Raspberry Pi, drive the relays and power the relay devices. Hopefully photos to come soon.