Hey guys,
I have recently bought a BLDC actuator that uses CAN communication. Its working perfectly fine using an MCP2515 CAN module with an Arduino Mega. However, due to my application, I require it to work with Teensy 4.0 as it has a greater computational power.
Since Teensy 4.0 has a built in CAN controller therefore, I decided to use THREE different CAN transceiver modules with it ( including TJA1050, MCP2551 and SNHVD230 ) . Unfortunately, I have been unable to make the motor run. The motor uses an MIT mini cheetah driver which requires a certain command to enable its motor mode. Thats all I have been trying to implement using teensy so far, not even anything complex.
Could someone please help me out?
The pin configuration for Teensy 4.0 with SN65hvd230 is mentioned below:
CAN transceiver VCC -----> 3V on Teensy 4.0
GND--->GND on the Teensy.
CAN TX (D): Connected to the Teensy's CAN TX pin, which is pin 22.
CAN RX (R): Connected to the Teensy's CAN RX pin, which is pin 23.
CANH and CANL of tranceiver connected to the CANH/CANL of the motor.
Im using FlexCAN_T4 library. And the code is as mentioned below:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
void setup() {
Serial.begin(115200);
while (!Serial);
can1.begin();
can1.setBaudRate(1000000); // Set baud rate to 1Mbps(motor requirement)
Serial.println("CAN bus initialized.");
}
void loop() {
CAN_message_t msg;
// Define the message
msg.id = 0x00B; // CAN ID
msg.len = 8; // Data length code (8 bytes)
msg.buf[0] = 0xFF;
msg.buf[1] = 0xFF;
msg.buf[2] = 0xFF;
msg.buf[3] = 0xFF;
msg.buf[4] = 0xFF;
msg.buf[5] = 0xFF;
msg.buf[6] = 0xFF;
msg.buf[7] = 0xFC;
// Send the message
if (can1.write(msg)) {
Serial.println("Message sent successfully");
} else {
Serial.println("Error sending message");
}
delay(1000); // Wait for 1s
}
Please help me out. Its very important