Connection of Leonardo with Seed CanOpen Shield

Hello there, I am trying to make a master for 2 slave drive controllers from nanotec using Seeed Bus shield v2, the drives of nanotec are the CL-4-e series and they communicate via can open. Does anyone have experience trying to make canopen communication with seeed bus shield or do i need another board,
These are the motor drives that i have https://en.nanotec.com/fileadmin/files/Handbuecher/Kurzanleitungen/EN/cl4e-canopen-usb-modbus-rtu-quick-guide.pdf?1656012586
And this is the bus shield : https://www.seeedstudio.com/CAN-BUS-Shield-V2.html

At the moment im trying to setup the communication as it is said in the manual of nanotec but the bytes that i am getting back are not the ones that i should be getting:

This is the code as i have at the moment:

/*
 * This is an example of sending and receiving (FD) on its own,
 * connect two channels to each other using jumpers.
 */

#include <SPI.h>
#include "mcp2518fd_can.h"

// Set SPI CS Pin according to your hardware
// For Wio Terminal w/ MCP2518FD RPi Hat:
// Channel 0 SPI_CS Pin: BCM 8
// Channel 1 SPI_CS Pin: BCM 7
// Interupt Pin: BCM25
// *****************************************
// For Arduino MCP2515 Hat:
// SPI_CS Pin: D9

const int SPI_CS_PIN_SEND = 9;
const int SPI_CS_PIN_RECEIVE = 2;

mcp2518fd CAN_SEND(SPI_CS_PIN_SEND);
mcp2518fd CAN_RECEIVE(SPI_CS_PIN_RECEIVE);

// CANFD could carry data up to 64 bytes
#define MAX_DATA_SIZE 8

void setup() {
    SERIAL_PORT_MONITOR.begin(115200);
    while (!SERIAL_PORT_MONITOR) {} // wait for Serial

    /*
     * To compatible with MCP2515 API,
     * default mode is CAN_CLASSIC_MODE
     * Now set to CANFD mode.
     */
    CAN_SEND.setMode(CAN_NORMAL_MODE);
    CAN_RECEIVE.setMode(CAN_NORMAL_MODE);
    
    if (CAN_SEND.begin(CAN_500K_1M) != 0 || CAN_RECEIVE.begin(CAN_500K_1M) != 0) {
        SERIAL_PORT_MONITOR.println("CAN-BUS initiliased error!");
        while (1);
    }
    byte send_mode = CAN_SEND.getMode();
    byte receive_mode = CAN_RECEIVE.getMode();
    SERIAL_PORT_MONITOR.print("CAN BUS Send Mode = "); SERIAL_PORT_MONITOR.println(send_mode);
    SERIAL_PORT_MONITOR.print("CAN BUS Receive Mode = "); SERIAL_PORT_MONITOR.println(receive_mode);
    SERIAL_PORT_MONITOR.println("CAN BUS Shield init ok!");
}

unsigned char stmp[MAX_DATA_SIZE] = {40, 41, 60, 00, 00, 00, 00, 00};
unsigned char len = 0;
unsigned char buf[MAX_DATA_SIZE];

void loop() {
    // send data:  id = 0x00, standrad frame, data len = 64, stmp: data buf
    stmp[MAX_DATA_SIZE - 1] = stmp[MAX_DATA_SIZE - 1] + 1;
    if (stmp[MAX_DATA_SIZE - 1] == 100) {
        stmp[MAX_DATA_SIZE - 1] = 0;

        stmp[MAX_DATA_SIZE - 2] = stmp[MAX_DATA_SIZE - 2] + 1;
        if (stmp[MAX_DATA_SIZE - 2] == 100) {
            stmp[MAX_DATA_SIZE - 2] = 0;

            stmp[MAX_DATA_SIZE - 3] = stmp[MAX_DATA_SIZE - 3] + 1;
        }
    }

    CAN_SEND.sendMsgBuf(0x6041, 0, CANFD::len2dlc(MAX_DATA_SIZE), stmp);
    delay(100);                       // send data per 100ms
    SERIAL_PORT_MONITOR.println("CAN BUS sendMsgBuf ok!");

    // ---------------------
    if (CAN_MSGAVAIL == CAN_RECEIVE.checkReceive()) {
        // read data,  len: data length, buf: data buf
        SERIAL_PORT_MONITOR.println("checkReceive");
        CAN_RECEIVE.readMsgBuf(&len, buf);
        // print the data
        for (int i = 0; i < len; i++) {
            SERIAL_PORT_MONITOR.print(buf[i]);
            SERIAL_PORT_MONITOR.print(' ');
        }
        SERIAL_PORT_MONITOR.println();
    }
    SERIAL_PORT_MONITOR.println("---LOOP END---");
    delay(10000);
}

Any feedback is appriciated

The CAN bus shield only provides the transport layer and doesn't know anything about CANopen.
CANopen is a communications layer that runs on the microcontroller.

Have a look on Github for a CANopen library. If you cannot find anything suitable then your options are to either purchase a commercial library or write your own.
CANopen is complex so check to see if the library memory footprint is compatible with your Arduino.

Using the Modbus interface may be an easier option as there are free libraries available.

Hello @mikb55 thank you for your answer, since it seems that the setup with arduino leonardo and bus shield is okay could you suggest a commercial library or an open source one, if i manage to make the steps below work I can write the rest of the library by myself, I just need the communication to be as it should. This is what needs to be done in order to make this work
image

Is this a student project?

The 40, 41, 60, 00, 00, 00, 00, 00 in the datasheet probably refers to hex values, whereas your code is sending decimal values.

The expected reply is shown in hex as 4B 41 60 00 XX XX 00 00, but you are displaying the bytes in decimal.

Hey there, kind of a student project, im an enginnering student but I am also planing to upgrade the task that the professor gave, for a nicer project but i cannot afford a PLC yet to do that so i went with arduino. I had tried to send and receive hex values also but it gave the same output just in hex.

I think my mistake was the node where i am sending the data, i will try again later today to change the node since i missed the written instruction that the node shall be 127 as the default.
Here you can see the 4 steps in total, also will give it a shot to the canOpen master library in github and get back to you with the info, if you have any other suggestion please share it.
Thanks a lot in advance.

Your code looks like it was based on the send_receiveFD.ino example, however you posted a link to the MCP2515 hardware.
The Seeed studio examples are confusing. The send_receive.ino file looks like it was originally designed for the MCP2515 but then modified for the MCP2518 even through there is a sub directory for the FD demos.

Suggest starting with the wiki page.

Hold up a sec, so my example was based on send_receive.ino you have the link here

But i think it wont matter if it is designed for MCP2515 because from the wiki.seeedstudio.com that you sent there you can see that it is using MCP2515 not the MCP2518, I have read that page a couple of times actually, I still think that i messed up the node-ID only. Why were you mentioning MCP2518 by the way im curios where di that come out ?

Your code has the line

#include "mcp2518fd_can.h"

The wiki page has

#include "mcp2515_can.h"

You are right, will fix try and come back with an update. Thanks a lot