How using 9 pin D-Sub at CAN-BUS Shield?

Hello,

I’m a newby with Arduino and the CAN-BUS Shield. I have read the wiki.

I tried both ways (sending and receiving) but got always the same message:
"CAN BUS Shield init fail
Init CAN BUS Shield again
CAN BUS Shield init fail
Init CAN BUS Shield again
"

I try to use the 9 pin D-Sub Connection and not the “CANH / CANL” Connection (green on the Shield).
How can I switch or set the communication to use the D-Sub? Or does it work automaticaly on both (D-Sub and “CANH / CANL” Connection? (I Tryed both 500kbps and 250kbps.)

When I use my raspberry pi with the “PICAN CAN-Bus Board” from skpang also with the 9 pin D-Sub Connector and connect it to the canbus, it works perfectly fine.
I use the Baudrate 250kbps for the Pi.

It’s an Arduino Uno Board. And the CAN-BUS Shield is v1.2 11/03/2014.

Hopefully you can help me. Thank you in advance.

Cheers
Alex K.

This is the example code I use for “receive_check”:

#include <SPI.h>
#include "mcp_can.h"


unsigned char Flag_Recv = 0;
unsigned char len = 0;
unsigned char buf[8];
char str[20];


MCP_CAN CAN(10);                                            // Set CS to pin 10

void setup()
{
    Serial.begin(115200);

START_INIT:

    if(CAN_OK == CAN.begin(CAN_250KBPS))                   // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init ok!");
    }
    else
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        delay(100);
        goto START_INIT;
    }
}


void loop()
{
    if(CAN_MSGAVAIL == CAN.checkReceive())            // check if data coming
    {
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print(buf[i]);Serial.print("\t");
        }
        Serial.println();
    }
}

And this is the code that i try for “send”:

#include <mcp_can.h>
#include <SPI.h>

MCP_CAN CAN(10);                                      // Set CS to pin 10

void setup()
{
    Serial.begin(115200);

START_INIT:

    if(CAN_OK == CAN.begin(CAN_250KBPS))                   // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init ok!");
    }
    else
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println("Init CAN BUS Shield again");
        delay(100);
        goto START_INIT;
    }
}

unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
    // send data:  id = 0x00, standrad flame, data len = 8, stmp: data buf
    CAN.sendMsgBuf(0x00, 0, 8, stmp);
    delay(100);                       // send data per 100ms
}

Did you solve your problem? I have the same exact issue the 9pin to obd cable. I just dont seem to get get any connections made.

I have the same problem with the CAN-BUS Shield v2.0. Has someone now a soltion for using DB9 connection?

How did you connect to DB9? Any pictures?

It seems that this is not the problem, because now I tried to use the “CAN_H-CAN_L” Port and it don’t work, too.
So I opened a new forum entry here: CAN-BUS Shield V2.0: Problem with sending