1

I have a problem which I am working on for some days now. I do have knowledge in electronics, but not extensively. I also posted this question in the RFduino Forum but couldn't get any good answers.

What I am trying to do: I want to connect the Sparkfun CAN bus shield to the RFduino. I am using the code further below. It compiles without problem and does work with my Arduino Leonardo!

I used a logic analyser (ignore the filled shapes, some display error) to further narrow down the problem and found the following on the RFduino: Picture of the logic analyser on the RFduino

On the Leonardo, it looks different: Picture of the logic analyser on the Leonardo

It seems like I don't get a response on the MISO line! I played around with different speeds, but nothing seemed to work.

I do have a suspicion however: The RFduino works with 3.3V, while the Leonardo works with 5V. So the logic signals on the RFduino can only achieve 3.3V P-P. I confirmed this with my old CRO, LOW is at GND and HIGH at 3.3V. The Leonardo has 5V P-P. On page 70 of the datasheet for the MCP2515 (the chip used on the shield), it says that the supply voltage VDD ranges from 2.7V to 5.5V. So supply voltage should be ok. V_INPUT_HIGH ranges from 2.31 to 4.3V. V_INPUT_LOW ranges from -0.3V to 0.495V. I am in this range! Similarly so for the V_OUTPUT_LOW (up to 0.6V) and V_OUTPUT_HIGH (at least 2.8V). Could this nevertheless be a problem?

What would you try or change?

MCP2515 Datasheet

#include <SPI.h>

// demo: CAN-BUS Shield, send data
#include <mcp_can.h>


MCP_CAN CAN0(SS);                                      // Set CS to pin 10

unsigned char stmp[8] = {0, 1, 0, 3, 0, 5, 0, 7};

void setup()
{
  Serial.begin(115200);
  while (!Serial) {
    ;                  // wait for serial port to connect. Needed for Leonardo only
  }
  // init can bus, baudrate: 500k
  if(CAN0.begin(CAN_500KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
  else Serial.print("Can init fail!!\r\n");
               // send data per 100ms
}

void loop()
{
//    // send data:  id = 0x00, standrad flame, data len = 8, stmp: data buf
//  CAN0.sendMsgBuf(0x00, 0, 8, stmp);      
}

migrated from electronics.stackexchange.com Jul 15 '15 at 3:34

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

2

Ok, I found the solution. The fix first: I had to physically connect the reset line from the RFduino to the MCP2515 reset pin. On page 55 in the datasheet of the MCP2515 it says that you can either reset it by pulling the reset line low or by sending a command over the SPI. The library I used is sending this reset command, but it isn't working for some reason. The logic analyser shows me this signal, it is the first recorded. Maybe it is a timing issue, that the reset has to be sent at the same time as the RFduino resets. Connecting the reset pin solves this issue, because then the RFduino and the MCP2515 are being reset at the same time. If anybody knows more about this, feel free to tell me!

0

It is difficult to tell whether your chip select is working correctly or not with the logic analyzer view. Have you tried hooking it up to an o-scope to capture what the CS is actually doing(in the analog world)?

What cabling have you chosen between the CAN and arduino?

If you get the o-scope out, you may want to check the MISO and MOSI for ringing, which may lead back to cabling.

  • I just hooked up my oscilloscope. Looks like the analyser wasn't lying, the signal is good. A little bit of overshoot (0.1V at max), but the separation is good, the MOSI is only active when CS is low and so on. On the MISO I have some strange signal, about 25 MHz and very small (0.4V). It goes blank when the chips is reset. Giving the CAN shield/MPC2515 5V to work with doesn't change anything. – zorgmorg Jun 30 '15 at 16:08
  • After looking through the data sheets, i have to ask how are you powering the CAN BUS? From the Leonardo/RFduino? – AJee Jun 30 '15 at 17:42
  • The CAN BUS schematic shows a VCC and a +12V, but the source of VCC is not shown. If VCC is being regulated down from +5V provided by the leonarado, then VCC might not be able to be regulated down by the +3.3V provided by the rfduino. If 3.3V is the input to an LDO somewhere and 3.3V has to be the output too, you'll definately have problems.. Moral of the story, make sure you understand the Power chain fully. – AJee Jun 30 '15 at 18:57
  • The 'power chain' with the Leonardo depends on the operation: with the CAN bus connected, the 12V goes through the Vin pin of the Leonardo to its onboard 5V regulator, which then provides 5V on a pin. This pin is via the shield connected to the VCC pin on the MCP2515. The other chain is for testing, where I just initialize the chip without actually doing anything on the CAN bus: I provide 5V via USB and the Leonardo then again provides it on the same pin as above. The RFduino provides 3.3V from USB via a regulator on the programming shield, which I connect to the VCC on the CAN bus shield. – zorgmorg Jun 30 '15 at 20:56
  • So Leonardo+CANbus active: CAN->CAN Shield->Leonardo (12V->5V)->CAN Shield->MCP2515. Leonardo on USB: USB->Leonardo->CAN Shield->MCP2515. RFduino on USB: USB->Programming Shield (5V->3.3V)->CAN Shield->MCP2515. – zorgmorg Jun 30 '15 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy