Search results

  1. M

    Teensy Programming with Simulink

    It just came to my attention that a number of features have been added to Simulink over the past few years to support programming Teensy 4 hardware. The most reason release (2026B) added support for data logging to SD-card and XCP-over-CAN. My prior attempts at Simulink+Arduino were cumbersome...
  2. M

    Clamping digital input to 3.3V rail

    I briefly considered an optocoupler but I was trying to keep it simple, plus no galvanic isolation is required. But yes, I agree that would be a good solution for the next pcb revision. The signals are quite slow, the project is just reading some dash rocker switches and a brake pedal switch...
  3. M

    Clamping digital input to 3.3V rail

    I'm working on an automotive project that uses a T4.0 to read a digital signal that is either 0V (off) or 11-15V (on). Rather than just using a simple voltage divider to reduce the voltage to under 3.3V, I thought I would improve the protection by using clamping diodes tied to the GND and 3.3V...
  4. M

    Precision and drift of GPS position

    In this solution, what is your source for speed? Measuring rotations of the wheels or GPS? If you can add another sensor besides the GPS, such as wheel speed or even acceleration, a Kalman filter can give good results. A simpler alternative that may work is a complimentary filter. Either of...
  5. M

    CAN Error Frame Register

    Regarding bus load estimate: Vector Bus Load You would just need to adjust the math for your assumptions.
  6. M

    Teensy 4.1 GPIO protection

    Absolute maximum rated voltage for T4.1 pins is 3.6V. if you expect the possibility of 5V, you will need something more to limit the voltage closer to 3.3V, like a zener or schottky clamp diode.
  7. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    I'm not very familiar with Peak tools, but in CANalyzer you can have the tool ACK its own tx messages to keep the bus from going into an error state while it is the only device on the bus. If you could do this, it could help narrow down if the problem is starting up on an active bus vs starting...
  8. M

    WDT_T4 - Watchdog Library for Teensy 4

    Simon, wdt.expired(); This function returns a boolean value indicating if the LAST reset resulted from a watchdog timeout. If the last reset was due to power-on reset or software initiated reset (normal operations), this will return false. This could be useful in the setup or the loop function...
  9. M

    Forwarding with FlexCAN_T4 While Modifying Some

    A T4 running at 600MHz can make surprisingly quick work of a car battery if the car sits for long periods (like winter storage or while on vacation). While switching the T4 on/off from a ignition signal is certainly the most straight forward, there other ways to accomplish this. For example...
  10. M

    Forwarding with FlexCAN_T4 While Modifying Some

    If your vehicle uses an "Ignition" signal wire to wake up the control modules, you could also use this to control when the Teensy is powered, instead of relying on bus traffic. However, I know some newer vehicles have reduced the use of the IGN wire and just use CAN bus traffic to wake many of...
  11. M

    Forwarding with FlexCAN_T4 While Modifying Some

    Glad you got it working. The FlexCAN module on the T4 has the capability to go into "Stop Mode" which is a system low power mode, and "Self Wake" on CAN traffic. Unfortunately, this functionality isn't currently implemented in the FlexCAN_T4 library, nor any other library I'm aware of. Looking...
  12. M

    Forwarding with FlexCAN_T4 While Modifying Some

    The 0x denotes hexadecimal notation, which is typically used for ID and Byte data. However, the decimal equivalent is equally valid. For example, ID=0x3EA is the same as if you wrote ID=1002. Therefore you can't simply drop the "0x" without converting to the decimal value. Hope that makes sense...
  13. M

    Forwarding with FlexCAN_T4 While Modifying Some

    Yep, that's the bare minimum to create a message. If you need to shorten the data length, you can use the msg.len property. If you don't specify the length, it defaults to 8 bytes.
  14. M

    Forwarding with FlexCAN_T4 While Modifying Some

    I'm glad that helped. Good catch on copying the frame in the callback. Yes. enableFIFOInterrupt() instructs FlexCAN to call the callbacks you specify with onReceive(). Without that, gotFrame1() and gotFrame2() will never be processed.
  15. M

    Forwarding with FlexCAN_T4 While Modifying Some

    The onReceive() function can't be used to separate messages by ID, as you are trying to do. It can only be attached to mailboxes or the FIFO. In setup(), attach your callback to the FIFO like this: Can0.enableFIFO(); Can0.enableFIFOInterrupt(); Can0.onReceive(gotFrame0); then in gotFrame0()...
  16. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    SK Pang is correct regarding the clock. I ran your code with a MCP2558FD transceiver and Vector CANalyzer. Red lines are CLK_80MHz, black are CLK_24MHz.
  17. M

    CAN BUS Message Issue Transmiting with Teensy 4.1 and BAMOCAR d3 controller using FlexCAN_T4

    Nothing in your code stands out to me as incorrect. Is the bus properly terminated with 120ohms at each end? What do you see if you scope the TX and RX lines?
  18. M

    Teensy 4.1 CAN Bus Communication

    FWIW, you can operate CAN over very short distances without transceivers. It is absolutely critical that you use a 3.3v source instead of the 5v shown! https://www.mikrocontroller.net/attachment/28831/siemens_AP2921.pdf
  19. M

    FlexCAN_T4 how the the timestamp works

    Tomtom, that is odd that the one teensy isn't providing timestamps. The manual I referenced is just the microprocessor manual, specifically the chapter pertaining to FlexCAN. Here is the link: https://www.pjrc.com/teensy/IMXRT1060RM_rev3.pdf Feel free to post your code if you don't get to the...
  20. M

    FlexCAN_T4 how the the timestamp works

    According to the manual: The timer resets to 0 on Reset, wraps around at 0xFFFF, and increments with each bit interval, based on baudrate. So if the bus is running at 500kbps, a timer value of 1 represents 2us. During flexcan Freeze Mode, disable, and stop mode, the timer is not incremented.
  21. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    So canbus1.error() returns true, but once the errors print, there are none? Am I understanding this correctly? If so, can you post the canbus.error() function?
  22. M

    How to use CAN bus on Teensy 4.1, 4.0 and 3.2 ?

    While I generally agree with SK Pang, sometimes it's helpful to rule out physical layer/transceiver issues when troubleshooting. The typical tool used would be an oscilloscope or logic analyzer. There is a specific way you can connect multiple devices without transceivers, but it negates the...
  23. M

    Error receiving FlexCAN_T4 message

    If it's the board I think it is, there is a solder jumper on bottom labeled SJ7 that needs soldered on both boards. For the receiving code, you EnableFIFOInterrupt() but don't attach a function or service the interrupt. Try just commenting out that line.
  24. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Gary, based on looking at the library, try: Can.setFIFOFilter(Accept_All); Also, in case you weren't aware, Can.MailboxStatus(); is an easy way to see what's going on with the mailboxes and filters.
  25. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    I'm not familiar enough with implementing filters to comment, but I can confirm the FlexCAN hardware reserves MB0-MB7 when FIFO is enabled.
  26. M

    Teensy 4.1 FlexCAN_t4 ext ID setMBFilter() 18 bits only?

    Oh ok, I understand now. It's like the standard bits should always be set and then extended bits only if IDE==1. Since my uses of the library have never included extended frames with filters, I'm a out of my depth. I'd suggest posting an issue in the GitHub repo.
  27. M

    Teensy 4.1 FlexCAN_t4 ext ID setMBFilter() 18 bits only?

    The macro FLEXCAN_MB_ID_IDEXT() is used in conjunction with FLEXCAN_MB_ID_IDSTD(), which checks the 11 MSB of the extended ID. I haven't had a chance to look over your code yet
  28. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    In your program, when you want to check if errors exist, you should be able to do something like this: void loop() { ... some other code ... static uint32_t timeout = millis(); if ( millis() - timeout > 1000 ) { // Check for errors every 1000 ms CAN_error_t err; if...
  29. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Yeah, check out the structure typedef struct CAN_error_t in FlexCAN_T4.h and the function bool error(CAN_error_t &error, bool printDetails); in FlexCAN_T4.tpp
  30. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    There are a couple functions that could be considered. The CAN.reset() function resets the module, so you'd have to reconfigure every time you start logging. FLEXCAN_EnterFreezeMode() and FLEXCAN_ExitFreezeMode() might be useful, but I can't say if any other steps would be required to fully...
  31. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    The general idea is to replace your canRecieve function with code that just checks for IDs you want. If ID matches 0x361 (for example), grab the correct bytes and join them, then convert to physical units. Also, be sure to correct the baud rate in canInit. Here's an example of how to get...
  32. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    The termination resistor is built in to the chip? What chip are you referring to? Maybe check the datasheet for the purpose of the 8th transceiver pin you didn't mention. It sometimes is a 'silent' logic pin that prevents the transceiver from ack'ing or sending.
  33. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Sorry, I didn't read your post well enough. You say you interacted with the device in standard mode. Did you you successfully read messages sent by the device, or only write to the bus? Any chance you have some sort of oscilloscope to verify the bus activity?
  34. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Unless I'm missing something, it seems like your code is calling the send_std_can_message function as fast as the teensy can loop. This is certainly faster than a 1Mbps bus can transmit those frames, causing the teensy to flood the bus. Try putting your function in a timing conditional like: if...
  35. M

    Reading data from CAN bus volkswagen

    Mark, It seems like you may have figured this out the hard way, but the 2020 civic (and most late 2010's and newer vehicles) have a CAN gateway, which acts to route traffic between multiple busses, but also preventing easy access to the busses through the diagnostic port. When you are talking...
  36. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    If the msg data is 8 bytes long, msg.len is 8. Valid indices for msg.buf are 0:7. Your last loop iteration is then: msg.buf[7] = msg.buf[8]; which is out of range. Also, the first index msg.buf[0] is never assigned in your loop, unlike the line that worked.
  37. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Hi Samduino, The data lines from Teensy to CAN transceiver should be: CAN-RX --> CAN-RX | CAN-TX --> CAN-TX They don't cross over like a serial connection. The ACK bit is sent by the Teensy hardware, so without proper connection between Teensy transceiver, incoming frames cannot be received...
  38. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    If you are using a library like MegaCAN, which will parse the message IDs and data, fifo with interrupt probably makes the most sense.
  39. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Regarding adding the 'new data' flag, that's a good idea. If your msg unpacking routine is intensive, you might just copy your message from the interrupt to a global, set a 'new msg 1501' flag, then later unpack it in loop().
  40. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    No need to use can.events() if you are using mailbox interrupts. The interrupt will fire upon receipt of each message, and the received message object will be passed as an input arg. You can use one interrupt function for all MBs, check it's ID and process it accordingly. Or you can have...
  41. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    If you have a limited enough set of rx IDs, I find it easiest to just assign each its own mailbox using the mailbox filters. Unless you are logging data or receiving multi-frame data packets, you generally only concerned with the most recent data. In this case, you want to service the mailbox rx...
  42. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Do you have an oscilloscope or logic analyzer that you can use to verify signals? Viewing CANH/CANL and TX/RX signals would make quick work of troubleshooting.
  43. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    As @tonton81 mentioned, I've had success with both the TCAN330 and TCAN337. Aside from the special function pins and being powered by 3.3V, these transceivers function the as well as any others I've used with teensy 4/4.1.
  44. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Rayan, just an idea: Can you record a single frame on your scope, with the probes on the receiving node's RX and TX signals? Does RX look like a proper CAN frame? Is TX quiet, except for a single ACK bit? Can you post a picture of the recording?
  45. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Do you have proper bus termination resistors? Combined resistance between CANH and CANL should be 60 ohms. Also, can you clarify what the leds are doing with the Rs pin? If it isn't strongly pulled to ground, it's either in some slope control mode or low power mode. Maybe try temporarily...
  46. M

    WS2812 Logic Level Converter Recommendation

    I've had mixed results with this level converter circuit driving ws2812, as the low to high transition speed is limited by the 10k pull-up. Or I could have been doing something else wrong, I suppose.
  47. M

    FlexCAN_T4 - FlexCAN for Teensy 4

    Teensyduino doesn't include the latest FlexCAN_T4 library, so make sure you get it from here: https://github.com/tonton81/FlexCAN_T4 When enableInterrupts is set in setup, events() should be removed from the loop.
  48. M

    Forwarding with FlexCAN_T4 and losing messages

    Glad you got it working. I had been experiencing related issues prior to the FlexCAN_T4 commit on June 20 (AKA Update7), so my money is on that. Tony - that commit barely missed inclusion into Teensyduino 1.53 and doesn't seem to be on the list for 1.54. Are updated libraries automatically...
  49. M

    Forwarding with FlexCAN_T4 and losing messages

    Yep, that's all.
  50. M

    Forwarding with FlexCAN_T4 and losing messages

    Regarding the RX mailboxes: both due and flexcan use 7 RX mailboxes by default. If your message handling is fast enough, only 1 RX mailbox will be used at a time, and nothing can get out of order. If the due could do this fast enough, the T4 should be fine. If you want a more robust solution...
Back
Top