Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: T4, Talldog BoB & CANbus - HELP?!

  1. #1
    Junior Member
    Join Date
    Nov 2020
    Posts
    6

    T4, Talldog BoB & CANbus - HELP?!

    Hi All,

    I working on an electronic dash project for my motorhome. The UI is built, and I now need to get it connected to the CANbus. So far I have failed utterly. I assume that it's due to ignorance on my part - something small but critical that I'm missing. Please help before I flush the whole thing...

    Here's the setup:
    1. Teensy 4.0
    2. Dan Gilbert's (Tall Dog) breakout board with on-board CANbus tansciever
    3. Separate SN65HVD230 transciever BoB
    4. All of the above on a breadboard setup wired to send from CAN2 and receive on CAN1 or CAN3. (I'm not sure which bus Daniel's board feeds to, bit I guessed it was one of these.
    5. Wired thusly:

      • BoB GND -> ext Xciever GND
      • BoB 3.3v -> ext Xciever 3.3v
      • BoB CANL -> ext Xciever CANL
      • BoB CANH -> ext Xciever CANH
      • BoB pin 0 (CRX2) -> ext Xciever RX
      • BoB pin 1 (CTX2) -> ext Xciever TX
      • I've tried crossing the Rx and Tx pins with no change in results
      • No other wiring, power is coming from the Teensy's micro USB port



    I'm using example code I found online (below), and it seems to conform with what I see in the FlexCAN_T4 examples. The output delivered to the serial monitor looks like this:


    can 1 begin complete
    can 1 baud rate set
    can 2 begin complete
    can 2 baud rate set
    can 3 begin complete
    can 3 baud rate set
    CAN1 read status = 0
    CAN3 read status = 0
    message sent, status = 1
    CAN1 read status = 0
    CAN3 read status = 0
    message sent, status = 1

    with the last 3 lines repeating infinitely.

    Thanks in advance for any help!

    Regards,

    Randy

    //************************************************** ************************************************** **********

    #include <FlexCAN_T4.h>

    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2; // this one is connected to the external transceiver, we'll use it for sending

    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
    FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> can3;

    CAN_message_t msg1, msg2;



    void setup()
    {//BEGIN setup()
    Serial.begin(115200);
    delay(500);

    can1.begin();
    Serial.println("can 1 begin complete");
    can1.setBaudRate(500000);
    Serial.println("can 1 baud rate set");
    can2.begin();
    Serial.println("can 2 begin complete");
    can2.setBaudRate(500000);
    Serial.println("can 2 baud rate set");
    can3.begin();
    Serial.println("can 3 begin complete");
    can3.setBaudRate(500000);
    Serial.println("can 3 baud rate set");
    }//END setup()


    int rs;

    void loop()
    {//BEGIN loop()
    rs = can1.read(msg2);
    Serial.print("CAN1 read status = ");
    Serial.println(rs);
    if (rs)
    {
    Serial.print("CAN1 ");
    Serial.print("MB: "); Serial.print(msg2.mb);
    Serial.print(" ID: 0x"); Serial.print(msg2.id, HEX );
    Serial.print(" EXT: "); Serial.print(msg2.flags.extended );
    Serial.print(" LEN: "); Serial.print(msg2.len);
    Serial.print(" DATA: ");
    for ( uint8_t i = 0; i < 8; i++ )
    {
    Serial.print(msg2.buf[i]); Serial.print(" ");
    }
    Serial.print(" TS: "); Serial.println(msg2.timestamp);
    }
    rs = can3.read(msg2);
    Serial.print("CAN3 read status = ");
    Serial.println(rs);
    if ( rs )
    {
    Serial.print("CAN3 ");
    Serial.print("MB: "); Serial.print(msg2.mb);
    Serial.print(" ID: 0x"); Serial.print(msg2.id, HEX );
    Serial.print(" EXT: "); Serial.print(msg2.flags.extended );
    Serial.print(" LEN: "); Serial.print(msg2.len);
    Serial.print(" DATA: ");
    for ( uint8_t i = 0; i < 8; i++ )
    {
    Serial.print(msg2.buf[i]); Serial.print(" ");
    }
    Serial.print(" TS: "); Serial.println(msg2.timestamp);
    }

    msg1.id = 0x100;
    msg1.len = 8;
    msg1.buf[0] = 10;
    msg1.buf[1] = 20;
    msg1.buf[2] = 0;
    msg1.buf[3] = 100;
    msg1.buf[4] = 128;
    msg1.buf[5] = 64;
    msg1.buf[6] = 32;
    msg1.buf[7] = 16;
    rs = can2.write(msg1);
    Serial.print("message sent, status = ");
    Serial.println(rs);
    delay(1000);
    }//END loop()

  2. #2
    I haven't had a chance to read through your code yet, but here's a couple common sources of trouble:
    Do you have the bus properly terminated at both ends with 120 ohm resistor from CANH to CANL? Combined resistance is 60 ohms between lines.

    It is also pretty common for transceivers to have some sort of enable or sleep or silent pin that needs pulled high or low. I suggest checking this for both transceivers.

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    411
    Hi Randy,
    Just to make sure, are we talking about this board?
    If so, it is imperative to know to which of Teensy's CAN pins the MCP2558FD transceiver is actually connected on the TallDog board.
    Looking very closely to the PCB layout, Im pretty sure that pin 1 of the MCP2558FD transceiver [Txd] routes to external pin CTX3, and pin 4 [Rxd] routes to pin CRX3.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	9 
Size:	294.7 KB 
ID:	22450

    These external TallDog board pins connect to the T4 by the 2x5 header to pads 30 & 31 on the backside of the T4 [see this page]. Did you actually install this header?

    From your serial output, I see that no data is received on either CAN1 or CAN 3 ["CAN1 read status = 0", "CAN3 read status = 0"].

    From the above I would change my code to transmit on CAN 3 and receive on CAN2.

    Regards,
    Paul

  4. #4
    Junior Member
    Join Date
    Nov 2020
    Posts
    6
    Msadie,


    Both Dan's board and the transceiver have the resistor, but I'll put the meter on 'em and verify everything looks good. Dan's documentation doesn't mention an enable pin. I'll go back over the pinout and see if I can find anything. There are no extra pins on the transceiver BoB, so pretty sure there's no enable pin there.


    Paul,


    Yes, that's the BoB I'm using. I do have the backside headers installed. I'll go back and verify that I have end to end continuity.

    I put the meter on the MCP2558FD TX/RX pins and found the same as you - they appear to terminate at 30 and 31 or CRX3, CTX3. I'll make the changes you suggest and re-test.

    Thanks to you both.

    Regards,

    Randy

  5. #5
    Junior Member
    Join Date
    Nov 2020
    Posts
    6

    Unhappy Still no joy...

    Tried all the suggestions, still no joy (or messages read).

    • Neither Dan's board nor the external transceiver have enable pins so no issue there.
    • The MCP2558FD on Dan's board does have a Silent Mode pin (routes to Teensy pin 6). I pulled it LOW to ensure the transceiver is in read/write mode. no change in behavior. Also set it HIGH, just to see if anything happens. No change.
    • I've verified all of my connections and they seem to be correct and sound. Pictures below.
    • Verified terminator resistors at both ends. I see 120 Ohms across CANL/CANH on each transceiver when disconnected, 60 Ohms when wired together.
    • Verified the remote transceiver is getting 3.3V.
    • I made some minor changes to the code, but nothing meaningful. Current state is at the bottom.
    • I did notice one thing by accident. Don't know if it's relevant. In the serial monitor I sent earlier, I said that sending was successful, apparently forever. That was wrong. I get a return status of SUCCESS for 8 sent messages, and FAILURE after that. I assume a buffer is filling up?


    • So, anything else I can look at?
    • Is there any way I can detect activity on the TX/RX or CANL/CANH lines without a 'scope?


    The pictures are of my development platform. I'm going to try it on the "production" platform and see if I seen anything different.

    Regards,

    Randy


    Click image for larger version. 

Name:	IMG_0131_small.jpg 
Views:	11 
Size:	110.0 KB 
ID:	22469Click image for larger version. 

Name:	IMG_0132_small.jpg 
Views:	7 
Size:	104.9 KB 
ID:	22470Click image for larger version. 

Name:	IMG_0133_small.jpg 
Views:	8 
Size:	114.5 KB 
ID:	22471

    //************************************************** ************************************

    #include <FlexCAN_T4.h>

    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
    FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
    FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> can3;

    CAN_message_t msg1, msg2;



    void setup()
    {//BEGIN setup()
    Serial.begin(115200);
    delay(500);

    pinMode(6, OUTPUT);
    digitalWrite(6, HIGH);

    can1.begin(); Serial.println("can 1 begin complete");
    can2.begin(); Serial.println("can 2 begin complete");
    can3.begin(); Serial.println("can 3 begin complete");

    pinMode( 0, INPUT);
    pinMode( 1, OUTPUT);
    pinMode(22, OUTPUT);
    pinMode(23, INPUT);
    pinMode(30, INPUT);
    pinMode(31, OUTPUT);

    msg1.id = 0x100;
    msg1.len = 8;
    msg1.buf[0] = 10;
    msg1.buf[1] = 20;
    msg1.buf[2] = 0;
    msg1.buf[3] = 100;
    msg1.buf[4] = 128;
    msg1.buf[5] = 64;
    msg1.buf[6] = 32;
    msg1.buf[7] = 16;
    }//END setup()


    int rs;

    void loop()
    {//BEGIN loop()
    rs = can3.write(msg1);
    Serial.print("message sent, status = ");
    Serial.println(rs);

    rs = can1.read(msg2);
    Serial.print("CAN1 read status = ");
    Serial.println(rs);
    if (rs != 0)
    {
    Serial.print("CAN1 ");
    Serial.print("MB: "); Serial.print(msg2.mb);
    Serial.print(" ID: 0x"); Serial.print(msg2.id, HEX );
    Serial.print(" EXT: "); Serial.print(msg2.flags.extended );
    Serial.print(" LEN: "); Serial.print(msg2.len);
    Serial.print(" DATA: ");
    for ( uint8_t i = 0; i < 8; i++ )
    {
    Serial.print(msg2.buf[i]); Serial.print(" ");
    }
    Serial.print(" TS: "); Serial.println(msg2.timestamp);
    }

    rs = can2.read(msg2);
    Serial.print("CAN2 read status = ");
    Serial.println(rs);
    if (rs != 0)
    {
    Serial.print("CAN2 ");
    Serial.print("MB: "); Serial.print(msg2.mb);
    Serial.print(" ID: 0x"); Serial.print(msg2.id, HEX );
    Serial.print(" EXT: "); Serial.print(msg2.flags.extended );
    Serial.print(" LEN: "); Serial.print(msg2.len);
    Serial.print(" DATA: ");
    for ( uint8_t i = 0; i < 8; i++ )
    {
    Serial.print(msg2.buf[i]); Serial.print(" ");
    }
    Serial.print(" TS: "); Serial.println(msg2.timestamp);
    }
    delay(1000);
    }//END loop()

  6. #6
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,518
    check to see if your CAN lines are not reversed, do you have any devices on the network to ACK the Teensy when it sends? if not it will go into bus off state and stop transmitting. I would load up the FIFO example with interrupts while testing your connections, if data is streaming in you should be fine, if not it's a hardware connection issue

  7. #7
    Junior Member
    Join Date
    Nov 2020
    Posts
    6
    Tonton81,

    The network is just the two transceivers trying to talk to one another so no ACK. I'll look at the example you reference and see what I can figure out!

    As I mentioned in my initial note, my ignorance in this area is somewhat profound. To borrow from a famous curmudgeon, "Dammit Jim, I'm a software engineer, not a EE."

    Thanks,

    Randy

  8. #8
    Junior Member
    Join Date
    Nov 2020
    Posts
    6
    tonton,

    Thank you!

    Your note prompted me to set up a second Teensy rather than trying to do everything on one. Running the FIFO example on one and a simple sender on the other and I have connectivity.

    I'm not sure why it works one way and not the other, but at this point I'll take it. Now to move it to the car and see if I can read through the OBD2 port.

    Regards,

    Randy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •