{"id":2755,"date":"2017-02-06T00:00:23","date_gmt":"2017-02-06T08:00:23","guid":{"rendered":"http:\/\/192.168.3.4\/?p=2755"},"modified":"2018-01-09T06:51:28","modified_gmt":"2018-01-09T14:51:28","slug":"serial-communications","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=2755","title":{"rendered":"Serial Communications"},"content":{"rendered":"<p>Ideas and thoughts are shared with people through speech, text, or some other form of communication.\u00a0 This is how one knows, or at least has some idea of, what the other is thinking.\u00a0 Electronic devices are similar.\u00a0 Without communication, devices and people would be isolated in the cosmos.\u00a0 Like language, devices use sets of standards and protocols to accomplish communication.<\/p>\n<p>In this post, I&#8217;ll introduce briefly parallel communication.\u00a0 Next I&#8217;ll be covering the most fundamental communication methods of serial communication.\u00a0 Communication has dependencies on timing and most of our focus will be on asynchronous communication.\u00a0 Asynchronous communication has several facets like rate, start, stop, and parity.\u00a0 We&#8217;ll continue with how these devices are physically linked.\u00a0 Reliability will be a factor so we&#8217;ll cover a basic method to meet that challenge.\u00a0 Next, we&#8217;ll delve into detail of what the serial data is and how it&#8217;s constructed.\u00a0 With that knowledge, we&#8217;ll step into the world of UART and why it&#8217;s such a common bridgehead.\u00a0 Lastly, I&#8217;ll cover common mistakes that should be considered when using serial communication.\u00a0 We&#8217;ve got a lot to cover, so lets begin.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2757\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image1.png\" alt=\"\" width=\"400\" height=\"300\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image1.png 400w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image1-300x225.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image1-360x270.png 360w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>Digital electronic devices are binary by nature.\u00a0 This means that the circuitry they contain transfer, process, transmit, and receive are either high voltage states or low voltage states.\u00a0 These voltage states are simply referred to as data.<\/p>\n<p>A single device typically transfers data between its internal circuitry using parallel paths.\u00a0 This isn&#8217;t a problem because the nature of an integrated circuit or printed circuit board allow this without much effort.<\/p>\n<p>If we were to add a second device, physically separate from our first devices, linking them together with parallel links becomes a challenge.\u00a0 This is especially true when the distance between the devices becomes great.\u00a0 This is why serial communication was developed.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2758\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image2.png\" alt=\"\" width=\"318\" height=\"340\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image2.png 318w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image2-281x300.png 281w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image2-253x270.png 253w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/a><\/p>\n<p>Serial communication is the process were parallel data, or data that contain several voltage states, is assembled into a packet and sent across a single line as a signal.\u00a0 It doesn&#8217;t end there.\u00a0 To make the link, the receiving device must take that packet of data and reconstruct the parallel data it contains.\u00a0 The reliability is much greater, however the speed is greatly reduced.<\/p>\n<p>The speed of communication is determined by the clock speed of the serial signal.\u00a0 We use a clock speed because logic states are limited on how fast they can turn on and off.\u00a0 The slower the clock speed, the more reliable the receiver will see that the signal is either high or low.\u00a0 If we set the clock speed too fast, the receiver might not have enough time to accurately determine what the signal is.<\/p>\n<p>Devices that are linked have to agree on what the clock speed is.\u00a0 There are two ways to do this.\u00a0 We can send a clock signal on a separate connection, this is called synchronous serial communication.\u00a0 The other option is to have the devices use internal clocks and set both to a matching rate, this is called asynchronous serial communication.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2759\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image3.png\" alt=\"\" width=\"600\" height=\"424\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image3.png 600w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image3-300x212.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image3-382x270.png 382w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Synchronous communication adds an additional clock channel requirement to our link.\u00a0 It has some benefits like dopler correction that I won&#8217;t go into detail here.\u00a0 Adding the additional channel might not be an option when transmitting over a single fixed media.<\/p>\n<p>Having both devices use an internal clock overcomes the problem of synchronous links.\u00a0 Asynchronous communication lets us set both devices to an agreed data rate without the need for a second clock channel.\u00a0 The data rate is referred to as the baud rate.\u00a0 This is how many bits can be sent in a second, often expressed as bps.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2760\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image4.png\" alt=\"\" width=\"420\" height=\"278\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image4.png 420w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image4-300x199.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image4-408x270.png 408w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/a><\/p>\n<p>To reliably send the data, the transmitting device assembles the bits into chunk streams or more commonly known as packets.\u00a0 The packets typically consist of 8 bits of data and some quality and control bits to ensure success.\u00a0 The control bits are start and stop indicators for the receiver to accept data.\u00a0 When a transmission occurs, a start bit is sent followed by the data and concluded with a stop bit.\u00a0 The receiving device will see that a stream is about to be sent when the start bit is detected.\u00a0 It buffers the data as it is received and stops when the stop bit is detected.\u00a0 To further ensure quality of the data, a parity bit can be sent so that the receiving device is certain the bits are validated.\u00a0 Parity is done mostly by counting the number if high state bits.\u00a0 As an example, if an 8 bit data packet of 10010111 were received, the parity bit would be 1 since the high state count is an odd value.\u00a0 In contrast a packet of 11010111 would create a parity bit of 0 since the number of 1 bits is even.<\/p>\n<p>The linking of serial communication devices is key.\u00a0 The transmit port of the sending device needs to mate with the receiving port of the device accepting the data.\u00a0 They also need to have an agreed reference, most often this is ground.\u00a0 If the devices will be communicating back an forth, or bidirectionally, then the same linking method applies, transmit to receive.<\/p>\n<p>Devices that have both a transmit and receive port can send and receive data at the same time, this is called full-duplex communication.\u00a0 Some devices have both ports but can only operate one of them at a time, this is called half-duplex.<\/p>\n<p>There are many flavors of serial logic states, I&#8217;ll cover the more basic TTL and RS-232 standards.\u00a0 Transistor to Transistor Logic uses lower voltage levels.\u00a0 These are in the range of either 3.3 or 5 VCC.\u00a0 The lower voltage levels allow for faster speed, but are limited by distance.\u00a0 RS-232 uses a higher 13 to -13 volt range.\u00a0 This lets links travel longer distances but speed is limited by the inherent slew rate.\u00a0 The binary logic state for each standard is reversed.\u00a0 This means that a binary 1 state on a TTL bit is typically VCC, whereas the RS-232 logic 1 state is -13 volts.\u00a0 The reverse is true for low binary states.\u00a0 When linking TTL to RS-232, or any other serial logic state, a logic level shifter is needed to match the standards.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2762\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image5.png\" alt=\"\" width=\"612\" height=\"372\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image5.png 612w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image5-300x182.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image5-444x270.png 444w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><\/a><\/p>\n<p>When data packets are created the parallel data set of LSB and MSB need to be agreed on.\u00a0 LSB is the least significant bit or the lowest numeric value.\u00a0 MSB is the most significant bit and is the highest numeric value.\u00a0 Lets take this as an example.\u00a0 Say we have a decimal value of 138 and we need to convert this to a binary number of 8 bits, that would be 10001010.\u00a0 Our MSB is 1 which is on the left side and our LSB is 0 on the far right side.\u00a0 When the bits are placed into a packet, they typically are arranged LSB to MSB.\u00a0 This would mean it would look like a mirror of itself, 01010001.\u00a0 It all has to do with how buffers are addressed on the transmitting and receiving devices.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2763\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image6.png\" alt=\"\" width=\"600\" height=\"460\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image6.png 600w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image6-300x230.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image6-352x270.png 352w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>One of the most common methods of packet assembly and buffering is UART.\u00a0 Universal asynchronous receiver and transmitter devices follow a standard on how bits are arranged in a packet.\u00a0 It does the work of taking parallel data and converting it to serial packets.\u00a0 It also converts the serial packets it receives back into data for the parallel data bus.\u00a0 UART has control input and outputs so it can operate a function as needed.\u00a0 UARTs are mostly hardware chips but can also be software, as in the Arduino UART library.<\/p>\n<p>There are common mistakes that can make serial communications a challenge.\u00a0 Sending data from a transmit port to a device transmit port will amount to squat.\u00a0 You&#8217;re talking to the mouth, nothing is heard.\u00a0 Baud rate mismatch is another problem.\u00a0 If the transmitting device sends data too fast, the bits will wash over the receiver and garbage will be the result.\u00a0 Another problem is when more than one device transmits on the same data channel or bus.\u00a0 This bus contention will prevent the receiver from getting the data it was intended to get.\u00a0 When it comes to serial data buses, the rule is one bus can accommodate only two devices, the transmitter and the receiver.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2764\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/02\/Image7.png\" alt=\"\" width=\"600\" height=\"471\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image7.png 600w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image7-300x236.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/02\/Image7-344x270.png 344w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Aside from that, serial communications is basically simple.\u00a0 Having the ability to send and receive data between devices that have distances between them can radically improve how electronics can be used.\u00a0 This understanding is going to be needed as we cover this topic again in up comming posts.\u00a0 I hope this has been informative and I look forward to having you back for more topics.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ideas and thoughts are shared with people through speech, text, or some other form of communication.\u00a0 This is how one knows, or at least has some idea of, what the other is thinking.\u00a0 Electronic devices are similar.\u00a0 Without communication, devices and people would be isolated in the cosmos.\u00a0 Like language, devices use sets of standards and protocols to accomplish communication. In this post, I&#8217;ll introduce briefly parallel communication.\u00a0 Next I&#8217;ll be covering the most fundamental communication methods of serial communication.\u00a0&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=2755\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7,6,3,8],"tags":[],"class_list":["post-2755","post","type-post","status-publish","format-standard","hentry","category-android","category-arduino","category-raspberry-pi","category-rd","category-xbee"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2755"}],"version-history":[{"count":3,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2755\/revisions"}],"predecessor-version":[{"id":2761,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2755\/revisions\/2761"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}