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

Thread: Teensy 3.2 and 3.6 CAN BUS

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Location
    Perth, Australia
    Posts
    6

    Teensy 3.2 and 3.6 CAN BUS

    Hi,

    I'm trying to make a Teensy 3.2 (transmitter) and a Teensy 3.6 (receiver) communicate through CAN using these cheap MCP2551 Modules:https://www.aliexpress.com/item/32467806585.html?spm=a2g0s.9042311.0.0.22f24c4dP75 xAS.

    But I'm not receiving anything through Teensy 3.6. I'm even tried swapping both MCP2551 modules as I have 5 of them available, thinking that maybe one of them could be faulty, with no success. I have the photos of my connections attached, and this is my code:

    Teensy 3.2 transmitter
    Code:
    #include <FlexCAN.h>
    #include <kinetis_flexcan.h>
    
    FlexCAN CANBus(500000);
    static CAN_message_t msg;
    
    void setup() {
      CANBus.begin();
      pinMode(LED_BUILTIN, OUTPUT); 
      delay(1000);
      Serial.println("CAN Transmitter Initialized");
    }
    
    void loop() {
        Serial.println("Sending");
        msg.id = 0x1;
        msg.len = 1;
        msg.buf[0] = 1;
        CANBus.write(msg);
        //digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
        delay(500);
    }
    Teensh 3.6 receiver
    Code:
    #include <FlexCAN.h>
    #include <kinetis_flexcan.h>
    
    FlexCAN CANBus(500000);
    static CAN_message_t msg;
    
    void setup() {
      CANBus.begin();
      pinMode(LED_BUILTIN, OUTPUT); 
      delay(1000);
      Serial.println("CAN Receiver Initialized");
    }
    
    void loop() {
        if (CANBus.available()) {
            Serial.println("Message Received");
            CANBus.read(msg);
            Serial.println(msg.buf[0]);
            digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
        }
    }
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	IMG_20191208_110433085.jpg 
Views:	16 
Size:	49.6 KB 
ID:	18364   Click image for larger version. 

Name:	IMG_20191208_110512273.jpg 
Views:	9 
Size:	55.8 KB 
ID:	18365  


  2. #2
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    124
    The Teensy 3.6 is not 5v input tolerant. The way you have connected the MCP2551 to the 5v supply and the logic out to the T3.6 is 5v. You might have damaged the T3.6.

    You also need a 120R terminator on each end of your network.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Location
    Perth, Australia
    Posts
    6
    The pins on the Teensy 3.6 seems to be OK. I have tried adding a voltage divider on the CANH and CANL on the Teensy 3.6 with no results. The 120R resistor is already implemented as part of the transceiver module.

  4. #4
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    124
    How did you check the pins on the Teensy 3.6 are still ok ? The CANH and CANL doesn't connect to the T3.6.

    You can try and add a voltage divider from CAN_RX (CRX pin) to the T3.6 but damage might have already been done.

  5. #5
    Junior Member
    Join Date
    Dec 2018
    Location
    Perth, Australia
    Posts
    6
    I've tested the pins with outputs and inputs and they seem to be ok. Sorry, you are right, I have done the voltage divider in the canrx and cantz, and not canh and canl. But it is still not working. Unfortunately I don't have any other boards to test this with.

  6. #6
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    124
    You don't need a voltage divider on the CAN_TX line because the signal is coming from the Teensy. What resistor value did you used ? Post a photo of the setup.

Posting Permissions

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