SlideShare a Scribd company logo
1 of 26
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

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 

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