Can Communication: Data Acquisition & Electronics
Can Communication: Data Acquisition & Electronics
CAN COMMUNICATION
DATA ACQUISITION & ELECTRONICS
AIM:
● To make the sensor harness in the car less complicated and easy to troubleshoot.
ADVANTAGES:
● This would reduce the number of microcontrollers used in the car by a great amount as
multiple sensors can be connected to a single microcontroller which can then be used to
transmit all the data as a CAN message.
● Makes the mounting and dismounting of the data logger much easier as only a lan cabe
goes inside it for data transfer.
COMPONENTS NEEDED:
● Microcontroller
● MCP 2515 module
● LAN Cable
SETUP:
● The SPI pins of the MCP module are connected to the corresponding pins of the arduino
i.e., MISO – pin 11
MOSI – pin 12
SCK – pin 13
● CAN high and CAN low of the MCP module are connected to the corresponding CAN
high and CAN low of one of the data logger's two CAN channels.
ARDUINO CODE:
The following code makes the microcontroller extract data from the sensors and convert it to
CAN messages with the help of the MCP module.
//START OF CODE
#include <SPI.h>
#include <mcp_can.h>
#include<Wire.h>
#include<Adafruit_MLX90614.h>
MCP_CAN CAN(spiCSPin);
void setup()
{
Serial.begin(115200);
void loop()
{
b1 = mlx.readObjectTempC();
b2 = mlx1.readObjectTempC();
b3 = mlx2.readObjectTempC();
b4 = mlx3.readObjectTempC();
//END OF CODE
LUA SCRIPTING:
The following script in the data logger reveives the CAN messages and does necessary
operations on the data received to finally give out readable and usable data that can be logged.
--START OF CODE
startLogging()
count = 0
setTickRate(100)
function onTick()
–-combining the decimal values with the integer values to get final
sensor data
--END OF CODE