cybergear_m5 Library

repository·main·Indexed 41 days ago

https://github.com/project-sternbergia/cybergear_m5

A library for M5Stack (ESP32) devices to interface with Xiaomi Cybergear motors via CAN bus. It supports hardware configurations including MCP2515, PWRCAN, and CAN Transceiver Units, and provides examples for control mode testing and leader-follower bilateral control.

Tokens
646
Snippets
1
Records
4
Agent score
50%

What's inside cybergear_m5

  1. Hardware requirements for cybergear_m5

    main

    This library is designed for the M5Stack Basic V2.7 (ESP32) to interface with Xiaomi Cybergear motors via CAN bus. There are three primary hardware configurations supported:

    1. MCP2515 Configuration

    • M5Stack Basic V2.7
    • M5Stack Commu module [M001]
    • MCP2515 CAN controller
    • XT30(2+2)-F connectors and Grove Cables

    2. PWRCAN Configuration

    • M5Stack Basic V2.7
    • PWRCAN 13.2 Module (Isolated 2-Ch CAN & 1-Ch RS485)

    3. CAN Transceiver Unit Configuration

    • M5Stack Basic V2.7
    • LAN Module W5500 with PoE V12 OR CANBus Unit (CA-IS3050G)
    • XT30(2+2)-F connectors and Grove Cables
  2. Setup the cybergear_m5 library in Arduino IDE

    main

    To use this library, you must clone the library itself and several required dependencies into your Arduino libraries directory.

    Required Dependencies:

    • MCP_CAN_lib
    • RingBuffer
    • arduino-CAN (ESP32 CAN library)
    • cybergear_m5

    Steps:

    1. Navigate to your Arduino libraries folder.
    2. Clone the repositories listed below.
    3. Open the desired example file from the cybergear_m5/examples/ directory in the Arduino IDE.
    4. If you intend to use the ESP32_CAN library instead of MCP_CAN, ensure you comment out the relevant lines in the example file as instructed in the source code.
    5. Build and upload the firmware to your M5Stack device.
    cd ~/Arduino/libraries
    git clone https://github.com/coryjfowler/MCP_CAN_lib.git
    git clone https://github.com/Locoduino/RingBuffer.git
    git clone git@github.com:project-sternbergia/arduino-CAN.git
    git clone https://github.com/project-sternbergia/cybergear_m5.git
  3. Use the control_mode_example sample

    main

    The control_mode_example.ino allows you to test and observe Xiaomi Cybergear behavior using the M5Stack buttons:

    • Middle Button: Cycles through Control Modes (Position Mode $\rightarrow$ Speed Mode $\rightarrow$ Current Mode).
    • Right Button: Increases the control value.
    • Left Button: Decreases the control value.
  4. Use the cybergear_bilateral sample for leader-follower testing

    main

    The cybergear_bilateral.ino example demonstrates bilateral control using two Cybergear motors configured as a leader and a follower.

    Setup Requirements: Before running the example, you must manually change the CAN IDs of your Cybergear motors to the following:

    • Leader Cybergear ID: 0x7F
    • Follower Cybergear ID: 0x7E

    Once IDs are set, upload the cybergear_bilateral.ino example to your M5Stack via the Arduino IDE.