Sunday, December 1, 2024

CAN Bus Tool

Product Pictures And Documentation Showing The Usage Of The CAN Bus Tool


This CAN Bus Tool uses an LCD Touchscreen, an Arduino UNO and a Microchip MCP 2515 Stand-Alone CAN Controller to allow real time monitoring of 11-bit messages and 29-bit extended messages in a CAN V2.0B bus at up to 1 Mb/s. It can also be used to send 11-bit or 29-bit CAN messages with a payload of 0 to 8 bytes. 

Messages can be viewed in real-time or specific messages can be filtered by message identifier and message content. The bus speed can be dynamically changed to the following speeds: 5, 10, 20, 31. 25, 33, 40, 50, 80, 100, 125, 200, 250, 500, and 1000 kbps (1Mbps). 

The unit, in Normal mode, will send acknowledgment replies to each received message or it can be configured in Silent mode as Listen-Only and not send replies. There is a built in 120 ohm termination resistor that can be enabled and disabled with a jumper. 

In Silent mode with the 120ohm termination resistor disabled, this unit is invisible to other devices in an existing bus.


TABLE OF CONTENTS:











DESCRIPTION:


The picture below is a top view showing the LCD Touchscreen and the CAN connector at the bottom. The CANH signal is the orange wire on the left and the CANL signal is the white wire on the right. 

This device uses the Microchip MCP2515 Stand-Alone CAN Controller with SPI Interface, Implements CAN V2.0B at 1 Mb/s, 0 to 8-byte length in the data field, 11-bit standard and 29-bit extended data frames. (CAN ID 000h to 7FFFh and 00000000h to 8FFFFFFFh)

The following speeds can be used: 5kbps 10kbps 20kbps 31.25kbps 33kbps 40kbps 50kbps 80kbps 100kbps 125kbps 200kbps 250kbps 500kbps and 1000kbps (1Mbps).

In the picture below, the unit is currently configured for 125K speed and is in Silent mode, in which ACK replies are not being sent to messages received. 


An upside down view of the CAN connector. The blue jumper on the left is used to enable the 120 ohm termination resistor that is needed by the can bus. 


Top view showing the power switch.



Side views showing all the components, a 4 AAA battery holder at the bottom, a Genuine Arduino UNO, an OSHPark made shield to hold the MCP2515 CAN Bus Controller with TJA1050 Driver and SPI Interface and a Seeed Studio Touch Screen LCD Shield at the top.






Four units are connected together using a breadboard. The (+) and (-) rails in the breadboard are used to connect the all the CANH and all the CANL signals together.

A development unit on the left is used to send data to the production units on the right. The development unit has been connected to a real world device to verify that the speed settings are correct.


Now the production units on the right are sending data to the development unit on the left, multiple units can send data simultaneously.


Note: Shorting the leads together or connecting the CANH and CANL signals backwards has not been tested and could damage the driver chip, requiring replacing the CAN driver or the CAN shield.



USAGE:


The unit powers up to the HOME screen, all the areas between square brackets [ ] are buttons that can be touched. The top left corner indicates we are in the Home screen, touching this area shows a series of Help screens. Touching the top right corner puts the unit in demonstration mode so the rest of the screens show simulated data without having to connect the unit to an actual bus. Touching the bottom left corner changes the bus speed. Touching the bottom right corner changes between Normal and Silent mode. In Normal mode, the MCP 2515 sends back an acknowledgement to each message received. When the bus speed is changed, the mode is automatically changed to Silent in order to prevent acknowledgments to be sent back at the wrong speed, which could temporarily crash a working CAN bus. The MCP 2515 requires an acknowledgment to be sent to each message it sends, so at least one receiving unit in the bus needs to be put in Normal mode, otherwise, no acknowledgement messages will be sent and the sender will sent the same message over and over until it receives an ACK.

The unit remembers the last settings of the Demo, Speed and Normal/Silent buttons and will reload them the next time it is powered up.


Touching the top right corner puts the unit in demonstration mode. In Demo mode, the MCP 2515 CAN controller is put in Loopback mode and sample messages are periodically sent to the MCP 2515 so the Realtime Viewer, Active ID and Filter View screens show data. In Loopback mode data that is written to the controller can be immediately read, no data is sent to the CANH and CANL signals.



REALTIME VIEW SCREEN:



Touching REALTIME VIEWER takes us to the Realtime screen. A new line is shown for each message received. If a message is received multiple times, multiple lines are shown, see CAN ID 0F6h on the screen below.

The full message identification (CAN ID) is shown on the left, followed by ( : ), the message length (08) and the first three bytes of the message. The last 13 received messages are shown. When the cursor reaches the bottom of the screen, it scrolls back to the top and the oldest message is overwritten.  

The first line shows a message identification of 036h, a message of 8 bytes is being sent and the first three bytes are 0Eh 00h 00h.

To see the remainder of the message data, the unit must be paused by pressing the Pause button on the top right corner


When the Realtime View screen is paused, the Pause button changes to a White background. 

To enable identification of the different viewing modes, each screen uses a different color scheme. In Realtime View, the message identification (CAN ID) and the first part of the message is shown in Red if the unit is in Normal mode and Blue if the unit is in Silent mode.


In the previous screen, the message identifier of 07Fh is followed by 08616263, indicating an 8 byte long message where the first three bytes are 61h 62h and 63h. After a while, the right part of the message changes to the background color and the first 4 bytes of the message are shown: 61h 62h 63h and 64h. To see the last 4 bytes, one has to wait a little.


After a couple of seconds, the right part of the screen changes to the last 4 bytes of the message that are 65h 66h 67h and 68h.

Thus, the complete message for the first line is: message identifier: 07Fh, length: 08 bytes and the message is 61h 62h 63h 64h 65h 66h 67h 68h.

From here, touching a line will take us to the Filter View screen and automatically filter messages containing only that message identifier (CAN ID).


Touching a line containing CAN ID 037h would take us to the Filter View screen and show us the message length, full message contents as well as the time between messages,


Touching BACK would take us first to the Realtime Viewer screen and touching it again takes us back to the Home screen.



ACTIVE ID VIEW SCREEN:



Touching Active ID View takes us to this screen, In here, a new line is displayed once for each message identifier (CAN ID) received. In order to differentiate it at a glance from Realtime View, the color scheme is different, the message identifier is in the background color and the first part of the message is either Red if Normal mode is selected or Blue in Silent mode. 

The message data format is the same as Realtime View, the first two characters (08) indicate the message length, followed by the first three bytes of the message data.

Even though 0F6h is a repeating message, only only line is shown. The newest 14 messages are shown here, followed by the message data. If more than 14 message identifications are received, the oldest one is erased and replaced with the newest one.

If the message data changes (see CAN ID 037h), the message part of the data is updated on the same line. To see the rest of the message, press Pause.


Once Pause is pressed, the button background changes to White to indicate is is enabled. Similarly to Realtime view, when Active ID is paused, the entire message contents are shown 4 bytes at a time. The first screen shows the message identification followed by ( : ) followed by a two character message length (08), followed by the first three bytes of the message 8Eh 87h 32h for message identification 0F6h shown in the first line.


After a few seconds, the message part changes to the background color and the first four bytes are shown. For message identification 0F6h, the first four bytes of the message are 8Eh 87h 32h FAh


After a few more seconds, the message part changes again to show the second half of the message. For message identification 0F6h, the next four bytes of the message are 26h 8Eh BEh 86h

Thus, for message identification (CAN ID) 0F6h, the message is 8 bytes long and it is 8Eh 87h 32h FAh 26h 8Eh BEh 86h


Touching the third line containing CAN ID 037h take us to the Filter View screen and show us the message length, full message contents as well as the time between messages,


Touching BACK would take us first to the Active ID screen and touching it again takes us back to the Home screen.



FILTER VIEW SCREEN:



Touching Filter View in the Home screen takes us to this screen where messages can be filtered by any combination of wildcards. Initially, all the field values are set to the wild card character (?). 

Messages can be filtered by any message ID, any message length, or any message content. The Yellow cursor is moved between fields by pressing the [PRV] and [NXT] buttons. The value is changed by pressing the [UP] and [DN] buttons.

One specify FILTER ID as ???????4  MSG LENGTH as 3 and FILTER DATA as ?1??????????????

And this would show any 3 byte long message with a CAN ID ending in 4 and having a 1 in the least significant half of the first byte, this would match values like 01 31 B1 or F1.


Pressing the Start button on the top right of the screen takes us to the capture screen, where messages matching the filtering criteria are shown. In this case, all fields were left to the wildcard, so this essentially turned into a realtime view where the entire message value is shown. 

As a message is received it is evaluated against the matching criteria and shown if it is a match. At the top of the screen there are two rows containing the wildcard character ( ? ). The first row shows the matching criteria for the message identification (CAN ID). The second row shows the wildcard characters that are used to match the message length and content. The first wildcard character is used to match the message length. Any matching messages are drawn with the message length as a single character first (0 .. 8). The message length is drawn in the background color to emphasize it is not part of the message data. The message data for the first line starts at 0Eh. If an E was set as the second character of the Filter Data, the first, second, third and fifth lines would be shown, but not the fourth line, as it has an F in that position of the message. 

The time elapsed between the last two received messages are shown, in this case is 39ms.  


As usual, pressing the Pause button shows more data.


When the Filter View screen is paused, the first view shows the ASCII character represented by the each message byte. In the screen below we see that the 32h have been substituted by the number 2. The line before the last one at the bottom, shows in hexadecimal view 61 62 63 64... When paused, this decodes to "abcdefgh".


If the message ID had any wildcard characters, the next view shows the message ID for each line. Here we can see that the message ID for the line containing "abcdefgh" is 05Ch. Touching a line takes us to the Filter View screen where only that particular message identification (CAN ID) is shown.


Touching the line for CAN ID 037h takes us to a screen that shows only that message, only messages that change values are shown, so we can observe that the third byte of that message changes from 00h to 01h and that message ID is sent every 1.1 seconds.

Touching a message line in the Realtime View and Active ID view brings us directly to this screen. 


Pressing pause shows more information. As the message ID does not have wildcards, it does not show the message ID for each line as only one match is possible.


In the pause view, only the message values are decoded from hexadecimal to ASCII. Pressing Back would take us first to the wildcard Filter View and then back home.


Once the back button is pressed twice, we return to the home screen. 



SEND DATA SCREEN:



Before touching Send Data, ensure Demo is set to N, messages cannot be sent in loopback mode. Additionally, Normal Mode must be selected, but that can be changed from within the Send screen. To summarize, messages can only be sent if Demo is set to N and the mode is set to Normal.

The Send Data screen is very similar to the Filter View screen but wild card characters are not allowed. The Yellow cursor is moved between fields by pressing the [PRV] and [NXT] buttons. The value is changed between the hexadecimal values 0..9 and A..F by pressing the [UP] and [DN] buttons.

Once the message ID, message length and message data are constructed, press the Send button on the the top right corner of the screen.


Once the Send button is pressed, as an additional safety, the second Send button on the lower part of the screen must be pressed for the message to be sent. 

NOTE: If Demo is set to Y, no messages can be sent and the user must press back until the Home screen is reached and Demo mode is set to N. Also, Normal mode must be set. The speed can be changed at this screen by touching the speed button at the bottom left corner, but the mode will automatically change to Silent. Once the desired speed is selected, change the mode to Normal. 


Pressing the Back button takes us back to this screen where the message can be modified or the Back button pressed again to return to the Home screen.




HELP SCREEN:


Once back on the home screen, [?] can be pressed to show the help screens.


When the help screen is shown, the help screens are advanced with the Next button. Pressing Back returns home. Pressing the speed button changes the speed and automatically changes the mode from Normal to Silent. In each help screen below, the speed button was touched to show all the speeds this device supports.

















SENDING and RECEIVING DATA:


A development unit on the left is used to send data to the production units on the right. The development unit has been verified as being able to communicate with a real world device and communicates with the production units. This is how we know that the CAN chip is being initialized correctly and the speed settings are accurate.

Below, the speeds match, all the units are in Normal mode and different message identification, message lengths and message values are sent. The highest possible 11bit (7FFh) and 29bit (8FFFFFFFh) CAN ID are sent with different message contents showing that message values are sent and received correctly.


Now each production units on the right is sending different message data to the development unit on the left, multiple units can send data simultaneously. All unit have the same speed and are in Normal mode. Some units are sending 11bit message IDs (7FFh and 567h), one unit is sending a 29bit message ID (8FFFFFFFh). All messages are received by the leftmost unit. 


The send button in each unit was pressed twice, 6 messages are registered in the receiving unit.


The sender on the left and the rightmost unit were set to 1000kbps (1Mbps). The other two units were set to a lower speed. All are in Normal mode. Only the unit with a matching speed receives the message.


Similar scenario to above. Below, the sender on the left and the rightmost unit were set to 500kbps. The other two units were set to a lower speed (250kbps). All are in Normal mode. Only the unit with a matching speed receives the message.


All of the units are set to the same speed (200kbps). The two units in the middle are set to Silent mode. The sender must be set to Normal mode and not be in demo mode in order to send messages. The rightmost receiver is set in Normal mode. The message is sent only once and received by all units. The units in Silent mode display it in Blue. The unit in Normal mode shows it in Red.


Similar scenario to above. Below, all of the units are set to the same speed (125kbps). All the receiving units are set to Silent Mode. When the Send button is pressed once, as no unit is in Normal mode and no one is sending ACK back to the sender, the sending unit autonomously sends the same message over and over.


The autonomous messages are stopped once either receiving unit is set to Normal mode. The message is drawn in Red in that unit. The others draw it in Blue.


Units can be switched from Normal to Silent mode. Messages are drawn in different colors on the units where the mode was changed.



No comments:

Post a Comment