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

Thread: Teensy 3.2 Canbus - Which FlexCan do I use?

  1. #1
    Junior Member
    Join Date
    Oct 2019
    Posts
    3

    Teensy 3.2 Canbus - Which FlexCan do I use?

    Hi all,

    Ove the last couple of months (on and off) I've been developing a project around OBD/UDS canbus based data display for my car (MQB VW)
    I started off with an Arduino Uno and an Elecfreaks Canbus shield as well as an I2c OLED display (SH1106) and later on an SPI (SSD1351) RGB OLED.
    The Uno is a little slow to say the least - as I am requesting and displaying 6-10 PID's at a time and I need a high sample rate and display rate to display realtime engine data.

    I decided to try out the Teensy 3.2, being that it is a lot faster than the Uno, and has built in Can capabilities.
    I purchased a few TJA1050 transceivers, hooked them up to the Teensy with a 5v supply (via USB) and tried out SK Pang's OBD sketch (https://github.com/skpang/Teensy_CAN-Bus_ECU_reader) using Collin80's FlexCan library - but it was not picking up anything at 500KBs (where the Uno was).

    I did a lot of research and every time it came to the 3.2 and canbus, Collin's fork of FlexCan was suggested.
    I stumbled across this article (https://ironsource.com/streaming-can...a-with-teensy/) and tried it out (with the TJA in place as well as without) but still - nothing in the Teensy's serial monitor.

    I thought it might be a defective TJA, so I tried the other. All with the same result.

    I was hoping someone could direct me to the right FlexCan library for the 3.2

    Which one should be used?
    Techtop
    Collin80
    tonton
    Pawelsky


    Thanks
    David
    Last edited by Rezo; 10-10-2019 at 11:43 AM.

  2. #2
    Junior Member
    Join Date
    Oct 2019
    Posts
    3
    So I got my Teensy to read the message transmitted from the Uno ("hello" over can every second)
    I had my Can Tx/Rx mixed up between the T3.2 and the TJA1050, and I added a 120ohm resistor between CANH and CANL.


    I'm just concerned with one thing, the CanRx led (right) I hooked up flashes upon every receive from the Uno, but my Can Tx led (left) stays on.
    I get 3,3v between Tx (pin3) and Gnd
    Click image for larger version. 

Name:	IMG_0223.jpg 
Views:	2 
Size:	135.9 KB 
ID:	17914

    Is this something to worry about?

    Here is the code running on the Teensy (Collin80 FlexCan library)
    Code:
    /*
     Authors:	Eric Desgranges
     Licensed under the GNU General Public License v3.0
    */
    
    #include <FlexCAN.h>
    
    // Teensy 2.0 has the LED on pin 11
    // Teensy++ 2.0 has the LED on pin 6
    // Teensy 3.x / Teensy LC have the LED on pin 13
    const int ledPin = 13;
    
    // -------------------------------------------------------------
    static void hexDump(uint8_t dumpLen, uint8_t *bytePtr)
    {
    	uint8_t hex[17] = "0123456789abcdef";
    	uint8_t working;
    	while (dumpLen--) {
    		working = *bytePtr++;
    		Serial.write(hex[working >> 4]);
    		Serial.write(hex[working & 15]);
    	}
    	Serial.write('\r');
    	Serial.write('\n');
    }
    
    // -------------------------------------------------------------
    void setup(void)
    {
    	pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); delay(200); digitalWrite(ledPin, LOW);    // Blink once!
    	Can0.begin();
    	Serial.println(F("Hello Teensy E85!"));
    }
    
    // -------------------------------------------------------------
    void loop(void)
    {
    	CAN_message_t rxMsg;
    	while (Can0.available())
    	{
    		Can0.read(rxMsg);
    		Serial.print("CAN BUS: "); hexDump(8, rxMsg.buf);
    	}
    }
    Last edited by Rezo; 10-15-2019 at 08:50 PM.

Posting Permissions

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