I am trying to create a datalogging box for an OBD2 port on a car and I can not get any successful data reads to come through the FlexCAN library. I have stripped everything out of the design and am running a bare bones test setup and still can't get anything to come into the Teensy. I can successfully transmit data onto the bus, but can not pull it off. I am on my second transceiver chip and still no luck.I have also tried many example codes and written a sample myself. Any help that you could provide would be (greatly!) appreciated. I am nearing my wits end. Thank you!
Details:
Two Teensy 3.2s on a dedicateCAN Bus
Using MCP2562 Transceiver chip http://ww1.microchip.com/downloads/en/DeviceDoc/20005167C.pdf
Have a smt 120 Ohm resistor bridging the CAN H and L terminals at each transceiver
MCP2562 VDD pin wired to the Vsupply on each teensy
MCP2562 VIO pin wired to 3.3V on each Teensy
MCP2562 STNDBY pin pulled to ground (directly, no resistor)
Running the transmitting node (code below) powered by a USB port that is not host on a computer (charging port)
Running the receiving node via USB on my PC
Teensy pin 3 > MCP pin 1
Teensy pin 4 > MCP pin 4
Sending node code (example taken from here: http://webcache.googleusercontent.com/search?q=cache:http://rummanwaqar.com/can-bus-with-teensy-3-1/)
Receiving code:
Scope output:
Channel 1: Input to CAN TX on sending MCP2562
Channel 2: CAN HI
Channel 3: CAN LO
Channel 4: Pin 4 at receiving Teensy
Details:
Two Teensy 3.2s on a dedicateCAN Bus
Using MCP2562 Transceiver chip http://ww1.microchip.com/downloads/en/DeviceDoc/20005167C.pdf
Have a smt 120 Ohm resistor bridging the CAN H and L terminals at each transceiver
MCP2562 VDD pin wired to the Vsupply on each teensy
MCP2562 VIO pin wired to 3.3V on each Teensy
MCP2562 STNDBY pin pulled to ground (directly, no resistor)
Running the transmitting node (code below) powered by a USB port that is not host on a computer (charging port)
Running the receiving node via USB on my PC
Teensy pin 3 > MCP pin 1
Teensy pin 4 > MCP pin 4
Sending node code (example taken from here: http://webcache.googleusercontent.com/search?q=cache:http://rummanwaqar.com/can-bus-with-teensy-3-1/)
Code:
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANTransmitter(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANTransmitter.begin();
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Transmitter Initialized");
}
void loop() {
Serial.print("Sending: ");
msg.id = 0x222;
msg.len = 2;
for(int i=0; i<msg.len; i++) {
msg.buf[i] = '0' + i;
Serial.print(msg.buf[i]); Serial.print(" ");
}
Serial.println("");
CANTransmitter.write(msg);
digitalWrite(led, !digitalRead(led));
delay(500);
}
Receiving code:
Code:
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
// create CAN object
FlexCAN CANReceiver(500000);
static CAN_message_t msg;
void setup() {
// init CAN bus
CANReceiver.begin();
pinMode(led, OUTPUT);
delay(1000);
Serial.println("CAN Receiver Initialized");
}
void loop() {
while( CANReceiver.read(msg)) {
// toggle LEDs
digitalWrite(led, !digitalRead(led));
Serial.print("Receiving: ");
for(int i=0; i<msg.len; i++) {
Serial.print(msg.buf[i]); Serial.print(" ");
}
Serial.println("");
}
}
Scope output:
Channel 1: Input to CAN TX on sending MCP2562
Channel 2: CAN HI
Channel 3: CAN LO
Channel 4: Pin 4 at receiving Teensy