Hi,
This could be something daft, it likely is.. I'm fairly new to this stuff.
I have a car ECU powered by my bench PSU, this provides a CAN stream at 1mbd which I am successfully receiving via a Waveshare SN65HVD230 (Chinese copy, I have an original Waveshare product en-route from Amazon).
My project is wired as follows
SN65 on the left, Teensy 3.2 on the right
TX-> Pin 3 (Purple Wire)
RX-> Pin 4 (Blue Wire)
GND-> GND (Black to Brown Wire)
3.3v-> 3.3v (Green to Red Wire)
The teensy powered from USB.
The CAN stream I'm receiving sends a total of 8 data blocks with ID's: 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007. I'm mostly receiving the first 2000 block, and every now and again, the second 2001 block. Until I physically touch the RX and TX wires from the Transveiver to the Teensy, and then I get a proper data stream including all of the above data blocks.
I'm puzzled as to why me taking a hold of the wires makes this work, but when I'm not touching the wires it seems to repeat?
Hopefully someone has a suggestion.
Thanks
Here's a photo of my project
Here's the sketch I'm using
This could be something daft, it likely is.. I'm fairly new to this stuff.
I have a car ECU powered by my bench PSU, this provides a CAN stream at 1mbd which I am successfully receiving via a Waveshare SN65HVD230 (Chinese copy, I have an original Waveshare product en-route from Amazon).
My project is wired as follows
SN65 on the left, Teensy 3.2 on the right
TX-> Pin 3 (Purple Wire)
RX-> Pin 4 (Blue Wire)
GND-> GND (Black to Brown Wire)
3.3v-> 3.3v (Green to Red Wire)
The teensy powered from USB.
The CAN stream I'm receiving sends a total of 8 data blocks with ID's: 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007. I'm mostly receiving the first 2000 block, and every now and again, the second 2001 block. Until I physically touch the RX and TX wires from the Transveiver to the Teensy, and then I get a proper data stream including all of the above data blocks.
I'm puzzled as to why me taking a hold of the wires makes this work, but when I'm not touching the wires it seems to repeat?
Hopefully someone has a suggestion.
Thanks
Here's a photo of my project
Here's the sketch I'm using
Code:
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
int led = 13;
FlexCAN CANbus(1000000);
static CAN_message_t rxmsg;
static uint8_t hex[17] = "0123456789abcdef";
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
Serial.println(F("Teensy 3.2 CAN Test"));
CANbus.begin();
pinMode(led, OUTPUT);
digitalWrite(led, 1);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
while (CANbus.read(rxmsg)) {
// 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
if (rxmsg.len >= 1) {
text = String(text + " DATA: ");
}
// construct string for available bytes
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 FIFO
digitalWrite(led, 1);
}
}