SlideShare une entreprise Scribd logo
1  sur  15
CUSTARD PI 6 & I2C
USING THE RASPBERRY PI I2C UTILITIES
8 Relay card with ribbon connector and I2C bus interface
18th Nov 2013

SF Innovations
FUNCTIONS FOR CONTROLLING THE CUSTARD PI 6
RELAY CARD

Original set of Instructions
This PowerPoint presentation shows how to use the built in I2C process
of the Raspberry Pi Linux Operating System to do the same thing.

www.sf-innovations.co.uk

In an earlier instruction we showed 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.
CUSTARD PI 6 - FEATURES

www.sf-innovations.co.uk
CUSTARD PI 6 - 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
GPIO CONNECTIONS

www.sf-innovations.co.uk

Only 4 pins used
3.3V and 0V to power the I2C chip and driver
&
I2C SDA and SCL pins
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 “cpi6x.txt” and place this in the same directory as
the program that you are developing. Rename it as “cpi6x.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 control cpi6x.txt

www.sf-innovations.co.uk

Then just use the following commands to control each individual relay on
the card.
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
SETTING UP THE I2C BUS – STEP 1
At the command prompt type:
sudo nano /etc/modules

Add the following two lines to this file
i2c-bcm2708
i2c-dev
Then save and exit the file using CTRL-x and Y.

www.sf-innovations.co.uk

This uses the nano editor to make some changes to the modules file.
SETTING UP THE I2C BUS – STEP 2
Make sure that you have the I2C utilities installed by executing the
following two commands. The Pi will need to be connected to the Internet
for this.

If you get a 404 error do an update first:
sudo apt-get update
Note : The installation could take a few minutes to do, depend on how
busy the server is.
Now add a new user to the i2c group:
sudo adduser pi i2c

www.sf-innovations.co.uk

sudo apt-get install python-smbus
sudo apt-get install i2c-tools
SETTING UP THE I2C BUS – STEP 3
On the Raspberry Pi, the I2C and the SPI buses are usually disabled.
This is done in the /etc/modprobe.d/raspi-blacklist.conf file.

sudo nano /etc/modprobe.d/raspi-blacklist.conf
If the I2C and the SPI is blacklisted, you will see the following commands.
blacklist spi-bcm2708
blacklist i2c-bcm2708
Insert a # in front of these to comment them out.
Then save and exit the file using CTRL-x and Y.
After editing the file, you will need to reboot for the changes to take
effect.

www.sf-innovations.co.uk

If this file is not present then there is nothing to be done. Otherwise edit
the file by typing the following at the command prompt.
SETTING UP THE I2C BUS – STEP 4
Now we need to test if the I2C bus is working correctly.
Connect up the Custard Pi 6 board (or any other I2C bus device) and run
the following command.

Or
sudo i2cdetect -y 0 (for Rev 1 boards which uses port 0)
If everything is OK, then the I2C address of the device will be shown as
on the following slide.

www.sf-innovations.co.uk

sudo i2cdetect -y 1 (for Rev 2 boards which uses port 1)
SETTING UP THE I2C BUS – STEP 4

www.sf-innovations.co.uk

I2C devices with address 40 and 70 present on the bus.
USING THE CUSTARD PI 6
First, set all the pins to be as outputs by using the following command.
board1=cpi6x.add1
cpi6x.setasoutput(board1)

cpi6x.setbit(board1, cpi6x.ONrelay0)
The following command clears relay 0 on board 1 – ie turns it OFF
cpi6x.clrbit(board1, cpi6x.OFFrelay0)

www.sf-innovations.co.uk

The following command sets relay 0 on board 1 – ie turns it ON
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 cpi6x
GPIO.setmode(GPIO.BOARD)
#start program
board1=cpi6x.add1
cpi6x.setasoutput(board1)
while True:
cpi6x.setbit(board1, cpi6x.ONrelay0)
cpi6x.setbit(board1, cpi6x.ONrelay1)
cpi6x.setbit(board1, cpi6x.ONrelay7)
cpi6x.clrbit(board1, cpi6x.OFFrelay0)
cpi6x.clrbit(board1, cpi6x.OFFrelay1)
cpi6x.clrbit(board1, cpi6x.OFFrelay7)
GPIO.cleanup()
import sys
sys.exit()
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

Contenu connexe

Dernier

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Using the Custard pi 6 with I2C utilities

  • 1. CUSTARD PI 6 & I2C USING THE RASPBERRY PI I2C UTILITIES 8 Relay card with ribbon connector and I2C bus interface 18th Nov 2013 SF Innovations
  • 2. FUNCTIONS FOR CONTROLLING THE CUSTARD PI 6 RELAY CARD Original set of Instructions This PowerPoint presentation shows how to use the built in I2C process of the Raspberry Pi Linux Operating System to do the same thing. www.sf-innovations.co.uk In an earlier instruction we showed 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.
  • 3. CUSTARD PI 6 - FEATURES www.sf-innovations.co.uk
  • 4. CUSTARD PI 6 - 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
  • 5. GPIO CONNECTIONS www.sf-innovations.co.uk Only 4 pins used 3.3V and 0V to power the I2C chip and driver & I2C SDA and SCL pins
  • 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 “cpi6x.txt” and place this in the same directory as the program that you are developing. Rename it as “cpi6x.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 control cpi6x.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. SETTING UP THE I2C BUS – STEP 1 At the command prompt type: sudo nano /etc/modules Add the following two lines to this file i2c-bcm2708 i2c-dev Then save and exit the file using CTRL-x and Y. www.sf-innovations.co.uk This uses the nano editor to make some changes to the modules file.
  • 9. SETTING UP THE I2C BUS – STEP 2 Make sure that you have the I2C utilities installed by executing the following two commands. The Pi will need to be connected to the Internet for this. If you get a 404 error do an update first: sudo apt-get update Note : The installation could take a few minutes to do, depend on how busy the server is. Now add a new user to the i2c group: sudo adduser pi i2c www.sf-innovations.co.uk sudo apt-get install python-smbus sudo apt-get install i2c-tools
  • 10. SETTING UP THE I2C BUS – STEP 3 On the Raspberry Pi, the I2C and the SPI buses are usually disabled. This is done in the /etc/modprobe.d/raspi-blacklist.conf file. sudo nano /etc/modprobe.d/raspi-blacklist.conf If the I2C and the SPI is blacklisted, you will see the following commands. blacklist spi-bcm2708 blacklist i2c-bcm2708 Insert a # in front of these to comment them out. Then save and exit the file using CTRL-x and Y. After editing the file, you will need to reboot for the changes to take effect. www.sf-innovations.co.uk If this file is not present then there is nothing to be done. Otherwise edit the file by typing the following at the command prompt.
  • 11. SETTING UP THE I2C BUS – STEP 4 Now we need to test if the I2C bus is working correctly. Connect up the Custard Pi 6 board (or any other I2C bus device) and run the following command. Or sudo i2cdetect -y 0 (for Rev 1 boards which uses port 0) If everything is OK, then the I2C address of the device will be shown as on the following slide. www.sf-innovations.co.uk sudo i2cdetect -y 1 (for Rev 2 boards which uses port 1)
  • 12. SETTING UP THE I2C BUS – STEP 4 www.sf-innovations.co.uk I2C devices with address 40 and 70 present on the bus.
  • 13. USING THE CUSTARD PI 6 First, set all the pins to be as outputs by using the following command. board1=cpi6x.add1 cpi6x.setasoutput(board1) cpi6x.setbit(board1, cpi6x.ONrelay0) The following command clears relay 0 on board 1 – ie turns it OFF cpi6x.clrbit(board1, cpi6x.OFFrelay0) www.sf-innovations.co.uk The following command sets relay 0 on board 1 – ie turns it ON
  • 14. 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 cpi6x GPIO.setmode(GPIO.BOARD) #start program board1=cpi6x.add1 cpi6x.setasoutput(board1) while True: cpi6x.setbit(board1, cpi6x.ONrelay0) cpi6x.setbit(board1, cpi6x.ONrelay1) cpi6x.setbit(board1, cpi6x.ONrelay7) cpi6x.clrbit(board1, cpi6x.OFFrelay0) cpi6x.clrbit(board1, cpi6x.OFFrelay1) cpi6x.clrbit(board1, cpi6x.OFFrelay7) GPIO.cleanup() import sys sys.exit()
  • 15. 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