SlideShare a Scribd company logo
1 of 26
Download to read offline
Implementing RS-232 Serial Ports
On An Arduino

DESERT CODE CAMP 2012.1
               Presented by Don Doerres
               Embedded Pro Guy
               don@azlaborlaw.com
TODAY’S TAKEAWAYS

 The Arduino has a ―Low Level‖ serial
  connection; many electronic devices have
  higher voltage serial connections called RS-
  232
 This class will explain
     The basics of the serial connection
     What the low and high level signals look like

     How to convert between the types of signals

     Some generalized RS-232 interfacing
      suggestions
LET’S PICK A CHARACTER FOR AN EXAMPLE

 Let‘s use capital ‗C‘ for Code Camp
 Look this up on an ANSI Chart

 Dec: 67, Hex:43, Binary, 8 bits: 01000011
THE BASIC SERIAL PROTOCOL 1

 The bits of the characters come one at a
  time, through a single wire.
 The wire ―idles‖ at a ‗1‘ level to show that it is
  alive
 The bits come out low order bit first

 We will program for bytes of 8 bits each
THE BASIC SERIAL PROTOCOL 2

 We know the wire is alive because it idles at
  ‗1‘, the higher voltage level
 We know in advance how fast bits will be
  coming out of the wire; this is called the
  ―baud rate‖
 So, our Arduino is sampling the incoming
  wire for a transition from ‗1‘ to a ‗0‘
THE BASIC SERIAL PROTOCOL 3

 So now we have one start bit
 This will be followed by 8 bits of the byte

 And, to keep this straight, we will have 1
  extra bit of 1 at the end of the string of bits to
  guarantee that a ‗1‘ to ‗0‘ transition can take
  place to indicate the start of a next byte
PUTTING IT ALL TOGETHER

 1 Start Bit, 8 data bits, 1 Stop bit
 The bits of the byte come out low order bit
  first in time
 So we will have this string of 10 bits, with
  gray showing the state of the wire before and
  after the byte:
    …1 1 1 1 0 1 1 0 0 0 0 1 0 1 1 1 1 1…
                    Time
ANOTHER VIEW OF THE SAME THING

   Here we show both the bit stream and the
    Arduino voltage levels
NOW RS232

 On the Arduino, the serial line swings
  between 0 and 5 volts (some are 0 to 3.3V)
 RS-232 is an older protocol
    A  ‗1‘ is -12V
     A ‗0‘ is +12V

   Don‘t even think about connecting the
    Arduino directly to this…please
ANOTHER VIEW OF THE SAME THING

 This time RS232
 A ‗1‘ is -12V

 A ‗0‘ is +12V
SO HOW DO WE GET FROM LOW LEVEL TO
RS232?
 We need a hardware level translator
 This one is a Sparkfun PRT-00449
HOW TO HOOK TO ARDUINO

   Note the signal arrows between the adapter
    and the Arduino
TEST CODE INCLUDES AND DEFINES
#include <SoftwareSerial.h>

#define INSOFT1 7
#define OUTSOFT1 8

int incomingByte = 0;
SoftwareSerial SWSerial(INSOFT1, OUTSOFT1);
TEST CODE SETUP
void setup()
{
Serial.begin(9600);
SWSerial.begin(9600);
}
TEST CODE LOOP
void loop()
{
while (Serial.available() > 0)
    {
    incomingByte = Serial.read();
    SWSerial.print((char)incomingByte);
    }
while (SWSerial.available() > 0)
    {
    incomingByte = SWSerial.read();
    Serial.print((char)incomingByte);
    }
}
SCREEN CAPTURES
SCREEN CAPTURES
MORE STUFF…

 Q: How do I hook up right?
 A: Use an RS232 Analyzer and adapters
HOOK TO THE MAIN COMPUTER

 The TD light should light
 Note TD and DTR, may light for a more
  advanced connection
HOOK TO THE TARGET

 The RD light should light
 Sometimes Target powered from the host,
  and there will be no lights—or the target is
  off!
 Note possible:
     CD

     CTS

     DSR
HOOK TOGETHER

   The ideal outcome – all the lights!
FIXING IT

   Sometimes you need a NULL adapter on one
    side
IF YOU DO THIS A BIT…

 Invest in some adapters
 These are a long term investment

 I bought the first of mine 30 years ago…they
  wear well
SOURCE FOR RS232 GEAR

   These companies offer different adapters
    over time
     Radio Shack (www.radioshack.com)
     Frys Electronics (www.frys.com)

   This company is more expensive, but has a
    huge variety in stock at all times
     Black   Box (www.blackbox.com)
RS232 TO LOW LEVEL ADAPTER

   Sparkfun has two different ones
     PRT-00133 ($6.95) is a through hole kit
     PRT-00449 ($13.95) is surface mount and is pre-
      built
   www.sparkfun.com
QUESTIONS?

   Find more slides from Don at
    www.slideshare.net/dondoerres
   The Arduino code shown came be
    downloaded from
    https://github.com/dondoerres/drdCodeCamp2012.
    1

More Related Content

What's hot (17)

Kramer VS-611
Kramer VS-611Kramer VS-611
Kramer VS-611
 
Kramer VS-1001-XLM
Kramer VS-1001-XLMKramer VS-1001-XLM
Kramer VS-1001-XLM
 
Kramer 401Dxl
Kramer 401DxlKramer 401Dxl
Kramer 401Dxl
 
Kramer VS-601-XLM
Kramer VS-601-XLMKramer VS-601-XLM
Kramer VS-601-XLM
 
Kramer VS-1201XL
Kramer VS-1201XLKramer VS-1201XL
Kramer VS-1201XL
 
Not gate
Not gateNot gate
Not gate
 
Building light automation (1)
Building light automation (1)Building light automation (1)
Building light automation (1)
 
Kramer VM-9T
Kramer VM-9TKramer VM-9T
Kramer VM-9T
 
Kramer VS-1011
Kramer VS-1011Kramer VS-1011
Kramer VS-1011
 
transistor transistor logic
transistor transistor logictransistor transistor logic
transistor transistor logic
 
jiby
jibyjiby
jiby
 
Vs 81 h-dxl
Vs 81 h-dxlVs 81 h-dxl
Vs 81 h-dxl
 
Kramer VS-81-HDXL
Kramer VS-81-HDXLKramer VS-81-HDXL
Kramer VS-81-HDXL
 
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
SFP(FT-901B-S-LC20)_DataSheet_ver_1.1
 
Franklin oscillator
Franklin oscillatorFranklin oscillator
Franklin oscillator
 
Hw4
Hw4Hw4
Hw4
 
Kramer VM-312
Kramer VM-312Kramer VM-312
Kramer VM-312
 

Similar to 2012 1 arduino_rs232

I2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoI2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoMike Ochtman
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseElaf A.Saeed
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptxHebaEng
 
Physical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialPhysical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialTony Olsson.
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshopatuline
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote controlVilayatAli5
 
Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3Anil Yadav
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixelssdcharle
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptansariparveen06
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorialsAnshu Pandey
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
 
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz RadiosArduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radiosroadster43
 

Similar to 2012 1 arduino_rs232 (20)

I2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduinoI2c interfacing raspberry pi to arduino
I2c interfacing raspberry pi to arduino
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Physical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serialPhysical prototyping lab3-serious_serial
Physical prototyping lab3-serious_serial
 
publish manual
publish manualpublish manual
publish manual
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Logic Gates & Family.pdf
Logic Gates & Family.pdfLogic Gates & Family.pdf
Logic Gates & Family.pdf
 
Intro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptxIntro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptx
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
Arduino spooky projects_class3
Arduino spooky projects_class3Arduino spooky projects_class3
Arduino spooky projects_class3
 
ARDUINO (1).pdf
ARDUINO (1).pdfARDUINO (1).pdf
ARDUINO (1).pdf
 
Smart Blind stick by using arduino uno and sensor
 Smart Blind stick  by using arduino  uno  and sensor Smart Blind stick  by using arduino  uno  and sensor
Smart Blind stick by using arduino uno and sensor
 
Measurements upload
Measurements uploadMeasurements upload
Measurements upload
 
Arduino Slides With Neopixels
Arduino Slides With NeopixelsArduino Slides With Neopixels
Arduino Slides With Neopixels
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
 
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz RadiosArduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
 

More from Don Doerres

2018 03 28_near_scifi
2018 03 28_near_scifi2018 03 28_near_scifi
2018 03 28_near_scifiDon Doerres
 
2018LifeOnOtherWorldsl
2018LifeOnOtherWorldsl2018LifeOnOtherWorldsl
2018LifeOnOtherWorldslDon Doerres
 
2018_03_15_life_on_otherworlds
2018_03_15_life_on_otherworlds2018_03_15_life_on_otherworlds
2018_03_15_life_on_otherworldsDon Doerres
 
2017 aacr youth day
2017 aacr youth day2017 aacr youth day
2017 aacr youth dayDon Doerres
 
Presentation desert codecamp_2017_1_sonichandkerchief
Presentation desert codecamp_2017_1_sonichandkerchiefPresentation desert codecamp_2017_1_sonichandkerchief
Presentation desert codecamp_2017_1_sonichandkerchiefDon Doerres
 
2013 1 arduino_datalogger
2013 1 arduino_datalogger2013 1 arduino_datalogger
2013 1 arduino_dataloggerDon Doerres
 
Rasberry pi class
Rasberry pi classRasberry pi class
Rasberry pi classDon Doerres
 
Raspberry pi lnl
Raspberry pi lnlRaspberry pi lnl
Raspberry pi lnlDon Doerres
 
Single Boards Overview
Single Boards OverviewSingle Boards Overview
Single Boards OverviewDon Doerres
 

More from Don Doerres (10)

2018 03 28_near_scifi
2018 03 28_near_scifi2018 03 28_near_scifi
2018 03 28_near_scifi
 
2018LifeOnOtherWorldsl
2018LifeOnOtherWorldsl2018LifeOnOtherWorldsl
2018LifeOnOtherWorldsl
 
2018 tamid sshw
2018 tamid sshw2018 tamid sshw
2018 tamid sshw
 
2018_03_15_life_on_otherworlds
2018_03_15_life_on_otherworlds2018_03_15_life_on_otherworlds
2018_03_15_life_on_otherworlds
 
2017 aacr youth day
2017 aacr youth day2017 aacr youth day
2017 aacr youth day
 
Presentation desert codecamp_2017_1_sonichandkerchief
Presentation desert codecamp_2017_1_sonichandkerchiefPresentation desert codecamp_2017_1_sonichandkerchief
Presentation desert codecamp_2017_1_sonichandkerchief
 
2013 1 arduino_datalogger
2013 1 arduino_datalogger2013 1 arduino_datalogger
2013 1 arduino_datalogger
 
Rasberry pi class
Rasberry pi classRasberry pi class
Rasberry pi class
 
Raspberry pi lnl
Raspberry pi lnlRaspberry pi lnl
Raspberry pi lnl
 
Single Boards Overview
Single Boards OverviewSingle Boards Overview
Single Boards Overview
 

Recently uploaded

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
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
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 

Recently uploaded (20)

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
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
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 

2012 1 arduino_rs232

  • 1. Implementing RS-232 Serial Ports On An Arduino DESERT CODE CAMP 2012.1 Presented by Don Doerres Embedded Pro Guy don@azlaborlaw.com
  • 2. TODAY’S TAKEAWAYS  The Arduino has a ―Low Level‖ serial connection; many electronic devices have higher voltage serial connections called RS- 232  This class will explain  The basics of the serial connection  What the low and high level signals look like  How to convert between the types of signals  Some generalized RS-232 interfacing suggestions
  • 3. LET’S PICK A CHARACTER FOR AN EXAMPLE  Let‘s use capital ‗C‘ for Code Camp  Look this up on an ANSI Chart  Dec: 67, Hex:43, Binary, 8 bits: 01000011
  • 4. THE BASIC SERIAL PROTOCOL 1  The bits of the characters come one at a time, through a single wire.  The wire ―idles‖ at a ‗1‘ level to show that it is alive  The bits come out low order bit first  We will program for bytes of 8 bits each
  • 5. THE BASIC SERIAL PROTOCOL 2  We know the wire is alive because it idles at ‗1‘, the higher voltage level  We know in advance how fast bits will be coming out of the wire; this is called the ―baud rate‖  So, our Arduino is sampling the incoming wire for a transition from ‗1‘ to a ‗0‘
  • 6. THE BASIC SERIAL PROTOCOL 3  So now we have one start bit  This will be followed by 8 bits of the byte  And, to keep this straight, we will have 1 extra bit of 1 at the end of the string of bits to guarantee that a ‗1‘ to ‗0‘ transition can take place to indicate the start of a next byte
  • 7. PUTTING IT ALL TOGETHER  1 Start Bit, 8 data bits, 1 Stop bit  The bits of the byte come out low order bit first in time  So we will have this string of 10 bits, with gray showing the state of the wire before and after the byte: …1 1 1 1 0 1 1 0 0 0 0 1 0 1 1 1 1 1… Time
  • 8. ANOTHER VIEW OF THE SAME THING  Here we show both the bit stream and the Arduino voltage levels
  • 9. NOW RS232  On the Arduino, the serial line swings between 0 and 5 volts (some are 0 to 3.3V)  RS-232 is an older protocol A ‗1‘ is -12V  A ‗0‘ is +12V  Don‘t even think about connecting the Arduino directly to this…please
  • 10. ANOTHER VIEW OF THE SAME THING  This time RS232  A ‗1‘ is -12V  A ‗0‘ is +12V
  • 11. SO HOW DO WE GET FROM LOW LEVEL TO RS232?  We need a hardware level translator  This one is a Sparkfun PRT-00449
  • 12. HOW TO HOOK TO ARDUINO  Note the signal arrows between the adapter and the Arduino
  • 13. TEST CODE INCLUDES AND DEFINES #include <SoftwareSerial.h> #define INSOFT1 7 #define OUTSOFT1 8 int incomingByte = 0; SoftwareSerial SWSerial(INSOFT1, OUTSOFT1);
  • 14. TEST CODE SETUP void setup() { Serial.begin(9600); SWSerial.begin(9600); }
  • 15. TEST CODE LOOP void loop() { while (Serial.available() > 0) { incomingByte = Serial.read(); SWSerial.print((char)incomingByte); } while (SWSerial.available() > 0) { incomingByte = SWSerial.read(); Serial.print((char)incomingByte); } }
  • 18. MORE STUFF…  Q: How do I hook up right?  A: Use an RS232 Analyzer and adapters
  • 19. HOOK TO THE MAIN COMPUTER  The TD light should light  Note TD and DTR, may light for a more advanced connection
  • 20. HOOK TO THE TARGET  The RD light should light  Sometimes Target powered from the host, and there will be no lights—or the target is off!  Note possible:  CD  CTS  DSR
  • 21. HOOK TOGETHER  The ideal outcome – all the lights!
  • 22. FIXING IT  Sometimes you need a NULL adapter on one side
  • 23. IF YOU DO THIS A BIT…  Invest in some adapters  These are a long term investment  I bought the first of mine 30 years ago…they wear well
  • 24. SOURCE FOR RS232 GEAR  These companies offer different adapters over time  Radio Shack (www.radioshack.com)  Frys Electronics (www.frys.com)  This company is more expensive, but has a huge variety in stock at all times  Black Box (www.blackbox.com)
  • 25. RS232 TO LOW LEVEL ADAPTER  Sparkfun has two different ones  PRT-00133 ($6.95) is a through hole kit  PRT-00449 ($13.95) is surface mount and is pre- built  www.sparkfun.com
  • 26. QUESTIONS?  Find more slides from Don at www.slideshare.net/dondoerres  The Arduino code shown came be downloaded from https://github.com/dondoerres/drdCodeCamp2012. 1