{"id":1842,"date":"2016-10-09T10:38:42","date_gmt":"2016-10-09T10:38:42","guid":{"rendered":"https:\/\/ibex.tech\/resources\/?p=1842"},"modified":"2022-02-18T15:05:16","modified_gmt":"2022-02-18T15:05:16","slug":"troubleshooting-can-bus","status":"publish","type":"post","link":"https:\/\/ibex.tech\/resources\/geek-area\/communications\/can-bus\/troubleshooting-can-bus","title":{"rendered":"Troubleshooting CAN Bus"},"content":{"rendered":"<p>\nA few tips on trying to get a CAN bus to work&#8230;\n<\/p>\n<h5>\nBaud Rate<br \/>\n<\/h5>\n<p style=\"margin-left: 40px;\">\nCheck the baud rate is good using&nbsp;an oscilloscope. &nbsp;If the baud is 250k for instance, that&#39;s 1 second \/ 250000 = 4uS per bit. You should be able to see 4uS individual bits being sent&nbsp;(the SOF at the start of a frame for instance if the following address bit is high).\n<\/p>\n<h5>\nTermination!!!!!!!!<br \/>\n<\/h5>\n<p style=\"margin-left: 40px;\">\nReally easy to forget this but CAN buses need termination, its not a nice to have,&nbsp;its an essential. &nbsp;When a bit is transmitted low the bus is forced into a state, but when a high bit is transmitted the bus is simply released &#8211; the resistance is needed to pull the bus back to the idle state quickly. &nbsp;This isn&#39;t RS422\/RS485 when high&#39;s and lows are forced onto the bus so you can sometimes get away without termination, the CAN bus is an arbitration based bus that uses idle as a specific bit state.&nbsp; That means 120ohm resistors need to be placed at each end of the bus (although when developing you can often get away with 1 resistor&nbsp;if cable runs are short). &nbsp;Here&#39;s an example of a 250k CAN bus device on its own (not connected to anything else). &nbsp;First without the termination resistance (yellow and blue are the CAN-H and CAN-L bus connections):\n<\/p>\n<p style=\"margin-left: 80px;\">\n<img loading=\"lazy\" decoding=\"async\" alt=\"can_sof_no_termination\" class=\"alignnone size-full wp-image-1843\" height=\"254\" src=\"https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_no_termination.png\" width=\"446\" srcset=\"https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_no_termination.png 446w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_no_termination-300x171.png 300w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_no_termination-60x34.png 60w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_no_termination-150x85.png 150w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/>\n<\/p>\n<p style=\"margin-left: 80px;\">\nThe 4uS SOF bit has horrible slow trailing edges which the CAN bus peripheral&nbsp;in the device see&#39;s as the bit being longer than it is actually sending, causing it to dump TX assuming there is another device on the bus that it needs to concede arbitration to!\n<\/p>\n<p style=\"margin-left: 40px;\">\nNow with a 120 resistor fitted across CAN-H and CAN-L:\n<\/p>\n<p style=\"margin-left: 80px;\">\n<img loading=\"lazy\" decoding=\"async\" alt=\"can_sof_with_termination\" class=\"alignnone size-full wp-image-1844\" height=\"250\" src=\"https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_with_termination.png\" width=\"441\" srcset=\"https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_with_termination.png 441w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_with_termination-300x170.png 300w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_with_termination-60x34.png 60w, https:\/\/ibex.tech\/resources\/wp-content\/uploads\/sites\/3\/can_sof_with_termination-150x85.png 150w\" sizes=\"auto, (max-width: 441px) 100vw, 441px\" \/>\n<\/p>\n<p style=\"margin-left: 80px;\">\nA hard edged&nbsp;SOF bit leaving the device to carry on transmitting the rest of the packet.\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few tips on trying to get a CAN bus to work&#8230; Baud Rate Check the baud rate is good using&nbsp;an oscilloscope. &nbsp;If the baud is 250k for instance, that&#39;s 1 second \/ 250000 = 4uS per bit. You should be able to see 4uS individual bits being sent&nbsp;(the SOF at the start of a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94],"tags":[],"class_list":["post-1842","post","type-post","status-publish","format-standard","hentry","category-can-bus"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/comments?post=1842"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1842\/revisions"}],"predecessor-version":[{"id":1850,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/posts\/1842\/revisions\/1850"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/media?parent=1842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/categories?post=1842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/resources\/wp-json\/wp\/v2\/tags?post=1842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}