SlideShare a Scribd company logo
1 of 14
Serial Communication
BJ Furman
ME 106 Fundamentals of Mechatronics
15NOV2012
Bit serial communication concepts
2/9/2024 2
• Serial  one bit at a time
• Most often using logic level signals
• Timing information needs to be shared
between sender and receiver
– Transitions between bits, duration of a bit
Introduction to Mechatronics, Figure 7.2 p. 107.
 Two major types of bit serial
protocols
 Synchronous (shared clock)
 Ex. SPI, I2C
 Asynchronous (no shared clock)
 Sender and receiver maintain
independent clocks
 Ex. RS-232, USB
http://www.quatech.com/support/figures/async1.gif
BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
Synchronous serial communication
2/9/2024 3
• Characteristics of synchronous serial
– At least one connection for serial data
– A clock connection
– Shared ground
• Common types
– Serial Peripheral Interface (SPI, developed by Freescale)
– Inter-Integrated Circuit bus (I2C, developed by Philips (NXT))
• Arduino support
– I2C and SPI
• See next slide
BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
I2C
2/9/2024 BJ Furman SJSU Mechanical and Aerospace Engineering ME 106 4
• Developed in 1982 by
Philips (now NXP)
– To connect CPU to
peripherals in televisions
• Two signal lines, both are
‘open drain’, thus pull-up
resistors are needed
– SDA (serial data)
– SCL (serial clock)
• Devices are either masters
or slaves
– Master is the device that
always drives SCL and
initiates a transfer
• Each device has an address
• Data is sent in 8 bit bytes
http://www.byteparadigm.com/kb/article/AA-00255/22/Introduction-to-SPI-and-IC-protocols.html
Use 1.2k - 2.2k pull up resistors for Vcc = 3.3 V
or 1.8 - 3.3k resistors for Vcc = 5 V
Analog pins 4 (SCL) and 5 (SDA) must be pulled
up, and a common ground is needed
Margolis, M. (2012). Arduino Cookbook, O’Reilly Media, Inc., Sebastopol, CA, p. 422.
You may need to shift the voltage level from 5 V
(Arduino) to 3.3 V for some sensors
Margolis, M. (2012). Arduino Cookbook, O’Reilly Media, Inc., Sebastopol, CA, p. 423.
I2C protocol
2/9/2024 7
• Master initiates transfer with a START bit (SDA from high to low while SCL is high
• Slave address (7 or 10 bits, 7 is most common)
• Transfer type (1 bit: 0 to write, 1 to read)
– All ICs compare address to their address
• If address matches, device sends an ACKNOWLEDGE signal
• If address does not match, device waits until bus is released by
STOP condition
• Once master receives ACKNOWLEDGE,
it then sends (writes) or receives (reads) data
– Receiver sends back ACKNOWLEDGE for each byte
received
• Master concludes the transfer with STOP bit
General structure of a 2-byte transfer
Writing 2-bytes (shaded bits are put on the bus by the master)
Reading 2-bytes (shaded bits are put on the bus by the master)
http://www.byteparadigm.com/kb/article/AA-00255/22/Introduction-to-SPI-and-IC-protocols.html
http://www.robot-
electronics.co.uk/acatalog/I2C_
Tutorial.html
BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
Many digital components use I2C
• See the list from:
http://forums.parallax.com/showthread.php?99
160-List-of-I2C-devices
The Arduino can be ‘expanded’ using an
I2C port expander device (pcf8574)
http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574
The Arduino can be ‘expanded’ using an
I2C port expander device (pcf8574)
http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574
I2C device – SRF10 Ultrasonic Range Finder
2/9/2024 11
• Devantech SRF10
– 3 cm – 6 m range
– 20 Hz max rep rate
– Range results in in., cm., or ms
(time of flight)
– Always a slave (default address is 0xE0)
– Four registers: http://www.robot-electronics.co.uk/htm/srf10tech.htm
 Three commands:
BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
2/9/2024
BJ Furman SJSU Mechanical and Aerospace
Engineering ME 285
12
• At least one ‘master’ and ‘slave’
needed
• Master controls:
– Unidirectional data line, MOSI
• Master Out, Slave In (data from
the master to the slave)
– Shared clock line, SCK
(synchronizes the data transfer)
– Slave select line(s), SS*
• Which slave to be addressed
• Slave controls:
– Unidirectional data line, MISO
• Master In, Slave Out (data from
slave to the master)
• Shared by slaves
• Non-selected slaves, “tri-state”
their MISO outputs
• SPI is a ‘data exchange’ protocol
– As a bit is clocked out of the
master and received by the slave,
the slave clocks out a bit that is
received by the master
Introduction to Mechatronics, Figure 7.4 p. 109.
Introduction to Mechatronics, Figure 7.5 p. 110.
SPI interface and protocol
SPI data transfer modes
2/9/2024
BJ Furman SJSU Mechanical and Aerospace
Engineering ME 285
13
• Four transfer modes
– Mode 0: SCK idle low, rising edge
– Mode 1: SCK idle low, falling edge
– Mode 2: SCK idle high, falling edge
– Mode 3: SCK idle high, rising edge
• Used most often
Mode 0 Mode 1
Mode 2 Mode 3
Introduction to Mechatronics, Figure 7.6 p. 111.
Many digital components use SPI
• See the (partial) list of SPI devices:
http://www.mct.net/faq/spi.html

More Related Content

Similar to lecture_I2C_SPI.pptx

UNI T 6- SPI_I2C_Lecture8.pptx
UNI                    T 6- SPI_I2C_Lecture8.pptxUNI                    T 6- SPI_I2C_Lecture8.pptx
UNI T 6- SPI_I2C_Lecture8.pptxnaveen088888
 
ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15Aritra Sarkar
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems VijayKumar5738
 
Embedded networking
Embedded networkingEmbedded networking
Embedded networkingArul Kumar
 
SPI AND I2C.pptx
SPI AND I2C.pptxSPI AND I2C.pptx
SPI AND I2C.pptxlakshmiact
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral InterfaceChirag Parikh
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Dhaval Kaneria
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolAnkur Soni
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacingRAMPRAKASHT1
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsMohamed Abdallah
 
I2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsI2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsMostafa Khamis
 
Input output organisation
Input output organisationInput output organisation
Input output organisationSanjeev Patel
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23Techvilla
 

Similar to lecture_I2C_SPI.pptx (20)

UNI T 6- SPI_I2C_Lecture8.pptx
UNI                    T 6- SPI_I2C_Lecture8.pptxUNI                    T 6- SPI_I2C_Lecture8.pptx
UNI T 6- SPI_I2C_Lecture8.pptx
 
serial.ppt
serial.pptserial.ppt
serial.ppt
 
serial.ppt
serial.pptserial.ppt
serial.ppt
 
ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15ASTROSAT SSR - 2015-05-15
ASTROSAT SSR - 2015-05-15
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems
 
Embedded networking
Embedded networkingEmbedded networking
Embedded networking
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
SPI AND I2C.pptx
SPI AND I2C.pptxSPI AND I2C.pptx
SPI AND I2C.pptx
 
I2C PRESENTATION.PPT
I2C PRESENTATION.PPTI2C PRESENTATION.PPT
I2C PRESENTATION.PPT
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
SPI.pptx
SPI.pptxSPI.pptx
SPI.pptx
 
I2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsI2C-Bus Design and Verification Specs
I2C-Bus Design and Verification Specs
 
11_interface.ppt
11_interface.ppt11_interface.ppt
11_interface.ppt
 
Input output organisation
Input output organisationInput output organisation
Input output organisation
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
 

Recently uploaded

Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Call Girls in Nagpur High Profile
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...ranjana rawat
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdftbatkhuu1
 
Fashion trends before and after covid.pptx
Fashion trends before and after covid.pptxFashion trends before and after covid.pptx
Fashion trends before and after covid.pptxVanshNarang19
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsCharles Obaleagbon
 
Stark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxStark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxjeswinjees
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfParomita Roy
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Servicearoranaina404
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...home
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceanilsa9823
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...BarusRa
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Government polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdGovernment polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdshivubhavv
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfAmirYakdi
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticTiaFebriani
 

Recently uploaded (20)

Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
(AISHA) Ambegaon Khurd Call Girls Just Call 7001035870 [ Cash on Delivery ] P...
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
Fashion trends before and after covid.pptx
Fashion trends before and after covid.pptxFashion trends before and after covid.pptx
Fashion trends before and after covid.pptx
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past Questions
 
Stark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptxStark Industries Marketing Plan (1).pptx
Stark Industries Marketing Plan (1).pptx
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
 
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts ServiceVVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
VVIP CALL GIRLS Lucknow 💓 Lucknow < Renuka Sharma > 7877925207 Escorts Service
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Paharganj 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
 
꧁❤ Hauz Khas Call Girls Service Hauz Khas Delhi ❤꧂ 9999965857 ☎️ Hard And Sex...
꧁❤ Hauz Khas Call Girls Service Hauz Khas Delhi ❤꧂ 9999965857 ☎️ Hard And Sex...꧁❤ Hauz Khas Call Girls Service Hauz Khas Delhi ❤꧂ 9999965857 ☎️ Hard And Sex...
꧁❤ Hauz Khas Call Girls Service Hauz Khas Delhi ❤꧂ 9999965857 ☎️ Hard And Sex...
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Government polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcdGovernment polytechnic college-1.pptxabcd
Government polytechnic college-1.pptxabcd
 
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdfThe_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
The_Canvas_of_Creative_Mastery_Newsletter_April_2024_Version.pdf
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aesthetic
 

lecture_I2C_SPI.pptx

  • 1. Serial Communication BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
  • 2. Bit serial communication concepts 2/9/2024 2 • Serial  one bit at a time • Most often using logic level signals • Timing information needs to be shared between sender and receiver – Transitions between bits, duration of a bit Introduction to Mechatronics, Figure 7.2 p. 107.  Two major types of bit serial protocols  Synchronous (shared clock)  Ex. SPI, I2C  Asynchronous (no shared clock)  Sender and receiver maintain independent clocks  Ex. RS-232, USB http://www.quatech.com/support/figures/async1.gif BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
  • 3. Synchronous serial communication 2/9/2024 3 • Characteristics of synchronous serial – At least one connection for serial data – A clock connection – Shared ground • Common types – Serial Peripheral Interface (SPI, developed by Freescale) – Inter-Integrated Circuit bus (I2C, developed by Philips (NXT)) • Arduino support – I2C and SPI • See next slide BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
  • 4. I2C 2/9/2024 BJ Furman SJSU Mechanical and Aerospace Engineering ME 106 4 • Developed in 1982 by Philips (now NXP) – To connect CPU to peripherals in televisions • Two signal lines, both are ‘open drain’, thus pull-up resistors are needed – SDA (serial data) – SCL (serial clock) • Devices are either masters or slaves – Master is the device that always drives SCL and initiates a transfer • Each device has an address • Data is sent in 8 bit bytes http://www.byteparadigm.com/kb/article/AA-00255/22/Introduction-to-SPI-and-IC-protocols.html Use 1.2k - 2.2k pull up resistors for Vcc = 3.3 V or 1.8 - 3.3k resistors for Vcc = 5 V
  • 5. Analog pins 4 (SCL) and 5 (SDA) must be pulled up, and a common ground is needed Margolis, M. (2012). Arduino Cookbook, O’Reilly Media, Inc., Sebastopol, CA, p. 422.
  • 6. You may need to shift the voltage level from 5 V (Arduino) to 3.3 V for some sensors Margolis, M. (2012). Arduino Cookbook, O’Reilly Media, Inc., Sebastopol, CA, p. 423.
  • 7. I2C protocol 2/9/2024 7 • Master initiates transfer with a START bit (SDA from high to low while SCL is high • Slave address (7 or 10 bits, 7 is most common) • Transfer type (1 bit: 0 to write, 1 to read) – All ICs compare address to their address • If address matches, device sends an ACKNOWLEDGE signal • If address does not match, device waits until bus is released by STOP condition • Once master receives ACKNOWLEDGE, it then sends (writes) or receives (reads) data – Receiver sends back ACKNOWLEDGE for each byte received • Master concludes the transfer with STOP bit General structure of a 2-byte transfer Writing 2-bytes (shaded bits are put on the bus by the master) Reading 2-bytes (shaded bits are put on the bus by the master) http://www.byteparadigm.com/kb/article/AA-00255/22/Introduction-to-SPI-and-IC-protocols.html http://www.robot- electronics.co.uk/acatalog/I2C_ Tutorial.html BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
  • 8. Many digital components use I2C • See the list from: http://forums.parallax.com/showthread.php?99 160-List-of-I2C-devices
  • 9. The Arduino can be ‘expanded’ using an I2C port expander device (pcf8574) http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574
  • 10. The Arduino can be ‘expanded’ using an I2C port expander device (pcf8574) http://garagelab.com/profiles/blogs/tutorial-arduino-i-o-port-expander-with-pcf8574
  • 11. I2C device – SRF10 Ultrasonic Range Finder 2/9/2024 11 • Devantech SRF10 – 3 cm – 6 m range – 20 Hz max rep rate – Range results in in., cm., or ms (time of flight) – Always a slave (default address is 0xE0) – Four registers: http://www.robot-electronics.co.uk/htm/srf10tech.htm  Three commands: BJ Furman SJSU Mechanical and Aerospace Engineering ME 106
  • 12. 2/9/2024 BJ Furman SJSU Mechanical and Aerospace Engineering ME 285 12 • At least one ‘master’ and ‘slave’ needed • Master controls: – Unidirectional data line, MOSI • Master Out, Slave In (data from the master to the slave) – Shared clock line, SCK (synchronizes the data transfer) – Slave select line(s), SS* • Which slave to be addressed • Slave controls: – Unidirectional data line, MISO • Master In, Slave Out (data from slave to the master) • Shared by slaves • Non-selected slaves, “tri-state” their MISO outputs • SPI is a ‘data exchange’ protocol – As a bit is clocked out of the master and received by the slave, the slave clocks out a bit that is received by the master Introduction to Mechatronics, Figure 7.4 p. 109. Introduction to Mechatronics, Figure 7.5 p. 110. SPI interface and protocol
  • 13. SPI data transfer modes 2/9/2024 BJ Furman SJSU Mechanical and Aerospace Engineering ME 285 13 • Four transfer modes – Mode 0: SCK idle low, rising edge – Mode 1: SCK idle low, falling edge – Mode 2: SCK idle high, falling edge – Mode 3: SCK idle high, rising edge • Used most often Mode 0 Mode 1 Mode 2 Mode 3 Introduction to Mechatronics, Figure 7.6 p. 111.
  • 14. Many digital components use SPI • See the (partial) list of SPI devices: http://www.mct.net/faq/spi.html