{"id":2930,"date":"2023-09-12T06:16:37","date_gmt":"2023-09-12T06:16:37","guid":{"rendered":"https:\/\/vegaprocessors.in\/blog\/?p=2930"},"modified":"2023-11-07T05:41:35","modified_gmt":"2023-11-07T05:41:35","slug":"interfacing-mcp2515-can-module-with-vega-aries-board","status":"publish","type":"post","link":"https:\/\/vegaprocessors.in\/blog\/interfacing-mcp2515-can-module-with-vega-aries-board\/","title":{"rendered":"Interfacing MCP2515 CAN Module with VEGA ARIES Board"},"content":{"rendered":"\n<p>In this tutorial, we will learn about the&nbsp;<strong>CAN Bus protocol<\/strong> by Interfacing&nbsp;<strong>MCP2515 CAN Bus Module<\/strong>&nbsp;with&nbsp;<strong>VEGA ARIES Boards<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MCP2515 CAN Bus Controller Module<\/strong><\/h2>\n\n\n\n<p>Microchip Technology\u2019s MCP2515 is a stand-alone Controller Area Network (CAN) controller that implements the CAN specification, Version 2.0B. It is capable of transmitting and receiving both standard and extended data and remote frames. The MCP2515 has two acceptance masks and six acceptance filters that are used to filter out unwanted messages, thereby reducing the host MCU\u2019s overhead. The MCP2515 interfaces with microcontrollers (MCUs) via an industry standard Serial Peripheral Interface (SPI). <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"964\" height=\"620\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/MCP2515-Parts.jpg\" alt=\"\" class=\"wp-image-2939\" style=\"width:419px;height:294px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/MCP2515-Parts.jpg 964w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/MCP2515-Parts-300x193.jpg 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/MCP2515-Parts-768x494.jpg 768w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/figure>\n\n\n\n<p>For more information refer to&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/MCP2515-Stand-Alone-CAN-Controller-with-SPI-20001801J.pdf\" target=\"_blank\"><strong>MCP2515 Datasheet<\/strong><\/a>&nbsp;which has a detailed guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Windows 10 or above\/Linux (64 bit)<\/li>\n\n\n\n<li>Arduino IDE<\/li>\n\n\n\n<li><a href=\"https:\/\/vegaprocessors.in\/devboards\/ariesv3.html\" target=\"_blank\" rel=\"noreferrer noopener\">VEGA ARIES Board support package<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Components Required<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ARIES v3.0 Board<\/li>\n\n\n\n<li>ARIES v2.0 Board<\/li>\n\n\n\n<li>MCP2515 CAN Bus Controller Module * 2<\/li>\n\n\n\n<li>USB type C to USB type A cable<\/li>\n\n\n\n<li>Micro USB type B to USB type A cable<\/li>\n\n\n\n<li>Jumper Wires<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Libraries Required<\/h2>\n\n\n\n<p>Download the&nbsp;<strong><a href=\"https:\/\/gitlab.com\/riscv-vega\/vega-sensor-libraries\/display\/vega_chainableled\">CAN_BUS_SHIELD<\/a><\/strong>&nbsp;Library by Seeed Studio from&nbsp;<strong>Tools -&gt; Manage Libraries&#8230;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"432\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-1024x432.png\" alt=\"\" class=\"wp-image-2951\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-1024x432.png 1024w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-300x127.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-768x324.png 768w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-1536x648.png 1536w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/Untitled-4-2048x864.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Circuit Diagram<\/h2>\n\n\n\n<p>Now let us interface MCP2515 CAN Bus Module with ARIES and test the CAN Communication protocol. We will transmit the character array of size 8 over a CAN Bus with the help of pair of ARIES Boards &amp; MCP2515 CAN Module. Here is the simple connection diagram.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"540\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/CAN_BUS_SHIELD_ARIES.png\" alt=\"\" class=\"wp-image-2938\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/CAN_BUS_SHIELD_ARIES.png 960w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/CAN_BUS_SHIELD_ARIES-300x169.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/CAN_BUS_SHIELD_ARIES-768x432.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p>The left part consisting of ARIES v2.0 Board connected to CAN Module using SPI protocol, which is a receiver part. Similarly, the right part consisting of ARIES v3.0 Board &amp; CAN Module which is the transmitter part.<\/p>\n\n\n\n<p>The transmitter &amp; Receiver Part is connected to each other with the help of the MCP2515 CAN Bus Module. The CAN_H &amp; CAN_L of the transmitter are connected to the CAN_H &amp; CAN_L of the receiver respectively.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"332\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/TJA1050-pinout.png\" alt=\"\" class=\"wp-image-3073\" style=\"width:820px;height:356px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/TJA1050-pinout.png 764w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/09\/TJA1050-pinout-300x130.png 300w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><figcaption class=\"wp-element-caption\"><strong><em>TJA1050 pinout<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Connections<\/h2>\n\n\n\n<p>The connection between ARIES Board &amp; MCP2515 CAN Module is as follows.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-ad2f72ca wp-block-group-is-layout-flex\">\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>MCP2515 CAN Bus Module<\/strong>   <\/td><td><strong>ARIES V2.0 Board<\/strong><\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>CS<\/td><td>GPIO-9<\/td><\/tr><tr><td>SO<\/td><td>MISO-1<\/td><\/tr><tr><td>SI<\/td><td>MOSI-1<\/td><\/tr><tr><td>SCK<\/td><td>SCLK-1<\/td><\/tr><tr><td>INT<\/td><td>GPIO-2<\/td><\/tr><tr><td>VCC (TJA1050)<\/td><td>5V<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><em><strong>Connection at CAN Receiver side<\/strong><\/em><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>MCP2515 CAN Bus Module<\/strong>  <\/td><td> <strong>ARIES V3.0 Board<\/strong><\/td><\/tr><tr><td>VCC<\/td><td>3.3V<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><\/tr><tr><td>CS<\/td><td>GPIO-9<\/td><\/tr><tr><td>SO<\/td><td>MISO-1<\/td><\/tr><tr><td>SI<\/td><td>MOSI-1<\/td><\/tr><tr><td>SCK<\/td><td>SCLK-1<\/td><\/tr><tr><td>INT<\/td><td>&#8211;<\/td><\/tr><tr><td>VCC (TJA1050)<\/td><td>5V<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><em><strong>Connection on CAN Transmitter side<\/strong><\/em><\/figcaption><\/figure>\n<\/div>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>MCP2515 CAN Bus Module<\/strong> <strong>(Receiver)<\/strong><\/td><td><strong>MCP2515 CAN Bus Module<\/strong> <strong>(Transmitter)<\/strong><\/td><\/tr><tr><td>H<\/td><td>H<\/td><\/tr><tr><td>L<\/td><td>L<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"><strong><em>Connection between two MCP2515 CAN modules<\/em><\/strong><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<p>Once we&#8217;re done with the connections, let\u2019s power up both the board. Make sure the Laptop\/Desktop\/PC which we&#8217;re using should be preinstalled with Arduino IDE and VEGA ARIES boards of latest version.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now,&nbsp;<strong>Open&nbsp;<\/strong>the Arduino IDE<\/li>\n\n\n\n<li>The code is divided into two parts one as CAN transmitter code (ARIES v3) and the other as CAN Receiver code (ARIES v2). First, we will upload the transmitter code, so make sure you have selected&nbsp;ARIES v3&nbsp;Board from&nbsp;<strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Board<\/strong>&nbsp;-&gt;&nbsp;<strong>VEGA Processor: ARIES Boards<\/strong>&nbsp;-&gt;&nbsp;<strong>ARIES v3<\/strong><\/li>\n\n\n\n<li>Select Programmer as VEGA XMODEM from&nbsp;<strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Programmer<\/strong>&nbsp;-&gt;&nbsp;<strong>VEGA XMODEM<\/strong><\/li>\n\n\n\n<li>Also select appropriate port,&nbsp;<strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Port<\/strong>&nbsp;-&gt;&nbsp;<strong>COM* (ARIES <strong>Board<\/strong>)<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"792\" height=\"437\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendTools.png\" alt=\"\" class=\"wp-image-4487\" style=\"width:727px;height:384px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendTools.png 792w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendTools-300x166.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendTools-768x424.png 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li> Open&nbsp;<strong>File<\/strong>&nbsp;-&gt;&nbsp;<strong>Examples<\/strong>&nbsp;-&gt; Under&nbsp;<strong>Examples for ARIES v3<\/strong>&nbsp;-&gt;&nbsp;<strong>SPI<\/strong>&nbsp;-&gt;&nbsp;<strong>CAN_BUS_SHIELD_MCP2515 -&gt; send<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"950\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendDemo-1.png\" alt=\"\" class=\"wp-image-4489\" style=\"aspect-ratio:1.033450704225352;width:633px;height:auto\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendDemo-1.png 884w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendDemo-1-279x300.png 279w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canSendDemo-1-768x825.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now let&#8217;s <strong>Upload<\/strong> the send\/transmitter code.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Once the transmitter\/send code is uploaded successfully, Now let&#8217;s upload the Receiver code. For that select ARIES v2 Board from <strong>Tools<\/strong>&nbsp;-&gt;&nbsp;<strong>Board<\/strong>&nbsp;-&gt;&nbsp;<strong>VEGA Processor: ARIES Boards<\/strong>&nbsp;-&gt;&nbsp;<strong>ARIES v2<\/strong><\/li>\n\n\n\n<li>Also select appropriate port,\u00a0<strong>Tools<\/strong>\u00a0->\u00a0<strong>Port<\/strong>\u00a0->\u00a0<strong>COM* (ARIES Board)<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"444\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canReceiveTools-1.png\" alt=\"\" class=\"wp-image-4490\" style=\"width:730px;height:386px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canReceiveTools-1.png 784w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canReceiveTools-1-300x170.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/11\/canReceiveTools-1-768x435.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now, open <strong>File<\/strong>&nbsp;-&gt;&nbsp;<strong>Examples<\/strong>&nbsp;-&gt; Under&nbsp;<strong>Examples for ARIES v2<\/strong>&nbsp;-&gt;&nbsp;<strong>SPI<\/strong>&nbsp;-&gt;&nbsp;<strong>CAN_BUS_SHIELD_MCP2515 -&gt; receive<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"966\" height=\"935\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/can_receive_demo.png\" alt=\"\" class=\"wp-image-2949\" style=\"width:690px;height:508px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/can_receive_demo.png 966w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/can_receive_demo-300x290.png 300w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/can_receive_demo-768x743.png 768w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Finally <strong>Upload<\/strong> the receiver code.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Output<\/h2>\n\n\n\n<p>After uploading sender\/transmitter code in ARIES v3, character array of size 8 with initially value of all elements equals to 0 will start transmitting through CAN_H &amp; CAN_L pins. The last element (index-7th) will start incrementing by 1. When the index-7th element value get equals to 100, it will reset to 0 and second last element (index-6th) will increment by 1. For every value of index-7th equals to 100, index-6th element will increment by 1. Similarly for every index-6th element value equal to 100, index 5th element will increment by 1. And these all updated values will continuously transmit to receivers end (ARIES v2) after every 100 ms delay. On successful transmission below message will display on Serial monitor. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"697\" height=\"399\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/send_output.png\" alt=\"\" class=\"wp-image-2952\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/send_output.png 697w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/send_output-300x172.png 300w\" sizes=\"auto, (max-width: 697px) 100vw, 697px\" \/><\/figure>\n\n\n\n<p>When the receiver code is uploaded in ARIES v2 (receiver), it will continuously check if the data is receiving through CAN_L &amp; CAN_H pins. If it receives the data, it will get its length and read the data into the buffer. Also, it will read its CAN ID and prints the data, and the CAN ID continuously on serial monitor as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"655\" height=\"400\" src=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/receive_output.png\" alt=\"\" class=\"wp-image-2953\" style=\"width:697px;height:426px\" srcset=\"https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/receive_output.png 655w, https:\/\/vegaprocessors.in\/blog\/wp-content\/uploads\/2023\/08\/receive_output-300x183.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will learn about the&nbsp;CAN Bus protocol by Interfacing&nbsp;MCP2515 CAN Bus Module&nbsp;with&nbsp;VEGA ARIES Boards. MCP2515 CAN Bus Controller Module Microchip Technology\u2019s MCP2515 is a stand-alone Controller Area Network (CAN) controller that implements the CAN specification, Version 2.0B. It is capable of transmitting and receiving both standard and extended data and remote frames. [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":3238,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94],"tags":[75,76,68,31,24],"class_list":["post-2930","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aries-with-arduinoide","tag-aries-v2-board","tag-c-dac","tag-gpio","tag-thejas32","tag-vegaprocessor"],"_links":{"self":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/2930","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/comments?post=2930"}],"version-history":[{"count":18,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/2930\/revisions"}],"predecessor-version":[{"id":4491,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/posts\/2930\/revisions\/4491"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media\/3238"}],"wp:attachment":[{"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/media?parent=2930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/categories?post=2930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vegaprocessors.in\/blog\/wp-json\/wp\/v2\/tags?post=2930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}