Each CAN-ID outputs 8 objects of data. When interpreting this data, certain rules are
important to note:
Step #1
– Data must be interpreted: Single-digit
pieces of data come with a zero in front of it, even though the zero is not
printed to Serial Monitor.
Step #2
– Convert Hexadecimal to Binary: This
can be done using an online converter.
Once in binary form, the ID’s data will be expressed in 64 bits.
Example 1 – ID: 21B,
Data: 1 FF E3 FF C0 0 C 51
●
Data must be
interpreted: 1 FF E3 FF C0 0 C 51 → 01 FF E3
FF C0 00 0C 51
●
Hexadecimal to
Binary: 01 FF E3 FF C0 00 0C 51 → 0000 0001 1111 1111 1110 0011 1111 1111 1100 0000 0000
0000 0000 1100 0101 0001
Example 2 – ID: 76,
Data: A6 10 7 FC 0 0 0 55
●
Data must be
interpreted: A6 10 7 FC 0 0 0 55 → A6 10 07
FC 00 00 00 55
●
Hexadecimal to
Binary: A6 10 07 FC 00 00 00 55 → 1010 0110 0001 0000 0000 0111 1111 1100 0000 0000 0000
0000 0000 0000 0101 0101
Example 3 – ID: 243,
Data: 8 0 9 20 2 0 0 C6
●
Data must be
interpreted: 8 0 9 20 2 0 0 C6 → 08 00 09
20 02 00 00 C6
●
Hexadecimal to
Binary: 08 00 09 20 02 00 00 C6 → 0000 1000 0000 0000 0000 1001 0010 0000 0000 0010 0000
0000 0000 0000 1100 0110
Step #3
– Interpret the binary Data. Once in
binary form, the data can be interpreted. Vehicle manufacturers provide an Excel sheet which explains all of the CAN IDs. An example is provided for CAN ID: 202
(reference Figure 20).
Figure 20 –
Ford has an excel document which contains all CAN-Bus IDs and features.
In these excel sheets, each ID has a several signal
descriptions. The 64-bit (numbered 0
through 63) binary code make up all of the signals within ID-202. Binary bits 16 through 31 represent the
vehicle’s kph. By converting these 16
bits to decimal form (online converter available), the vehicle’s kph is
calculated.
Bits 0-12 → Signal 1
Bits 0-12 → Signal 1
Bits
13-13 → Signal 2
Bits
14-15 → Signal 3
Bits
16-31 → Signal 4
Bits
32-41 → Signal 5
Bits
42-50 → Signal 6
Bits
51-52 → Signal 7
Bits
53-53 → Signal 8
Bits
54-55 → Signal 9
Bits
56-63 → Signal 7
16 objects → 64 bits of data → Features
●
Power Train,
●
ABS, CMU, CCM Control
●
Engine Control Data
●
Wheel Speed
Notes:
● When requesting all CAN IDs from the OBD-II port, I was unable to gain access to the power train vehicle information. It is possible that certain OEM and vehicle data is restricted from access.
● NOT all IDs are available through basic can bus connection.
Requesting All CAN-Bus Data
The path to the code required for requesting all
CAN IDs to print to the Serial Monitor can be found here:
C:\Users\rpierso3\Documents\Arduino\CAN_Writing_Prototype
The actual code for this process is as follows:
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
unsigned char len = 0;
unsigned char buf[8];
char str[20];
void setup() {
Serial.begin(9600);
Serial.println("CAN Write - Testing transmission of CAN Bus
messages");
delay(1000);
if
(Canbus.init(CANSPEED_500)) //Initialize MCP2515 CAN controller at the
specified speed
Serial.println("CAN Init ok");
else
Serial.println("Can't init CAN");
delay(1000);
}
void loop() {
tCAN message;
//Read CAN-Bus
Messages
if
(mcp2515_check_message()) {
if
(mcp2515_get_message(&message)) {
Serial.print("ID: ");
Serial.print(message.id, HEX);
Serial.print(", ");
Serial.print("Data: ");
for (int
i = 0; i < message.header.length; i++) {
Serial.print(message.data[i], HEX);
Serial.print(" ");
}
Serial.println("");
}
}
delay(100); //
Check signal every 100 milliseconds
}
This code will have CAN IDs print to Serial
Monitor. Example of what this code will
print to Serial Monitor:
ID: 4D1, Data: 0 0 0 75 7E F4 0 0
ID: 241, Data: 68 0 80 0 80 0 24 66
ID: 78, Data: DF 88 FF 61 4A E3 80 17
ID: 415, Data: 0 23 FA 0 FF 0 4C 0
ID: 75, Data: 62 0 7 D9 46 43 86 AE
ID: 21B, Data: 1 FF E3 FF C0 0 F 4E
ID: 246, Data: 80 0 0 8 0 20 80 0
ID: 240, Data: 7E 0 0 0 80 7F FD D0
ID: 344, Data: 40 38 0 0 0 0 6 F1
ID: 344, Data: 40 38 0 0 0 0 0 F7
ID: 79, Data: DF 2A 0 1 FE E1 8B 68
ID: 165, Data: 91 0 17 71 E0 0 1A 85
ID: 82, Data: 0 0 7C A6 5F F4 0 0
ID: 21D, Data: 7F 23 FF 0 17 0 FF FF
ID: 243, Data: 8 0 9 20 2 0 0 C6
ID: 240, Data: 7E 0 0 0 80 0 0 48
ID: 165, Data: 91 0 17 71 E0 0 1A 85
ID: 75, Data: 3A 0 7 DA 46 43 86 D5
ID: 241, Data: 48 0 80 0 80 0 24 68
ID: 215, Data: 27 10 27 10 27 10 27 10
ID: 45B, Data: 3 FF FF FF FF FF FF 7F
ID: 86, Data: 3E 8B F1 43 E5 3B 97 84
ID: 131, Data: 0 2 0 0 0 0 0 0
ID: 86, Data: 3E 8B A9 8B E5 39 59 C4
ID: 76, Data: A6 10 7 FC 0 0 0 55
Requesting Specific CAN-Bus Data
Code was written in the Arduino IDE to check if the
maintenance light in the car was on. The
following code can be used to check this specific feature within the CAN-Bus
ID:
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
unsigned char len = 0;
unsigned char buf[8];
char str[20];
int ticker = 0;
void setup() {
Serial.begin(9600);
Serial.println("CAN Write - Testing transmission of CAN Bus
messages");
delay(1000);
if
(Canbus.init(CANSPEED_500)) //Initialise MCP2515 CAN controller at the
specified speed
Serial.println("CAN Init ok");
else
Serial.println("Can't init CAN");
delay(1000);
}
void loop() {
tCAN message;
//Read CAN-Bus
Messages
if
(mcp2515_check_message()) {
if
(mcp2515_get_message(&message)) {
if
(message.id == 0x4F2) { // Check for specific in HEX form, ID 4F2
for (int
i = 0; i < message.header.length; i++) {
if
(message.data[i] <= 9) {
}
}
if
(message.data[5] == 32) {
Serial.println("Maintenance Required");
} else {
Serial.println("No Maintenance Required");
}
}
}
}
delay(10); //
Check signal every 100 miliseconds
}
No comments:
Post a Comment