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

Thread: Using the teensy on can bus

  1. #1
    Junior Member
    Join Date
    Feb 2017
    Posts
    11

    Using the teensy on can bus

    I do small projects for the automotive market but one thing that is certain is that soon somebody will want me to interface with a can bus. I understand the basics of how can bus works but setting up can bus hardware on a chip seems quite complex and a higher level environment would be very welcome. How much support for can bus is there on the teensy environment?

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    the canbus on teensy works for receiving, but if you want to talk to the car's network you will need a transceiver chip as well.

    https://forum.pjrc.com/threads/39867...ghlight=canbus

  3. #3
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    What do you mean by transceiver chip? Do you mean the driver chip? So basically does the can work fully if a transceiver (line driver) chip is put between the microcontroller and the can bus. What sort of libraries are there. The one you linked to seems to be different from can? Or is this just a different library to do the same job on can bus. I only ask because it is called Flex can and I know there is a similar bust technology called Flex Ray so I'm just wondering if we are talking about the same technology here.

  4. #4
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    that library is to use the built in can controller on the teensy which can receive but not transmit without an additional transceiver chip. if your looking to monitor only the car's canbus traffic you dont need the transceiver chip

  5. #5
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    I just got the MCP2562 transceiver working with the CAN hardware on the Teensy 3.2. I have not hooked it up to a car yet, but plan on it soon. It is really easy, just make sure to read the Flexcan library documentation on Github by Collin80 (here: https://github.com/collin80/FlexCAN_Library). The previous Flexcan library handles things slightly differently.

  6. #6
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    collin80 is the working one thats updated

  7. #7
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    Quote Originally Posted by moult View Post
    I just got the MCP2562 transceiver working with the CAN hardware on the Teensy 3.2. I have not hooked it up to a car yet, but plan on it soon. It is really easy, just make sure to read the Flexcan library documentation on Github by Collin80 (here: https://github.com/collin80/FlexCAN_Library). The previous Flexcan library handles things slightly differently.
    The MCP2562 is a chip that does the lvel shifting ect to allow the can protocol controller to receive and send messages on the physical bus, I can't see how you can receive without one.

  8. #8
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    you can receive without a transceiver. i did it with a teensy on a car logging the network.
    i also did it with teensy 3.5 with no transceiver and a mega2560 with canbus shield sending data over a single link no issue. your not writing to the cars network your reading it and you DONT need a transceiver to see the data. i doubt you tested it though considering your only 3 posts, anyways, i did and it works.
    Last edited by tonton81; 02-06-2017 at 07:46 PM.

  9. #9
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    ok fair enough, but I'd not advocate doing it on a volume comercial product.

  10. #10
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    its not that, its just on a canbus per vehicle standards your not the one to acknowledge the receipt of a packet thats meant for the other devices, for your own canbus network, its okay, but a transceiver is not needed for monitoring only, especially if packets are not for it to acknowledge. the reason the transceiver is there is to prevent the packets from being repeated until they get an acknowledgement from the client, if you test locally you will see the packets keep repeating because no clients respond to it with an ack, on a car its different, whereas they are not, more or less repeated repetitively the same packet, but instead a live streaming data with single packet output and next packet is new info and it just cycles at 500kbps
    Last edited by tonton81; 02-06-2017 at 07:54 PM.

  11. #11
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    Right, but I thought that any CAN device woud aknowledge any message, if the device your expecting to respond is not connected and you don't get an aknowledgement you assume it was not received, try a few times more and then shut down as each device assumes it is the faulty one.

  12. #12
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    if this happened on a vehicle the network would be even more so overflooded with packets, imagine resending the same RPM packets if the cluster was taken out, that means youll have old and new packets flooding endlessly holding back the buffers of the ecu while the network is congested, makes no sense and if you log the data with the canbus device detached (cluster,abs, etc) you will not see this happen as theres only 1 packet being poured in and every cycle its a new value, not repeat the old

  13. #13
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    i do believe you can do this too not sure if library suppirts just single shot packet without ack but i read it somewhere on the forums here

  14. #14
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    My, albeit limited understanding of the can bus is that every message is acknowledged by every device. In this way at least something is going to acknowledge the message any other device sent out. If the message is not acknowledged the sender could keep sending the message continually overloading the bus. So if just something acknowledges the receipt of a valid message whether or not it was the intended recipient the sender knows that it did good. If it does not receive any acknowledgement from anything it attempts a number of times to resend that message and then gives up and shuts down to prevent overloading the bus.

  15. #15
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    i know, but disconnect a component and you will see the packet for it is still transmitted but not same values each cycle
    overflowing/building a buffer in a network for an automobile to repeat the same data is not how it works

    you are right to say that a transceiver is needed, but not for vehicles where the packets must remain updated and not stale.
    in the library (not sure if collin has it) you can probably set your own timeout and mimic live values instead of repetitive stale packets, or add a timeout to end repetitive transmissions of stale packets, i seen it happen when i did mega2560&shield to teensy, yes there were repeats, but when i was reverse engineering the canbus stream on the car, it wasnt the same principle

  16. #16
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    besides your not telling the ecu you acknowledged a cluster packet
    if you want to talk to the ecu on the network, you can add a transceiver then, but its useless for the traffic on there as it is

  17. #17
    Junior Member
    Join Date
    Feb 2017
    Posts
    11
    ok well I am a novice at CAN and can only go by what one person tells me.

    So does this library work with the arduino style environment ? I'm hoping to make an easier entry into more powerful microcontrollers and not have a headache while doing that so that I can concentrate on things like learning CAN bus.

  18. #18
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    yeah i had it running with my other arduino sketches on teensy

  19. #19
    Junior Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    10
    wait.. so i am brooding over how to soldering and circuit FT LS-CAN transceiver which is only available as SOP14 SMD and you telling me i can connect car to teensy straight with nothing at all?

    buyed that semiconductor but no clue how to drive. should i just try to run it naked only with STP+EN+BAT+VCC short circuited and let rest floating, or do i need some capacitors/resistors on the other pins?

    there is mentionend 3V interfacing with microcontroller possible with TJA1055T/3 does it mean i can use teensy 3.3V pin as power source?
    https://www.nxp.com/docs/en/data-sheet/TJA1055.pdf

  20. #20
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    no you need a transceiver, you can use 3.3v transceivers, or "some" 5v transceivers *that communicate* at 3.3v logic levels

  21. #21
    Junior Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    10
    wondering how people got this work because cannot find any breakout board for that. MCP2515 shipped with TJA1050 which is not compatible anyway some people claim it works..

    edit: except PCAN-TJA1054 is the only solution without SMD soldering so far. they terminated with 5.66 k resistor

    edit2: btw many thanks for clarifying FlexCAN_T4.h together with isotp.h is exactly what i was looking for
    Last edited by alecxs; 06-17-2021 at 06:37 PM.

  22. #22
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    should be TX to TX and RX to RX for CAN, i guess it's a custom baudrate you are running? or it's the specs of the device you're connecting to?

  23. #23
    Junior Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    10
    it should be CAN_83K3BPS Mercedes-Benz Comfort CAN-B i am pretty sure i have connected the right connector X30/6 but i also tried 500.000 no success. maybe i am using wrong teensyduino version or should i overclock? currently i am running 72 MHz

  24. #24
    Junior Member
    Join Date
    Jun 2021
    Location
    Germany
    Posts
    10
    btw that is some TJA1055T/3 breakout board where:

    - VCC + BAT + WAKE are short-circuited to +5v and buffered with 100nF
    - STB, EN set to HIGH with 10k (each) to +5v
    - RTH, RTL 5.6k (each) termination (allowed: 500 < 6k)
    - CANH, CANL 150 pF (each) capacitor

    EVERYTHING ON BOARD
    (will update link soon)

    so all it needed was some additional pull-up resistors (3.3k ~ 4.7k) for RXD and ERR against +3.3v for the logic level according to page 18 datasheet

  25. #25
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,830
    Use 83333, according to my ESP32 driver calculation, that is closer to the rate you want when I inputted 83300

    another user has a problem using 95000, when I used the driver calculation return formula, the rate of choice was 95238, and he was good to go

Posting Permissions

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