Go Down

Topic: Arduino UNO R3 with ROBOTDYN CanBus Shield connecting to RX8 Cluster (Read 216 times) previous topic - next topic

Kipnlo

Hi, first time poster. I've been working on this for three weeks to no avail.  :( Trying to get the RX8 instrument cluster to communicate. Once that is done, I plan on using it for sim racing. Anyhow, here is where I'm stuck. If I haven't provided enough info, please let me know and I will get it. Thanks

1. As mentioned above, using Arduino Uno R3 with ROBOTDYN CanBus Shield
Here is the link to ROBOTDYN Shield Schematic https://robotdyn.com/pub/media/0G-00004323==CANBUS-Shiled/DOCS/Schematic==0G-00004323==CANBUS-Shiled.pdf

2. Using instrument cluster out of RX8. Cluster powered by separate 12v 750ma plugin. Arduino/shield powered by pc. Both Arduino and cluster share common ground. The ohm resistance reading across CanL and CanH is 252R. I have reduced that to 120R. I am certain it only needs 120R at the arduino end as the cluster has 120R in it. I have checked my wiring and connections over and over to be sure they are connected correctly. The cluster is good and goes through its normal check when powered up. Here are links for the cluster schematic and pinout.
https://www.sim-pc.de/wp-content/uploads/2017/02/rx8-pins.jpg
https://www.xsimulator.net/community/proxy.php?image=http%3A%2F%2Fi864.photobucket.com%2Falbums%2Fab206%2FTansooleng%2Finstrument-cluster-1_zps4eac18b1.jpg&hash=90fb227f0ce91b689eab0d4c1a7f75a0

3. I am getting a solid RX light with everything hooked up using this code. I am in no way a coding guru, but after weeks of reading, searching, etc. This looked like the best place to start.

Code: [Select]
#include <Arduino.h>
#include <mcp_can.h>
#include <mcp_can_dfs.h>


#define COMMAND 0xFE
#define CLEAR 0x01
#define LINE0 0x80
#define LINE1 0xC0

#define CANint 2
#define LED2 8
#define LED3 7

#define NOP __asm__ ("nop\n\t")

// Variables for StatusMIL
bool checkEngineMIL;
bool checkEngineBL;
byte engTemp;
byte odo;
bool oilPressure;
bool lowWaterMIL;
bool batChargeMIL;
bool oilPressureMIL;

// Variables for PCM
byte engRPM;
byte vehicleSpeed;

// Variables for DSC
bool dscOff;
bool absMIL;
bool brakeFailMIL;
bool etcActiveBL;
bool etcDisabled;


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

void setup()
{
   
    Serial.begin(115200);
    Serial.println("Init…");
    Serial.println("Setup pins");
   
    pinMode(LED2, OUTPUT);
    pinMode(LED3, OUTPUT);
    pinMode(CANint, INPUT);

    Serial.println("Enable pullups");
    digitalWrite(LED2, LOW);
    Serial.println("CAN init:");
   
    if (CAN0.begin(CAN_500KBPS) == CAN_OK)
    {
        Serial.println("OK!");
    }
    else
    {
        Serial.println("fail :-(");
        while (1)
        {
            Serial.print("Zzz… ");
            delay(1000);
        }
     }

Serial.println("Good to go!");
}

unsigned char stmp[8]       = {0, 0, 0, 0, 0, 0, 0, 0};                         // Always Off Array
unsigned char otmp[8]       = {255,255,255,255,255,255,255,255};                // Always On Array

unsigned char statusPCM[8]  = {125,0,0,0,156,0,0,0};                            // Write to 201
unsigned char statusMIL[8]  = {140,0,0,0,0,0,0,0};                              // Write to 420
unsigned char statusDSC[8]  = {0,0,0,0,0,0,0,0};                                // Write to 212

unsigned char statusEPS1[8] = {0x00,0x00,0xFF,0xFF,0x00,0x32,0x06,0x81};        // Write to 200 0x00 00 FF FF 00 32 06 81
unsigned char statusEPS2[8] = {0x89,0x89,0x89,0x19,0x34,0x1F,0xC8,0xFF};        // Write to 202 0x89 89 89 19 34 1F C8 FF

unsigned char statusECU1[8] = {0x02,0x2D,0x02,0x2D,0x02,0x2A,0x06,0x81};        // Write to 215 - Unknown
unsigned char statusECU2[8] = {0x0F,0x00,0xFF,0xFF,0x02,0x2D,0x06,0x81};        // Write to 231 - Unknown
unsigned char statusECU3[8] = {0x04,0x00,0x28,0x00,0x02,0x37,0x06,0x81};        // Write to 240 - Unknown
unsigned char statusECU4[8] = {0x00,0x00,0xCF,0x87,0x7F,0x83,0x00,0x00};        // Write to 250 - Unknown


/*

215 02 2D 02 2D 02 2A 06 81 // Some ECU status

231 0F 00 FF FF 02 2D 06 81 // Some ECU status

240 04 00 28 00 02 37 06 81 // Some ECU status

250 00 00 CF 87 7F 83 00 00 // Some ECU status

*/


void updateMIL()
{
    statusMIL[0] = engTemp;
    statusMIL[1] = odo;
    statusMIL[4] = oilPressure;
   
  if (checkEngineMIL == 1)
  {
    statusMIL[5] = statusMIL[5] | 0b01000000;
  }
  else
  {
    statusMIL[5] = statusMIL[5] & 0b10111111;
  }
   
    if (checkEngineBL == 1)
  {
    statusMIL[5] = statusMIL[5] | 0b10000000;
  }
  else
  {
    statusMIL[5] = statusMIL[5] & 0b01111111;
  }

   if (lowWaterMIL == 1)
  {
    statusMIL[6] = statusMIL[6] | 0b00000010;
  }
  else
  {
    statusMIL[6] = statusMIL[6] & 0b11111101;
  }

     if (batChargeMIL == 1)
  {
    statusMIL[6] = statusMIL[6] | 0b01000000;
  }
  else
  {
    statusMIL[6] = statusMIL[6] & 0b10111111;
  }

       if (oilPressureMIL == 1)
  {
    statusMIL[6] = statusMIL[6] | 0b10000000;
  }
  else
  {
    statusMIL[6] = statusMIL[6] & 0b01111111;
  }
}

void updatePCM()
{
    statusPCM[0] = engRPM;
    statusPCM[4] = vehicleSpeed;
}

void updateDSC()
{       
  if (dscOff == 1)
  {
    statusDSC[3] = statusDSC[3] | 0b00000100;
  }
  else
  {
    statusDSC[3] = statusDSC[3] & 0b01111011;
  }

    if (absMIL == 1)
  {
    statusDSC[4] = statusDSC[4] | 0b00001000;
  }
  else
  {
    statusDSC[4] = statusDSC[4] & 0b11110111;
  }

      if (brakeFailMIL == 1)
  {
    statusDSC[4] = statusDSC[4] | 0b01000000;
  }
  else
  {
    statusDSC[4] = statusDSC[4] & 0b10111111;
  }

     if (etcActiveBL == 1)
  {
     statusDSC[5] = statusDSC[5] | 0b00100000;
  }
  else
  {
    statusDSC[5] = statusDSC[5] & 0b11011111;
  }

    if (etcDisabled == 1)
  {
    statusDSC[5] = statusDSC[5] | 0b00010000;
  }
  else
  {
    statusDSC[5] = statusDSC[5] & 0b11101111;
  }
 

}

void loop()
{
    // StatusMIL
    engTemp         = 145;
    odo             = 0;
    oilPressure     = 1;    // Either 0 (fault) or >=1 (Ok)
    checkEngineMIL  = 0;
    checkEngineBL   = 0;
    lowWaterMIL     = 0;
    batChargeMIL    = 0;
    oilPressureMIL  = 0;

    updateMIL();
    CAN0.sendMsgBuf(0x420, 0, 8, statusMIL);
    delay(10);


    // StatusPCM
    engRPM          = 60;    // RPM  Value*67 gives 8500 RPM Reading Redline is 127
    vehicleSpeed    = 93;    // Speed  Value=0.63*(Speed)+38.5

    updatePCM();
    CAN0.sendMsgBuf(0x201, 0, 8, statusPCM);          //CAN0.sendMsgBuf(CAN_ID, Data Type (normally 0), length of data, Data
    delay(10);

    // StatusDSC
    dscOff          = 0;
    absMIL          = 0;
    brakeFailMIL    = 0;
    etcActiveBL     = 0;    // Only works with dscOff set
    etcDisabled     = 0;    // Only works with dscOff set

    updateDSC();
    CAN0.sendMsgBuf(0x212, 0, 8, statusDSC);
    delay(10);

/*
    CAN0.sendMsgBuf(0x200, 0, 8, statusEPS1);
    delay(10);           

    CAN0.sendMsgBuf(0x202, 0, 8, statusEPS2);
    delay(10);   
           
   
    CAN0.sendMsgBuf(0x215, 0, 8, statusECU1);
    delay(10); 

    CAN0.sendMsgBuf(0x231, 0, 8, statusECU2);
    delay(10); 

    CAN0.sendMsgBuf(0x240, 0, 8, statusECU3);
    delay(10); 
    CAN0.sendMsgBuf(0x250, 0, 8, statusECU4);
    delay(10); 

*/
           
 }


4. Tested in loopback and get the following. It reads the same hooked to cluster or not.

Code: [Select]
MCP2515 Initialized Successfully!
MCP2515 Library Loopback Example...
Message Sent Successfully!
Standard ID: 0x100       DLC: 8  Data: 0xAA 0x55 0x01 0x10 0xFF 0x12 0x34 0x56
Message Sent Successfully!
Standard ID: 0x100       DLC: 8  Data: 0xAA 0x55 0x01 0x10 0xFF 0x12 0x34 0x56
Message Sent Successfully!
Standard ID: 0x100       DLC: 8  Data: 0xAA 0x55 0x01 0x10 0xFF 0x12 0x34 0x56
Message Sent Successfully!
Standard ID: 0x100       DLC: 8  Data: 0xAA 0x55 0x01 0x10 0xFF 0x12 0x34 0x56

Kipnlo

Forgot to mention that I get this is Serial Monitor with everything hooked up.

Code: [Select]
Init…
Setup pins
Enable pullups
CAN init:
OK!
Good to go!

mikb55

Check the success/fail return code from CAN0.sendMsgBuf.
Which MCP2515 library are you using?

Kipnlo

Hi, thanks for the reply. I've attached the library I'm using. Before I get to far, I'll wait and see if you think this library is ok or if I should be using another one.

mikb55

If the CAN0.sendMsgBuf returns anything but zero then look in the mcp_can_dfs.h file to see what the error code indicates.

Kipnlo

Well. I think we found the problem. I get no response from receive. I have tried another Arduino and another CanBus Shield (https://www.elecfreaks.com/estore/can-bus-shield.html)

Both give the same result, solid RX light with no response except this. The INT light is on also with the Elecfreaks Shield. (ROBOT Shield doesn't have this light)

Code: [Select]
CAN BUS Shield init ok!

Kipnlo

Ok, I'm at such a loss, going back to the basics. Using the same library, I went to code below. It should simply make the tachometer go full scale. 0x201 is the pid for the tachometer. Same result, solid RX light and no response from the cluster.

Code: [Select]
#include <SoftwareSerial.h>
#include <mcp_can.h>
#include <SPI.h>

#define CANint 2
#define LED2 8
#define LED3 7

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

void setup() {
  Serial.begin(115200);
  Serial.println("Init...");

  Serial.println("Setup pins");
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(CANint, INPUT);

  digitalWrite(LED2, LOW);

  Serial.println("CAN init:");
  if (CAN0.begin(CAN_500KBPS) == CAN_OK) {
    Serial.println("OK!");
  } else {
    Serial.println("fail :-(");
    while (1) {
      Serial.print("Zzz... ");
      delay(1000);
    }
  }
}

unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
unsigned char otmp[8] = {255,255,255,255,255,255,255,255};

void loop() {
  CAN0.sendMsgBuf(0x201, 0, 8, otmp);
  delay(50);
}


A couple things I would like to ask about.

1. Is there any relevance in comment #13 here ? If so, should this be done in comment #22? I have 5v on my RST. I only put the links instead of asking the question just to show I've been researching this a while and I'm not trying to have someone else do all the work for me.
2. With power to the Arduino/Shield 120ohms at the end and no power to the cluster with 120ohms built in, I have 60ohms across them. Is this correct?  Once the cluster is powered, the RX light goes solid and I get nothing but this.


Code: [Select]
Init...
Setup pins
CAN init:
OK!

sherzaad

... solid RX light and no response from the cluster.
I had a similar issue in a project of mine in which the arduino and the device would be powered up/down as the SAME time.

I found that putting a 'delay(1000)' right at the beginning of 'setup' resolved the issue and allowed the arduino to RX and TX CAN messages consistantly.

Hopefully this solution works for you as well...

Kipnlo

Thanks, but if you were suggesting to put it here instead of where it was in the setup, it didn't help. Any other ideas? I would still like to know about the voltage at the RST.

Code: [Select]
#include <SoftwareSerial.h>
#include <mcp_can.h>
#include <SPI.h>

#define CANint 2
#define LED2 8
#define LED3 7

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

void setup() {
      delay(1000);
  Serial.begin(115200);
  Serial.println("Init...");

  Serial.println("Setup pins");
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(CANint, INPUT);

  digitalWrite(LED2, LOW);

  Serial.println("CAN init:");
  if (CAN.begin(CAN_500KBPS) == CAN_OK) {
    //Serial.println("OK!");
  } else {
    Serial.println("fail :-(");
    while (1) {
      Serial.print("Zzz... ");

    }
  }
}

unsigned char stmp[8] = {0, 0, 0, 0, 0, 0, 0, 0};
unsigned char otmp[8] = {255, 255, 255, 255, 255, 255, 255, 255};

void loop() {
  CAN.sendMsgBuf(0x201, 0, 8, otmp);
  delay(50);
}

Go Up