SlideShare une entreprise Scribd logo
1  sur  13
CUSTARD PI 2
General Purpose I/O for the Raspberry Pi
2nd June 2013
SF Innovations
FEATURES
www.sf-innovations.co.uk
DIGITAL OUTPUTS
www.sf-innovations.co.uk
4 digital outputs
Open collector – can sink 500 mA when low
Output can be taken up to 50V
SAMPLE PYTHON CODE TO TEST DIGITAL
OUTPUTS
www.sf-innovations.co.uk
#1/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
for x in range (0,20):
GPIO.output(11, True)
GPIO.output(12, True)
GPIO.output(13, True)
GPIO.output(15, True)
time.sleep(0.2)
GPIO.output(11, False)
GPIO.output(12, False)
GPIO.output(13, False)
GPIO.output(15, False)
time.sleep(0.2)
GPIO.cleanup()
import sys
sys.exit()
This program sets pins 11, 12, 13 & 15 as outputs.
Sets them all high
Waits 0.2 seconds
Sets them all low
Waits 0.2 seconds
Repeats 20 times
Connect an led to 3.3V, 5V or any voltage up to 50V
Connect a resistor in series (say 1 kohm) to
limit the current
Connect the other side of the resistor to
Pins 11, 12, 13 or 15 to see it flash.
Note: When GPIO pin is taken high, the output
on the Custard Pi goes low (i.e. it is inverted).
Download code
DIGITAL INPUTS
www.sf-innovations.co.uk
4 digital inputs
Pull down externally for low
Accept any voltage up to 20V for high
Use pull up on Raspberry Pi to detect high
www.sf-innovations.co.uk
SAMPLE PYTHON CODE TO TEST DIGITAL
INPUTS
#1/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
for x in range (0,10):
bit1=GPIO.input(7)
bit2=GPIO.input(22)
bit3=GPIO.input(18)
bit4=GPIO.input(16)
print bit1, bit2, bit3, bit4
time.sleep(1)
GPIO.cleanup()
import sys
sys.exit()
This program sets up pins 7,22,18 & 16
As inputs with a pull up resistor
Scans all 4 inputs
Prints results to screen
Waits 1 second
Repeats 10 times
For high, do not connect anything to pin
(pull up on Raspberry Pi will keep I/P high)
Revision 1 (no Custard Pi 2 legend on PCB
and 4 diodes on the back of the PCB)
For low link pin to 0 V (ie non-inverting inputs)
Revision 2 (Custard Pi 2 legend on PCB and
no diodes on the back of the PCB)
For low link pin to 3.3V (ie inverting inputs)
Download code
ANALOGUE OUTPUTS
www.sf-innovations.co.uk
2 (12 bit) analogue output channels using 2 channel D to A IC
Full scale voltage (when all 12 bits are High) is 2.048V
www.sf-innovations.co.uk
#1/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(26, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(19, GPIO.OUT)
GPIO.output(26, True)
GPIO.output(23, False)
GPIO.output(19, True)
count = 0
word1= [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
word2= [1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
while count<5:
GPIO.output(26, False)
for x in range (0,16):
GPIO.output(19, word1[x])
print word1[x]
time.sleep(0.01)
GPIO.output(23, True)
time.sleep(0.01)
GPIO.output(23, False)
Program sets pins 26, 23 and 19 as outputs
26 - chip enable
23 – clock
19 – data out
Word1
1st bit High – writing to Channel B
2nd bit Low – either state is OK
3rd bit High – when all bits high, V = 2.048V
4th bit High – output available
Last 12 bits all High = 4096 = 2.048V
Word2
Last 12 bits =011111111111= 2048 = 1.024 V
Chip enable (pin 26) Low
Clock out word1 bit by bit on pin 19
Data valid when clock (pin 23) goes from L to H
Set 1st bit low to output to Channel A
SAMPLE PYTHON CODE TO TEST ANALOGUE
OUTPUTS
www.sf-innovations.co.uk
GPIO.output(26, True)
time.sleep(5)
GPIO.output(26, False)
for x in range (0,16):
GPIO.output(19, word2[x])
print word2[x]
time.sleep(0.01)
GPIO.output(23, True)
time.sleep(0.01)
GPIO.output(23, False)
GPIO.output(26, True)
print count
count = count + 1
time.sleep(5)
GPIO.cleanup()
import sys
sys.exit()
Chip enable High
This makes analogue voltage available (word 1)
Wait 5 seconds
Chip enable Low
Clock out word2 bit by bit on pin 19
Data valid when clock (pin 23) goes from L to H
Chip enable High
This makes analogue voltage available (word 2)
Wait 5 seconds
Repeat 5 times (using variable count)
Use multi-meter on channel B to see voltage
cycle from 2V to 1V five times.
SAMPLE PYTHON CODE TO TEST ANALOGUE
OUTPUTS
Download code
ANALOGUE INPUTS
www.sf-innovations.co.uk
2 (12 bit) analogue input channels using 2 channel A to D IC
Maximum input 3.3V will set all 12 bits High
www.sf-innovations.co.uk
SAMPLE PYTHON CODE TO TEST ANALOGUE
INPUTS
#1/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(19, GPIO.OUT)
GPIO.setup(21, GPIO.IN)
GPIO.output(24, True)
GPIO.output(23, False)
GPIO.output(19, True)
word1= [1, 1, 1, 1, 1]
GPIO.output(24, False)
anip=0
for x in range (0,5):
GPIO.output(19, word1[x])
time.sleep(0.01)
GPIO.output(23, True)
time.sleep(0.01)
GPIO.output(23, False)
Program sets pins 24, 23 and 19 as outputs
Pin 21 as input
24 - chip enable
23 – clock
19 – data out
21 – data in
Word1
1st bit High – start bit
2nd bit High – two separate channels
3rd bit High – input on Channel 1
4th bit High – Most significant bit first
5th bit High – Clock in null bit
Chip enable (pin 24) Low
Clock out word1 bit by bit on pin 19
Data valid when clock (pin 23) goes from L to H
Set 3rd bit Low to input on Channel 0
www.sf-innovations.co.uk
for x in range (0,12):
GPIO.output(23,True)
time.sleep(0.01)
bit=GPIO.input(21)
time.sleep(0.01)
GPIO.output(23,False)
value=bit*2**(12-x-1)
anip=anip+value
print x, bit, value, anip
GPIO.output(24, True)
volt = anip*3.3/4096
print volt
GPIO.cleanup()
import sys
sys.exit()
Clock in 12 bits on pin 21
Data valid when clock (pin 23) goes from L to H
Work out decimal value based on position & value of bit
X = position of bit
Bit = 0 or 1
Value = value of that bit
anip = running total
Print x, bit, value, anip
Chip enable high
Work out and print voltage
Connect Channel 0 to 3.3V and voltage should be 3.3V
Connect two equal resistors in series from 3.3V to 0V.
Connect mid point of resistors to Channel 0 input
Voltage should be 1.65V
SAMPLE PYTHON CODE TO TEST ANALOGUE
INPUTS
Download code
FURTHER INFORMATION
www.sf-innovations.co.uk
Blog dedicated to electronics & Raspberry Pi
Custard Pi 2 available from Amazon.co.uk and E-
bay
Up-to-date info on stockists on website

Contenu connexe

Dernier

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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...
 

Custard Pi 2 - Analogue and digital I/O for the Raspberry Pi

  • 1. CUSTARD PI 2 General Purpose I/O for the Raspberry Pi 2nd June 2013 SF Innovations
  • 3. DIGITAL OUTPUTS www.sf-innovations.co.uk 4 digital outputs Open collector – can sink 500 mA when low Output can be taken up to 50V
  • 4. SAMPLE PYTHON CODE TO TEST DIGITAL OUTPUTS www.sf-innovations.co.uk #1/usr/bin/env python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT) GPIO.setup(12, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(15, GPIO.OUT) for x in range (0,20): GPIO.output(11, True) GPIO.output(12, True) GPIO.output(13, True) GPIO.output(15, True) time.sleep(0.2) GPIO.output(11, False) GPIO.output(12, False) GPIO.output(13, False) GPIO.output(15, False) time.sleep(0.2) GPIO.cleanup() import sys sys.exit() This program sets pins 11, 12, 13 & 15 as outputs. Sets them all high Waits 0.2 seconds Sets them all low Waits 0.2 seconds Repeats 20 times Connect an led to 3.3V, 5V or any voltage up to 50V Connect a resistor in series (say 1 kohm) to limit the current Connect the other side of the resistor to Pins 11, 12, 13 or 15 to see it flash. Note: When GPIO pin is taken high, the output on the Custard Pi goes low (i.e. it is inverted). Download code
  • 5. DIGITAL INPUTS www.sf-innovations.co.uk 4 digital inputs Pull down externally for low Accept any voltage up to 20V for high Use pull up on Raspberry Pi to detect high
  • 6. www.sf-innovations.co.uk SAMPLE PYTHON CODE TO TEST DIGITAL INPUTS #1/usr/bin/env python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP) for x in range (0,10): bit1=GPIO.input(7) bit2=GPIO.input(22) bit3=GPIO.input(18) bit4=GPIO.input(16) print bit1, bit2, bit3, bit4 time.sleep(1) GPIO.cleanup() import sys sys.exit() This program sets up pins 7,22,18 & 16 As inputs with a pull up resistor Scans all 4 inputs Prints results to screen Waits 1 second Repeats 10 times For high, do not connect anything to pin (pull up on Raspberry Pi will keep I/P high) Revision 1 (no Custard Pi 2 legend on PCB and 4 diodes on the back of the PCB) For low link pin to 0 V (ie non-inverting inputs) Revision 2 (Custard Pi 2 legend on PCB and no diodes on the back of the PCB) For low link pin to 3.3V (ie inverting inputs) Download code
  • 7. ANALOGUE OUTPUTS www.sf-innovations.co.uk 2 (12 bit) analogue output channels using 2 channel D to A IC Full scale voltage (when all 12 bits are High) is 2.048V
  • 8. www.sf-innovations.co.uk #1/usr/bin/env python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(26, GPIO.OUT) GPIO.setup(23, GPIO.OUT) GPIO.setup(19, GPIO.OUT) GPIO.output(26, True) GPIO.output(23, False) GPIO.output(19, True) count = 0 word1= [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] word2= [1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] while count<5: GPIO.output(26, False) for x in range (0,16): GPIO.output(19, word1[x]) print word1[x] time.sleep(0.01) GPIO.output(23, True) time.sleep(0.01) GPIO.output(23, False) Program sets pins 26, 23 and 19 as outputs 26 - chip enable 23 – clock 19 – data out Word1 1st bit High – writing to Channel B 2nd bit Low – either state is OK 3rd bit High – when all bits high, V = 2.048V 4th bit High – output available Last 12 bits all High = 4096 = 2.048V Word2 Last 12 bits =011111111111= 2048 = 1.024 V Chip enable (pin 26) Low Clock out word1 bit by bit on pin 19 Data valid when clock (pin 23) goes from L to H Set 1st bit low to output to Channel A SAMPLE PYTHON CODE TO TEST ANALOGUE OUTPUTS
  • 9. www.sf-innovations.co.uk GPIO.output(26, True) time.sleep(5) GPIO.output(26, False) for x in range (0,16): GPIO.output(19, word2[x]) print word2[x] time.sleep(0.01) GPIO.output(23, True) time.sleep(0.01) GPIO.output(23, False) GPIO.output(26, True) print count count = count + 1 time.sleep(5) GPIO.cleanup() import sys sys.exit() Chip enable High This makes analogue voltage available (word 1) Wait 5 seconds Chip enable Low Clock out word2 bit by bit on pin 19 Data valid when clock (pin 23) goes from L to H Chip enable High This makes analogue voltage available (word 2) Wait 5 seconds Repeat 5 times (using variable count) Use multi-meter on channel B to see voltage cycle from 2V to 1V five times. SAMPLE PYTHON CODE TO TEST ANALOGUE OUTPUTS Download code
  • 10. ANALOGUE INPUTS www.sf-innovations.co.uk 2 (12 bit) analogue input channels using 2 channel A to D IC Maximum input 3.3V will set all 12 bits High
  • 11. www.sf-innovations.co.uk SAMPLE PYTHON CODE TO TEST ANALOGUE INPUTS #1/usr/bin/env python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(24, GPIO.OUT) GPIO.setup(23, GPIO.OUT) GPIO.setup(19, GPIO.OUT) GPIO.setup(21, GPIO.IN) GPIO.output(24, True) GPIO.output(23, False) GPIO.output(19, True) word1= [1, 1, 1, 1, 1] GPIO.output(24, False) anip=0 for x in range (0,5): GPIO.output(19, word1[x]) time.sleep(0.01) GPIO.output(23, True) time.sleep(0.01) GPIO.output(23, False) Program sets pins 24, 23 and 19 as outputs Pin 21 as input 24 - chip enable 23 – clock 19 – data out 21 – data in Word1 1st bit High – start bit 2nd bit High – two separate channels 3rd bit High – input on Channel 1 4th bit High – Most significant bit first 5th bit High – Clock in null bit Chip enable (pin 24) Low Clock out word1 bit by bit on pin 19 Data valid when clock (pin 23) goes from L to H Set 3rd bit Low to input on Channel 0
  • 12. www.sf-innovations.co.uk for x in range (0,12): GPIO.output(23,True) time.sleep(0.01) bit=GPIO.input(21) time.sleep(0.01) GPIO.output(23,False) value=bit*2**(12-x-1) anip=anip+value print x, bit, value, anip GPIO.output(24, True) volt = anip*3.3/4096 print volt GPIO.cleanup() import sys sys.exit() Clock in 12 bits on pin 21 Data valid when clock (pin 23) goes from L to H Work out decimal value based on position & value of bit X = position of bit Bit = 0 or 1 Value = value of that bit anip = running total Print x, bit, value, anip Chip enable high Work out and print voltage Connect Channel 0 to 3.3V and voltage should be 3.3V Connect two equal resistors in series from 3.3V to 0V. Connect mid point of resistors to Channel 0 input Voltage should be 1.65V SAMPLE PYTHON CODE TO TEST ANALOGUE INPUTS Download code
  • 13. FURTHER INFORMATION www.sf-innovations.co.uk Blog dedicated to electronics & Raspberry Pi Custard Pi 2 available from Amazon.co.uk and E- bay Up-to-date info on stockists on website