Custard Pi 6 - 8 Relay card with ribbon connector
The Downloads tab has sample Python code to demonstrate the use of the Custard Pi 6.
The Custard Pi 6 provides the following benefits for the hobbyist intending to use the GPIO.
1. The board simply plugs into the 26 way GPIO connector Using the supplied ribbon connector. The LED fitted to the 3.3V rail confirms correct plug in.
2. Uses the two I2C pins on the GPIO connector to control 8 relays.
3. There are 8 screw terminals provided to access the three pins of each relay: C (common), NC (Normally Closed) and NO (Normally Open).
4. The necessary functions to control the relays are provided by SF Innovations making it very easy for the programmer.
6. Switch S1 on each Custard Pi 6 can be used to set it a unique address with a choice of 8. Up to 8 different cards can be controlled each with 8 relays - allowing a total of 64 relays to be controlled using the Custard Pi 6.
7. There are 2 26 way connectors provided on each Custard Pi 6 allowing a maximum of 8 to be daisy chained.
3. INTRODUCTION TO THIS SLIDESHOW
When using this, there is no need to set up the Raspberry Pi I2C
routines.
www.sf-innovations.co.uk
In this set of instructions we show how to control the Custard Pi 6 8relay card using the functions provided in cpi6.py routine. This used
“bit banging” to provide a basic I2C bus serial interface to address
the Custard Pi 6 board and switch relays ON and OFF.
4. ADDITIONAL DETAILS
To Custard Pi 6
Notch to the right
The 12V adaptor to supply the Custard Pi 6 is NOT
supplied. This can easily be purchased on Amazon or EBay.
Spec: 12V DC, 1 Amp
www.sf-innovations.co.uk
To Raspberry Pi
Notch to the right
6. USING THE CUSTARD PI 6
We supply a set of routines to make it very easy to control the Custard Pi
6.
Just download the file “cpi6.txt” and place this in the same directory as
the program that you are developing. Rename it as “cpi6.py”.
Addressing the board
You can use up to 8 different Custard Pi 6 boards to control a total of 64
relays.
Use switch S1 to set the address of the card that you are using.
Download cpi6 resources spi6.txt
www.sf-innovations.co.uk
Then just use the following commands to control each individual relay on
the card.
7. USING SWITCH S1 TO SET THE ADDRESS
S1 pos 2 S1 pos 3 S1 pos 4 Address
ON
ON
add0
OFF
ON
ON
add1
ON
OFF
ON
add2
OFF
OFF
ON
add3
ON
ON
OFF
add4
OFF
ON
OFF
add5
ON
OFF
OFF
add6
OFF
OFF
OFF
add7
Position 1 is not used.
www.sf-innovations.co.uk
ON
8. USING THE CUSTARD PI 6
First, set all the pins to be as outputs by using the following command.
board1=cpi6.add1
cpi6.setasoutput(board1)
cpi6.setbit(board1, cpi6.ONrelay0)
The following command clears relay 0 on board 1 – ie turns it OFF
cpi6.clrbit(board1, cpi6.OFFrelay0)
www.sf-innovations.co.uk
The following command sets relay 0 on board 1 – ie turns it ON
9. PYTHON PROGRAM
This program sets
relays 0,1&7 on
board 1 ON and then
turns them all OFF
again.
This is done
continuously until
the program is
aborted by a CTRL C.
When testing, please
make sure that
switch S1 is set
correctly for add1.
www.sf-innovations.co.uk
#1/usr/bin/env python
import RPi.GPIO as GPIO
import time
import cpi6
GPIO.setmode(GPIO.BOARD)
#start program
board1=cpi6.add1
cpi6.setasoutput(board1)
while True:
cpi6.setbit(board1, cpi6.ONrelay0)
cpi6.setbit(board1, cpi6.ONrelay1)
cpi6.setbit(board1, cpi6.ONrelay7)
cpi6.clrbit(board1, cpi6.OFFrelay0)
cpi6.clrbit(board1, cpi6.OFFrelay1)
cpi6.clrbit(board1, cpi6.OFFrelay7)
GPIO.cleanup()
import sys
sys.exit()
10. Blog dedicated to electronics & Raspberry Pi
Custard Pi 5 available from stockists
Up-to-date info on stockists on website
www.sf-innovations.co.uk
Further information