Skip to main content

CAN Bus

In this tutorial, we will explore how to prepare the Aotenjo One board for CAN Bus communication and run closed loop angle control.

Prerequisites

In this tutorial, the following hardware is used:

  • Aotenjo One Board
    MCU: STM32G431CBU6
    Version: Aotenjo One V1.4
  • Diametrically magnetized disc magnet (included with Aotenjo One)
  • ST-LINK V2 Clone
  • BlackPill STM32 Board
  • BE4108 75T Gimbal Motor
  • Power Supply (12V)
  • Soldering Kit

You need a ST-LINK V2 Clone to upload the firmware to the board. You can purchase a cheap clone ST-LINK V2 under $5.

CAN Bus Connection

Aotenjo One communicates via CAN Bus, allowing you to control multiple Aotenjo One boards using just four wires: CAN_H, CAN_L, VCC, and GND.

Keep in mind that a CAN Bus requires termination resistors at both ends of the network to prevent signal reflections.

In the setup shown above, the main CAN hub — Aotenjo Master — includes a built-in termination resistor. Therefore, you only need to enable termination on the last Aotenjo One board in the chain (e.g., the M0 unit) by soldering the termination jumper located on the top side of the board, as shown in the image below.

Installation

VScode with PlatformIO

You can install PlatformIO from the VSCode extension marketplace.

STM32CubeProgrammer

You need this to flash the firmware to the board.

Clone the repository

git clone https://github.com/aotenjo-xyz/one.git
cd one

Quickstart

  1. Place the magnet on the motor shaft.

    Magnet on Motor Shaft

  2. Connect the Aotenjo One board to the ST-LINK V2 programmer.

    ST-LINK V2 <-> Aotenjo One
    3.3V <---> 3.3V
    GND <---> GND
    SWDIO <---> SWDIO
    SWCLK <---> SWCLK
    RST <---> NRST
    info

    Unlike the blackpill board, you need to connect the NRST pin to the ST-LINK V2 programmer for STM32G4 series. Alternatively, you can press and hold the NRST button on the Aotenjo One board during the upload process to achieve the same effect.

  3. Connect the ST-LINK V2 programmer to your computer.

  4. Open the project folder in VSCode.

  5. Click on the PlatformIO tab on the left sidebar and click on the Upload button to upload the firmware to the board.

Now you are ready to control the motor using CAN Bus communication!

For the next steps, please refer to the Aotenjo Master CAN Bus tutorial.