Go Down

Topic: Elevator CAN BUS (Read 4592 times) previous topic - next topic

JacquesNel

I wish I had an oscilloscope, I live in South Africa and they are a bit on the expensive side here.

I have sent the engineers, admin guys and cleaning lady at the company e-mails a couple of times but there is never a reply to my mails. I have downloaded as much info and manuals and datasheets of the controller and display as possible but nowhere (and I have read the 300+page manual on the controller)does it say anything about baud rates or anything useful. Just that there is a CANH and CANL

I think ill have to beg my boss for an oscilloscope, highly doubt he will even consider it tho.

Damn electronics, looks like we have a love hate relationship.

musskopf

Hope this is just a hobby and not to be used in a real elevator with people inside or near by...
http://talk2.wisen.com.au

JacquesNel

Just a Hobby. A very frustrating hobby that's been driving me crazy.

Besides the elevator display is totally separated from the actual control of the elevator so no danger at all.
 

JacquesNel

Its my idea of learning how the system works, but now has become a challenge and something I can get working which is probably one of the things that irritates me the most.

I need to make it work in order to sleep at night hahaha

musskopf

Maybe try one of those cheap USB logic analyser... I'm just wondering if the board is actually waiting some message from a main controller or similar to start communicating. But trying to capture it via a scope or a $10 logic analyser would be great fun as well... You can trial between two Arduinos at different speeds, where you know that works... and try on the real boards later
http://talk2.wisen.com.au

JacquesNel

I have been experimenting with different codes that I found on the internet.
When I set all the baud-rates etc. the same on the sending and receiving arduino'sI manage to get the code using the Can bus Sniffer code I have been using.

Code I have been using:
Quote
#include <SPI.h>
#include "mcp_can.h"

INT32U canId = 0x000;

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


void setup()
{
  //SPI.setClockDivider(SPI_CLOCK_DIV2);

  Serial.begin(115200);

START_INIT:

  if (CAN_OK == CAN.begin(CAN_100KBPS))
  {
    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())
  {
    CAN.readMsgBuf(&len, buf);
    canId = CAN.getCanId();
    Serial.print("<"); Serial.print(canId); Serial.print(",");
    for (int i = 0; i < len; i++)
    {
      Serial.print(buf); Serial.print(",");
    }
    Serial.print(">");
    Serial.println();
  }
}
But I found some code on another website I have been using to learn code and what does what, This project that was done involved hacking the can bus of a vehicle, they also had a send and receive code for testing purposes. When I use their send and receive code on the arduino's everything works.
But when I try using the sniffer code above to get the message nothing happens?? Could this have anything to do with my current problem I am having with the elevator CAN BUS.

The sending code from the project in question is:
Quote
#include <SPI.h>
#include "mcp_can.h"
#include <Canbus.h>  // don't forget to include these
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>

void setup()
{
Serial.begin(115200);   //Initialise MCP2515 CAN controller at the specified speed
if(Canbus.init(CAN_100KBPS))
  Serial.println("CAN Init ok");
else
  Serial.println("Can't Init CAN");

delay(1000);
}


void loop()
{
tCAN message;

        message.id = 0x21; //formatted in HEX
        message.header.rtr = 0;
        message.header.length = 8; //formatted in DEC
  message.data[0] = 0x40;
  message.data[1] = 0x05;
  message.data[2] = 0x30;
  message.data[3] = 0xFF; //formatted in HEX
  message.data[4] = 0x00;
  message.data[5] = 0x40;
  message.data[6] = 0x00;
  message.data[7] = 0x00;

mcp2515_bit_modify(CANCTRL, (1<<REQOP2)|(1<<REQOP1)|(1<<REQOP0), 0);
mcp2515_send_message(&message);

delay(1000);
}
And the receiving code is as follows:
Quote
#include <SPI.h>
#include "mcp_can.h"
#include <Canbus.h>  // don't forget to include these
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>

void setup()
{
Serial.begin(115200);  //For debugging purposes

//Initialise MCP2515 CAN controller at the specified speed
if(Canbus.init(CAN_100KBPS))
  Serial.println("CAN Init ok");
else
  Serial.println("Can't Init CAN");

delay(1000);
}

void loop()
{
tCAN message;

if (mcp2515_check_message())
  {
    if (mcp2515_get_message(&message))
  {
               Serial.print("ID: ");
               Serial.print(message.id,HEX);
               Serial.print(", ");
               Serial.print("Data: ");
               for(int i=0;i<message.header.length;i++)
                {
                  Serial.print(message.data,HEX);
                  Serial.print(" ");
                }
               Serial.println("");
             }}
}
I have no idea what the difference in the codes are, I thought it was basically just another way of telling the arduino what to do??

I am thinking my main problems for this project I am working on has to be the CAN BUS SPEED and maybe some sort of command message that the elevator control needs??
But if it was a message the elevator is looking for would the other display units still work normally??
The way I understand it I am basically just adding a node to the can bus? should will this node be excluded from getting data before there is some sort of message sent?

indikalk

Hello i'm searching help for a same project and came across this thread. did you guys get any iight on this lately. Thanks and regards.

Go Up