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

PeMar

New member
Hello! I am trying to work with the CAN Bus protocol for a formula student team. We are using teensy 4.1 as the master attached to CAN tranceiver ISO1050 and the BAMOCAR d3 controller as the slave. More specifically we are trying to send to the controller a command for the torque control. As a reference, I used the "Example 5" of the attached document on page 17/28. The COB ID of BAMOCAR d3 is 0x201 for receiving and the length of the message should be 3 bytes. Also in the code i use the FlexCAN_T4 library so I do not have to specify the RX/TX pins of teensy 4.1 (as far as i have connected teensy's CAN1 which are pins 22 and 23). However, when scoping the CANH/CANL of the trenceiver it seems like there are no data being transmitted. All the connections between teensy and the tranceiver seem correct so I suppose there is an isuue with the code I have attached down below. I will appreciate your help and excuse me for any profound mistakes!

#include <FlexCAN_T4.h>

FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;

void setup() {
Serial.begin(9600);
while (!Serial);

can1.begin();
can1.setBaudRate(500000); // 500kbps baud rate
}

void loop() {
CAN_message_t msgTransmit;
msgTransmit.id = 0x201; // receive address COB ID
msgTransmit.len = 3; // DLC
msgTransmit.buf[0] = 0x90; // torque register

// Set torque command value to 50%
int16_t torqueValue = 16380; // 50% of maximum torque
// Little Endian format
msgTransmit.buf[1] = torqueValue >> 8; // Low byte
msgTransmit.buf[2] = torqueValue & 0xFF; // High byte

can1.write(msgTransmit);
delay(100);
}
 

Attachments

  • CAN-Complete_English.pdf
    722.5 KB · Views: 203
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?
 
Have you tried swapping the RX and TX lines to the transceiver? Some transceiver boards have a confusing way to indicate what the RX and TX connections are.

Paul
 
On the ISO1050 transceiver, have you applied the correct voltage on Vcc1 and Vcc2 ?
Post a photo of your setup.
 
Back
Top