Teensy 3.2 CAN rtr/ACK

This forum is for the discussion of other projects on Megasquirt/Microsquirt hardware that don't fit into any of the other forums

Moderators: jsmcortina, muythaibxr

Post Reply
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Teensy 3.2 CAN rtr/ACK

Post by ol boy »

I'm playing with a Teensy3.2 with MCP2551 transceiver to a micosquirt module. I've found several forks of FlexCAN over the past few days. I have a 4 channel o'scope and a systec USB/CAN widget that allows me to see what happening on the bus. When I set the USB/CAN to listen only, the only message seen is 0x5E8 (1512). It comes in at 5000hz. I see the ACK but it seems to miss the last bit by 5us. When I enable the USB/CAN as an active player everything works as it should, ACK happens right on the last bit. I can see the 4 CAN messages from the micro at 20hz. The USB/CAN also shows all 4 messages and their values.

Is this a slope control hardware problem or a software settings issue? HELP! Yes I have a 120 ohm resistor at the CAN bus point at the MCP2551. I can measure 59ish ohms across the bus.

Thanks Ryan

Code: Select all

#include <FlexCAN.h>
#include <kinetis_flexcan.h>

// -------------------------------------------------------------
// CANlisten for Teensy 3.1
// by kjn
//
// This test enables the CAN interface on the teensy and prints all recieved packets
// to the serial console. The RX FIFO buffer may overrun at high bus utilisation
// states. This is untested.



// Specify CAN Baudrate. Currently 125k, 250k, 500k, 1M are supported in teensydrino 1.20
int baud = 500000;

int led = 13;
FlexCAN CANbus(baud);
static CAN_message_t rxmsg; 
static CAN_filter_t filter; 
static CAN_filter_t mask;

void setup(void)
{
  
  Serial.begin(115200);
  while (!Serial) ; // wait for Arduino Serial Monitor
  Serial.println("Teensy 3.1 CANlisten Example"); 
  
  //boolean result = CANbus.begin(); -- Currently .begin object doesn't return state of bus
  //Serial.print("CAN begin successful: ");
  //Serial.println(result ? "YES" : "NO");
  filter.rtr = 1;
  filter.id = 0;
  filter.ext = 0;
  mask.rtr = 1;
  mask.id = 0;
  mask.ext = 0;
  CANbus.begin(mask);
  
  //Light on to indicate on-bus state
  pinMode(led, OUTPUT);
  digitalWrite(led, 1);
  
}

void loop(void){
  
//Poll Rx FIFO
while ( CANbus.read(rxmsg) ) {
//when message available

//light off to indicate FIFO is not being polled
digitalWrite(led, 0);

//construct string  
String text = "ID: 0x";
text = String(text + String(rxmsg.id, HEX));
text = String(text + " DLC: ");
text = String(text + String(rxmsg.len, HEX));

//check if DLC is >0 append string as required
if (rxmsg.len >= 1)
{
  text = String(text + " DATA: ");
}
  
//construct string for available bytes (trunctate to DLC to avoid reading garbage)
for( int idx=0; idx<rxmsg.len; ++idx ) 
{
   text = String(text + String(rxmsg.buf[idx],HEX));
   text = String(text + " ");
}
  
//print result
Serial.println(text);

//LED back on to indicate watching Rx FIFO  
digitalWrite(led, 1); 
} 

}

306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

Hey there, I got your PM, and you are right since I did my little projects quite a few CAN forks have come about. But before diving in to that can you post your MSQ?
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

Sure will, I'll attach it in the morning. It's just the default settings that get loaded during a firmware update. I'll I did was enable the can broadcast and the dash broadcast to auto.

In the morning I'm going to try adding a 10k pull up on the TX pins. Found a thread where if the TX pin never sees 3.8v or higher the mcp2551 goes into dormant mode. The teensy3.2 can't hold the line that high...

What's your thoughts?

Sent from my SM-G920V using Tapatalk
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

Do you get anything on the Teensy Serial port monitor? Also if I remember correctly you'll need to move the Serial port monitor over to Serial port 2 in the IDE.
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

With the systec USB/CAN hooked up I get data from teensy serial monitor. With out the systec I can see on the o'scope the same message 1512 being sent out at around 5000hz. It seems that the micro never sees the ACK from teensy and the teensy doesn't does not display any data over the serial monitor. I'm thinking the systec is able to send an ACK over the bus which satisfies the micro which then sends the next message.

The 5 volt pull up didn't work on the MCP2551 TX pin. Seems the 3.3V out from the teensy doesn't pull up easily. I might rig up a "level shifter"...?
TeensyCAN.msq
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

What do you have creating engine data to the Micro?
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

Nothing. Why does the micro need an engine attached to it to produce a CAN message?

Sent from my SM-G920V using Tapatalk
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

ol boy wrote:Nothing. Why does the micro need an engine attached to it to produce a CAN message?

Sent from my SM-G920V using Tapatalk
Never said it it does, but I didn't have to go through any sort of mods to make mine work. I had stim to microsquirt then the transciever to the Teensy, that's it. I was just thinking if you can change data outputs you can generate something other than the same repeating info.

1512 is the default ID so thats all good. You might go in to the tune and change up the transmit rate, IIRC when I cranked it up really high I did have some issues.
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

Which transceiver are you using?

Sent from my SM-G920V using Tapatalk
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

ol boy wrote:Which transceiver are you using?

Sent from my SM-G920V using Tapatalk
This one

https://www.amazon.com/gp/product/B00KM ... UTF8&psc=1
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

Okay. I'll order one of those and try again. Thanks.

Sent from my SM-G920V using Tapatalk
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
ol boy
Super MS/Extra'er
Posts: 1532
Joined: Mon Sep 10, 2007 3:06 am
Location: Tucson, Az

Re: Teensy 3.2 CAN rtr/ACK

Post by ol boy »

Finally got around to testing with the amazon linked 3.3V transceiver. It works!!!.. I can see the CAN messages displayed over the the serial moniter and they follow the expected results from TS. Next step is SD car logging!

Thanks Ryan
306 SBFord, Torquer II EFI intake, 60 lbs injectors, 8 LS2 coils, VS Racing 7668 turbo, 4R70W, MS3x fw1.4 w/built in trans controller.
Raymond_B
Super MS/Extra'er
Posts: 1394
Joined: Thu Mar 06, 2014 2:17 pm
Location: Texas
Contact:

Re: Teensy 3.2 CAN rtr/ACK

Post by Raymond_B »

Awesome!
1995 Ford Lightning. Dart based 427 Windsor, Novi 2000, full sequential, E-85, etc. MS3X/v3.57
http://www.buildpics.org/
Post Reply