Carambola i2c IO board – PCB

Late last week the parts arrived from my Carambola i2c IO board and I was busy over the weekend making and assembling the PCB.  Here are the results!

I used KiCad to create the artwork and my ink-jet printer to print it out onto OHP film.  Got better results with my ink-jet than my laser printer, the ink is a lot darker than toner.  As this is a double sided PCB I spent a good while getting the alignment correct, which was tricky!

For a UV source, I got an external 24W CLF bulkhead light which at a five minute exposure time worked the business. The back of the PCB worked out fine apart from the dodgy cheep FR4 board I got from Radionics.  The photo resist film on the copper was really crappy as you can see in the photo below (look in the centre of the PCB, the artwork was black but you can see the Cu has been etched in patches).

Carambola i2c IO Board PCB back side

Carambola i2c IO Board PCB back side

The top side was a little better apart from the PCB area at the top right of the board where there was a big blotch of resist.. Also the alignment of the top and bottom artwork was a little out on the right despite my best efforts.

Carambola i2c IO Board PCB front side

Carambola i2c IO Board PCB front side

Here is a close up of the track detail where they are at their closest, nice crisp tracks.

Carambola i2c IO Board PCB track detail

Carambola i2c IO Board PCB track detail

The switcher PSU with the 3.3V regulator:

Carambola i2c IO Board PSU

Carambola i2c IO Board PSU

And finally the assembled PCB..

Carambola i2c IO Board working

Carambola i2c IO Board working

The good news: it works!

Well I haven’t tried the Ethernet UTP connection yet, but the WiFi, PSU, input stage and relays work fine.

Carambola IO board with 8 relays and 8 inputs

Time to interface this great Carambola board I have. The I2C board I made up in the last post worked really nicely with the Carambola development board, so this seemed the natural progression.. Piggyback the Carambola on the 8 channel IO board, give it some power, an Ethernet jack, and this should be a nice little board for control / monitoring.  The board can work either wired or wireless, and by using a LM2575 Buck switching regulator, the board can run from 5V to 40V.

Here is first sheet of the schematic:

Schematic for Carambola IO Board with relays (1 of 2)

Schematic for Carambola IO Board with relays (1 of 2)

The second:

Schematic for Carambola IO Board with relays (2 of 2)

Schematic for Carambola IO Board with relays (2 of 2)

All done in KiCad. Below is the PCB layout.  Might have got it onto a single sided PCB with a few links, but pushed the boat and went double sided for this one! The components are all through hole so this should be easy to make when the parts arrive. I’ve designed in a header on the right hand side that would allow a 1-wire DS18B20 to be connected along with breaking out the i2c, SPI and UART. The PCB layout fits neatly on a Eurocard PCB (100 x 160mm).

Two layered PCB for Carambola IO Board with relays

Two layered PCB for Carambola IO Board with relays

All the info you need should be here: Carambola IO Board.tar (KiCad project files, BOM for Farnell parts, etc)

i2c 8 channel IO board with relays

With all these MCU’s needing to connect to real world stuff.. electric valves, heaters, motors and the like. I need a versatile IO board that I can hook up to an Arduino, Raspberry PI, Beaglebone or Carambola.  All of which have an i2c bus. So armed with a MCP23017, I’ve come up with this IO board.

  • 8 Relay outputs ( relays are spec’ed at 240V 5A )
  • 8 Digital inputs ( switched input, closing to ground )
  • Selectable i2c address ( up to 8 of these on the one i2c bus )
  • All running from +5V ( relays can be powered from an alternative power supply if 5V coils are not to hand )
  • Single layer, through hole construction ( old skool! )
i2c Relay Board - schematic

i2c Relay Board – schematic

I’m loving KiCAD… Over the last few schematic captures I now have a handle on libraries, this time I got my head around modules as I couldn’t find the pads for the relays I wanted to use.  Even better, I managed to layout the board on a single sided PCB! Here it is:

i2c Relay Board - PCB

i2c Relay Board – PCB.

All the files are here: i2cRelayBoard

Now I’ve got to get all the clobber to make my own PCB’s… It’s been a while since I’ve had to do that…!

BeagleBone and GPIO pin mux’ing

On my last BeagleBone post I have a relay driven through a transistor, the base of which is connected through a 1k0 resister to the pin 24 on the P8 pin header.  So how do we drive this pin?

The AM335x ARM Cortex™-A8 Processor can do a load more than the BGA package has connectors for, so to get around this “hardware limitation”, the pins can be set up for different functions.. enter pin muxing.

First we need to make sure the pin we want to use is in the correct mode! For this you’ll need to manual for your BeagleBone (its the SRM or System Reference Manual your looking for.. for latest rev, you’ll find it here). On the A6 rev manual head to page 48 and on.

The names for the pins (signal names) are shown beside the pin outs for the header connectors P8 (table 8, page 48) and P9 (table 11, page 53). If you login to your BeagleBone (as root, sudo, su -l or what ever you need to do!), you will see all these signal names (for mode 0) in the folder /sys/kernel/debug/omap_mux.

For my relay pin I need to set this to mode 7 (from table 10, page 51) can see the mode 7 signal name is “gpio1[1]“.  To find out the current mode, type:

cat /sys/kernel/debug/omap_mux/gpmc_ad1

That should return three lines:

name: gpmc_ad1.gpio1_1 (0x44e10804/0x804 = 0x0007), b NA, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE7
signals: gpmc_ad1 | mmc1_dat1 | NA | NA | NA | NA | NA | gpio1_1

From this we know that the pin is in the correct mode (7).  If it was not in the correct mode or a change of mode is required then it’s easy:

echo <mode> > /sys/kernel/debug/omap_mux/gpmc_ad1

There is a little more that can be done with the mode number, internal pull up resistors can be enabled or disabled.  The mode is made up from the following byte:

Bit 0 \
Bit 1 |- Mode
Bit 2 /
Bit 3: 1 - Pull disabled, 0 - Pull enabled
Bit 4: 1 - Pull up, 0 - Pull down
Bit 5: 1 - Input, 0 - Output

There are 66 GPIO pins between the two headers. These are 4 controllers driving these pins GPIO0, GPIO1, GPIO2 and GPIO3. To configure a pin we need to use a simple formula to find out the software GPIO reference for it or the GPIO pin number.

The pins GPIO number is made up of two parts: 1) The chips base number, 2) the pin number itself.  It’s all in the pin label: GPIO<base>_<pin_no>.

GPIO pin number = <base> x 32 + <pin_no>

For the physical pin GPIO1_1 [P8, pin 24] the GPIO pin number is found via this formula:

GPIO pin number = 1 x 32 + 1 = 33

Now we need get this pin ready to do something..  All IO ports on the BeagleBone are mapped to the file system (such in the Unix model for IO).  The file system location for this action is here: /sys/class/gpio. Getting a GPIO pin ready is done by “exporting” it.

echo 33 > /sys/class/gpio/export

This will cause a new folder to exist in the gpio directory…

gpio33 -> ../../devices/virtual/gpio/gpio33

We can go in and have a look inside this folder:

-rw-r--r-- 1 root root 4096 Nov  7 15:43 active_low
-rw-r--r-- 1 root root 4096 Nov  7 15:43 direction
-rw-r--r-- 1 root root 4096 Nov  7 15:43 edge
drwxr-xr-x 2 root root    0 Nov  7 15:43 power
lrwxrwxrwx 1 root root    0 Nov  7 15:42 subsystem -> ../../../../class/gpio
-rw-r--r-- 1 root root 4096 Nov  7 15:42 uevent
-rw-r--r-- 1 root root 4096 Nov  7 15:51 value

Set up the direction of the pin:

echo out > direction

Want to turn the port on/high…? easy:

echo 1 > value

Off again…

echo 0 > value

See what state it’s in?

cat value

Cool… I can hear my relay clicking on and off in the lab!

Some more info on this can be found here:

1) elinux.org/EBC_Exercise_10_Flashing_an_LED
2) beaglebone.cameon.net/home/pin-muxing
3) akademii.blogspot.ie/2012/02/beaglebone-gpio-testing.html