This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIDM-SMARTMETERBOARD3: Communication between two different CAN controller

Part Number: TIDM-SMARTMETERBOARD3


Hi all,

Currently I am working on communicating two can controllers. One controller is connected Arduino board and other controller connected to teensy board. Individually both can controllers are working like send message from can controller and read message from can controller but when i am trying to send message from Arduino and receive it on teensy or vice versa, I am not able to get output as expected  what can be reason.
I have connected wires correctly ,120ohm resistor is also connected in between.

  • Revati,

    If your CAN controllers are communicating through a CAN transceiver, and the CANH and CANL ports are connected on both transceivers, the controller should be able to read the RXD signal and interpret the message correctly. Now, there should be 60 ohms termination on the CAN bus (120 ohms on each side of the bus in parallel to make 60 ohms), but with 120 ohms there still should be some ability for the transceiver to correctly translate the message for the controller to interpret it correctly.

    If the communication isn't working, is either controller reporting errors? And is it possible for you to probe TXD, RXD, CANH, and CANL so we can see waveforms and get some insight to what may be causing the communication to not work correctly?

    Regards,

    Eric Hackett 

  • Hi Eric,
    Both CANH and CANL are connected together. There is 60ohm termination on CAN bus. In code baud rate is also same for both device. Individually I am able to read and write the message on CAN bus but after connecting i am not able to get message. Anything else  that i am forgetting?

  • Revati,

    It sounds like you're doing everything correctly. When you say you're not able to get a message, is nothing happening at all on the CAN bus, or is the controller throwing errors and not able to correctly receive the CAN message?

    Regards,

    Eric Hackett 

  • I am not able to figure out what can be reason for this type of behavior?

  • Revati,

    I understand, but from our side we need to have more information on why this might be happening. Do you have the capabilities to look at the signals on the CAN bus and share those waveforms?

    Regards,

    Eric Hackett 

  • I am trying to write to can2 and after that trying to read from can2, but I am not able to read through can2. what can be possible reason? output I am getting is for some time it is printing sent after sending successful can message but after some time it is printing fail.

    Below is code which i am using 

    #include "Arduino.h"
    #include <FlexCAN_T4.h>
    #define NUM 0x03
    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
    static CAN_message_t inMsg;
    static CAN_message_t msg;
    void setup()
    {
      Serial.begin(115200);
      can2.begin();
      can2.setBaudRate(500000);
      msg.id = 0x04000001;
      msg.len = 8;
      msg.flags.extended = 1;
      msg.buf[0] = 10;
      msg.buf[1] = 20;
      msg.buf[2] = 0;
      msg.buf[3] = 100;
      msg.buf[4] = 128;
      msg.buf[5] = 64;
      msg.buf[6] = 32;
      msg.buf[7] = 16;
    }
    
    void loop()
    {
      Serial.print("Loop");
    
      int fd = can2.write(msg);
      if (fd)
        Serial.print("sent");
      else
        Serial.print("fail");
    
      if (can2.read(inMsg) != 0)
      {
    
        Serial.print("Received CAN ID on can2:  0x");
        Serial.printf("%08X\n", inMsg.id);
        inMsg.id |= (NUM << 4);
        Serial.print("Modified CAN ID: 0x");
        Serial.printf("%08X\n", inMsg.id);
      }
      delay(4000);
    } 
  • Revati,

    So the communication works temporarily before failing, about how long does this take? And again, is there any other information you can provide from the controller, or waveforms so we can see how it is failing, or if communication is happening at all?

    Regards,

    Eric Hackett 

  • output:
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    sent
    Loop
    fail
    Loop
    fail
    Loop
    fail
    Loop
    fail
    Loo
    fail
    Loop
    fail

    This is the output i am getting after flashing code and about the waveform i don't have instrument right now to show you waveform apologize for that

  • Revati,

    This will be very difficult to debug without access to some kind of waveform or controller messages to understand what kind of failure is occurring. What CAN transceiver is being used? It looks like the communication works the majority of the time, but something is causing it to break down. What kind of message are you receiving, and how are you confirming the message is actually received? It looks like it's never reporting that the ID was received and then incremented.

    Regards,

    Eric Hackett 

  • I am using TIAJ050 can trans receiver. The functionality is stucked to can1.write(), can is not reading received message 

  • Revati,

    The TJA1050 is a CAN transceiver from NXP, not Texas Instruments, so it will be difficult to directly support the physical layer of this setup. That being said, it sounds like what is happening is the message is sending, but never receiving correctly, so the CAN controller error counter is incrementing. After a certain amount of messages and errors, the controller will go into a bus off state and not be able to transmit, nor receive. 

    Since the CAN messages in your log are being sent out, but never received this seems to be the problem. And since the other transceiver is not acknowledging that it received any message, the controller transmitting is also sensing errors, and incrementing its own counter. 

    None of this can be proven though if we don't have any insight to either controllers error codes, nor do we have access to the RXD, CANH, or CANL pin of either transceiver. Can you verify that the receiving node is actually powered on and working correctly?

    Regards,

    Eric Hackett