PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino...
Transcript of PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino...
![Page 1: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/1.jpg)
Serial Communication -UARTArduino Serial Library
PC/CP 364Serial Communication-UART
Terry Sturtevant
Wilfrid Laurier University
December 15, 2016
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 2: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/2.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver TransmitterSimplest form of serial communicationBetween 2 devicesUses 2 signals (and Ground), Rx and TxAsynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 3: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/3.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver Transmitter
Simplest form of serial communicationBetween 2 devicesUses 2 signals (and Ground), Rx and TxAsynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 4: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/4.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver TransmitterSimplest form of serial communication
Between 2 devicesUses 2 signals (and Ground), Rx and TxAsynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 5: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/5.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver TransmitterSimplest form of serial communicationBetween 2 devices
Uses 2 signals (and Ground), Rx and TxAsynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 6: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/6.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver TransmitterSimplest form of serial communicationBetween 2 devicesUses 2 signals (and Ground), Rx and Tx
Asynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 7: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/7.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Serial Communication -UART
Universal Asynchronous Receiver TransmitterSimplest form of serial communicationBetween 2 devicesUses 2 signals (and Ground), Rx and TxAsynchronous, so both must agree on baud rate
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 8: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/8.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” levelLSB transmitted firstCan have odd, even, or no parity bit1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 9: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/9.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” level
LSB transmitted firstCan have odd, even, or no parity bit1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 10: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/10.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” levelLSB transmitted first
Can have odd, even, or no parity bit1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 11: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/11.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” levelLSB transmitted firstCan have odd, even, or no parity bit
1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 12: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/12.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” levelLSB transmitted firstCan have odd, even, or no parity bit1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 13: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/13.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Communication parameters
1 Start bit at “0” levelLSB transmitted firstCan have odd, even, or no parity bit1 or 2 Stop bits at “1” level
Since start and stop bits are opposite, new characters can alwaysbe detected.
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 14: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/14.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 15: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/15.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 16: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/16.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 17: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/17.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1
1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 18: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/18.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2
1 1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 19: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/19.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2 3
1 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 20: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/20.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2 3 4
1 1 1 0 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 21: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/21.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2 3 4 5
1 1 1 0 0 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 22: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/22.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2 3 4 5 6
1 1 1 0 0 1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 23: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/23.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
LSB
1 2 3 4 5 6 7
MSB
1 1 1 0 0 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 24: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/24.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
0
LSB
1 2 3 4 5 6 7
MSB
1 1 1 0 0 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 25: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/25.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
0
LSB
1 2 3 4 5 6 7
MSB
1 1 1 0 0 1 1 0
UART no parity - 01100111
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 26: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/26.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
Parity0 1 2 3 4 5 6 7
UART even parity
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 27: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/27.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
Parity0 1 2 3 4 5 6 7
UART even parity
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 28: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/28.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
Parity0 1 2 3 4 5 6 7
UART odd parity
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 29: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/29.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Baud rate calculation
Baud rate is the number of bits possible in a seconde.g. 9600 baud → 1 bit takes 1
9600 secondAfter start bit is detected, wait time for 11
2 bit to testfor first data bit and then after every 1 bit intervalResetting at the start bit allows some clock variation
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 30: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/30.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Baud rate calculation
Baud rate is the number of bits possible in a second
e.g. 9600 baud → 1 bit takes 19600 second
After start bit is detected, wait time for 112 bit to test
for first data bit and then after every 1 bit intervalResetting at the start bit allows some clock variation
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 31: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/31.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Baud rate calculation
Baud rate is the number of bits possible in a seconde.g. 9600 baud → 1 bit takes 1
9600 second
After start bit is detected, wait time for 112 bit to test
for first data bit and then after every 1 bit intervalResetting at the start bit allows some clock variation
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 32: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/32.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Baud rate calculation
Baud rate is the number of bits possible in a seconde.g. 9600 baud → 1 bit takes 1
9600 secondAfter start bit is detected, wait time for 11
2 bit to testfor first data bit and then after every 1 bit interval
Resetting at the start bit allows some clock variation
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 33: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/33.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Baud rate calculation
Baud rate is the number of bits possible in a seconde.g. 9600 baud → 1 bit takes 1
9600 secondAfter start bit is detected, wait time for 11
2 bit to testfor first data bit and then after every 1 bit intervalResetting at the start bit allows some clock variation
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 34: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/34.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 35: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/35.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 36: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/36.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0
1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 37: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/37.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1
1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 38: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/38.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2
1 1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 39: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/39.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2 3
1 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 40: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/40.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2 3 4
1 1 1 0 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 41: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/41.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2 3 4 5
1 1 1 0 0 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 42: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/42.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2 3 4 5 6
1 1 1 0 0 1 1
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 43: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/43.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
0 1 2 3 4 5 6 7
1 1 1 0 0 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 44: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/44.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
0 1 2 3 4 5 6 7
1 1 1 0 0 1 1 0
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 45: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/45.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
0 1 2 3 4 5 6 7
1 1 1 0 0 1 1 0
Bit timing
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 46: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/46.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted±3→ ±12Zero is not a valid voltageMark level (inactive/1) is a negative voltageSpace level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 47: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/47.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted
±3→ ±12Zero is not a valid voltageMark level (inactive/1) is a negative voltageSpace level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 48: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/48.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted±3→ ±12
Zero is not a valid voltageMark level (inactive/1) is a negative voltageSpace level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 49: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/49.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted±3→ ±12Zero is not a valid voltage
Mark level (inactive/1) is a negative voltageSpace level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 50: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/50.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted±3→ ±12Zero is not a valid voltageMark level (inactive/1) is a negative voltage
Space level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 51: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/51.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
RS232 communication
Voltages are inverted±3→ ±12Zero is not a valid voltageMark level (inactive/1) is a negative voltageSpace level (active/0) is a positive voltage
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 52: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/52.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
ParityMark 0 1 2 3 4 5 6 7
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 53: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/53.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start
ParityMark
Space
0 1 2 3 4 5 6 7
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 54: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/54.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
ParityMark
Space
0 1 2 3 4 5 6 7
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 55: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/55.jpg)
Serial Communication -UARTArduino Serial Library
Baud rate calculationRS232 communication
Start Stop
ParityMark
Space
0 1 2 3 4 5 6 7
RS232 levels
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 56: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/56.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial
Serial.begin(9600)start port and set baudratewhile(!Serial)wait to connectif (Serial.available() > 0)returns True if data available, False if not
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 57: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/57.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial
Serial.begin(9600)start port and set baudrate
while(!Serial)wait to connectif (Serial.available() > 0)returns True if data available, False if not
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 58: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/58.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial
Serial.begin(9600)start port and set baudratewhile(!Serial)wait to connect
if (Serial.available() > 0)returns True if data available, False if not
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 59: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/59.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial
Serial.begin(9600)start port and set baudratewhile(!Serial)wait to connectif (Serial.available() > 0)returns True if data available, False if not
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 60: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/60.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial (continued)
Serial.write(value)write valueSerial.print(’A’)write string as ASCIIinByte = Serial.read()read byteSerial.end()close port
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 61: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/61.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial (continued)
Serial.write(value)write value
Serial.print(’A’)write string as ASCIIinByte = Serial.read()read byteSerial.end()close port
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 62: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/62.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial (continued)
Serial.write(value)write valueSerial.print(’A’)write string as ASCII
inByte = Serial.read()read byteSerial.end()close port
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 63: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/63.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial (continued)
Serial.write(value)write valueSerial.print(’A’)write string as ASCIIinByte = Serial.read()read byte
Serial.end()close port
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 64: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/64.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial (continued)
Serial.write(value)write valueSerial.print(’A’)write string as ASCIIinByte = Serial.read()read byteSerial.end()close port
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 65: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/65.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial sample code
v o i d s e t u p ( ) {S e r i a l . b e g i n ( 9 6 0 0 ) ;w h i l e ( ! S e r i a l ) {
;}
}
v o i d l o o p ( ) {i f ( S e r i a l . a v a i l a b l e ( ) > 0) {
i n B y t e = S e r i a l . r e a d ( ) ;S e r i a l . w r i t e ( i n B y t e ) ;}
}
Terry Sturtevant PC/CP 364 Serial Communication-UART
![Page 66: PC/CP 364- Serial Communication-UARTdenethor.wlu.ca/pc364/uartbeam.pdf · 2016-12-15 · Arduino Serial Library Baud rate calculation RS232 communication Baud rate calculation Baud](https://reader034.fdocuments.net/reader034/viewer/2022043020/5f3c021bfa5a4565995a307f/html5/thumbnails/66.jpg)
Serial Communication -UARTArduino Serial Library
Arduino Serial sample code
v o i d s e t u p ( ) {S e r i a l . b e g i n ( 9 6 0 0 ) ;w h i l e ( ! S e r i a l ) {
;}
}
v o i d l o o p ( ) {i f ( S e r i a l . a v a i l a b l e ( ) > 0) {
i n B y t e = S e r i a l . r e a d ( ) ;S e r i a l . w r i t e ( i n B y t e ) ;}
}
Terry Sturtevant PC/CP 364 Serial Communication-UART