I am trying to read data from the imu with an Arduino so I got an MCP2515 module. I connected the imu to a 12V power supply and the CANH and CANL wires to the CANH and CANL ports on the MCP2515. I am using pin 10 on the Arduino for the chip select and pin 2 for the interrupt.
Most of the examples I have found online are either for sending signals between two MCP2515 modules or plugging it into a car and I am struggling to understand these scripts. I have very little electronics and coding knowledge so could someone please steer me in the right direction for how to write a code that can get acceleration values from the imu?
As an extra, once I am able to get the data from the imu, I intend on storing the values to an SD card via a micro SD card module for Arduino so if anyone has any advice for this also it would be much appreciated!
You are correct you will be sending and receiving data. That is how CAN works. It is a defined protocol on both the physical and software layers. I would suggest you have two can modules one for sending and one for receiving. Download Cory Fowlers CAN library and install the receive on one system and the transmit on the other. Surprise you need both or it will not work; it cannot acknowledge itself. When somethings sends a message on CAN partway through the message it waits for an acknowledge from another node. If it does not get it it quits and will try again for a limited number of times. Until you get these two working your luck on a vehicle is slim. It would be best to post an annotated schematic of how you have wired it, including all power, ground, interconnections and power sources. While you are working on this I suggest you read a few tutorials on CAN and also get the Arduino Cookbook, skim it first then home in on the CAN section.
Is the IMU connected to a control unit? If not, then ask Bosh for a programming reference and timing diagram document. This may involve having to sign a non-disclosure document.
If it is connected to a control unit then use a CAN adaptor that supports a 1 MBPS data rate to sniff the traffic. MCP2515 boards require a 16 MHz crystal to achieve this speed.
Thanks for your replies and sorry for my late reply. Attached is a drawing I did before wiring it (don’t mind the switch or the sd card module for now). My thinking was that the arduino would request the data from the sensor and the sensor would then send the data to the arduino but maybe I need a second arduino and second mcp2515 at the other end of the system and then wire the sensor in between the two mcp2525s? Then the signal would send / request between the arduinos and pick up the sensor signal in the process?
Nice drawing. It appears correct. Your switch is a bit different but it will work without problems. "I am using pin 10 on the Arduino for the chip select and pin 2 for the interrupt." You show pin 10 for the interrupt and pin 2 for the switch in your schematic. I would not add anything else until you get it operational. I don't know the Bosch module or whether it will acknowledge any transmissions from another module but it should. Do Not use delays in your code, it will mess you up big time.