CAN-BUS Shield V2.0 // Tmotors AK80-64

dragos243

New member
Hello everyone,

I'm working on a project where I'm trying to control a motor using an Arduino Mega 2560 board, a CAN-BUS Shield V2.0 from SEEED, and an Elegoo joystick. I'm new to Arduino and electronics, so any help or advice would be greatly appreciated.

For starters, I'm using the joystick to send signals to the Arduino which then sends commands to the motor via the CAN-BUS Shield. However, I'm having trouble getting the motor to move, even though I'm not getting any errors in my code.

Here's my setup:

Arduino Mega 2560 board
CAN-BUS Shield V2.0 from SEEED
Elegoo joystick
Motor
And here's my code:

Code:
#include <SPI.h>
#include <mcp_can.h>

MCP_CAN CAN(10);

void setup() {
  Serial.begin(9600);
  
  while (CAN_OK != CAN.begin(CAN_1000KBPS)) {
    Serial.println("CAN BUS Shield init fail");
    Serial.println(" Init CAN BUS Shield again");
    delay(100);
  }
  
  Serial.println("CAN BUS Shield init ok!");
}

void loop() {
  if (Serial.available() > 0) {
    int joystickValue = Serial.read();
    
    if (joystickValue == 'u') {
      CAN.sendMsgBuf(0x001, 0, 8, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00});
      Serial.println("Joystick moved up");
    } else if (joystickValue == 'd') {
      CAN.sendMsgBuf(0x001, 0, 8, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00});
      Serial.println("Joystick moved down");
    } else {
      Serial.println("Invalid joystick command");
    }
  }
}

I'm currently using the Serial monitor to test the joystick commands, but I'm not getting any response from the motor. I'm not sure if there's something wrong with my code or my hardware setup.

photo_2023-04-25_15-24-07.jpg

If anyone has any suggestions or advice on how to troubleshoot this issue, I would greatly appreciate it.

Thank you!
 
Suggestion #1 - move to a Teesny 4.0 or 4.1 (this is a Teensy/PJRC forum after all..)
It has a built in CAN controller so all you need is a transceiver which I believe will be far easier to debug than the SPI based CAN shield.
It’s also wayyyy faster than the Arduino.. so much headroom for more application code and complex stuff.

Other than that, I don’t have experience with CAN controlled motors, so I will let someone else chime in!
 
1000kbps with no terminations? that'll never work. MAYBE at 125kbps, MAYBE, but definately nothing will work at >125kbps without terminations.
 
Back
Top