English
English
简体中文
日本語

Product Guides

Industrial Control & Measurement

Air Quality

PowerHub

StamPLC

VAMeter

Module13.2 PPS

Unit RollerCAN

Display & Interaction

Tab5 Keyboard

Chain DualKey

Robotics & Maker Projects

Atom Printer

BalaC Plus

Faces Kit Gameboy

RoverC & JoyC

StampFly & Atom Joystick

Unit Roller485/RollerCAN Motor Position Calibration

Encoder Calibration:
The internal magnetic encoder of the Unit Roller485/RollerCAN is factory-calibrated. If the motor is disassembled under special circumstances, it may fail to start properly. In this case, refer to the following guide to recalibrate the motor encoder.

Preparation

1.Press and hold the bottom button A, then connect the Grove cable to power the device.

2.Enter the configuration menu, and switch options by rotating the motor. Set the device to I2C mode.

3.Connect the Unit Roller485/RollerCAN to the M5 controller and follow the instructions below to upload the calibration program.

Calibration Procedure

  • Upload the calibration programM5Unit-Roller - encoder_calibrationto your main controller, If using another controller, adjust the GPIO pins inRollerI2C.begin(&Wire, 0x64, SDA, SCL, 400000)as needed.
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
/*
 *SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 *
 *SPDX-License-Identifier: MIT
 */
#include "unit_rolleri2c.hpp"
#include <M5Unified.h>

#define ROLLER_CALIBRATION_DELAY 10000

UnitRollerI2C RollerI2C;  // Create a UNIT_ROLLERI2C object

uint8_t is_roller_valid             = 0;
uint8_t is_roller_calibrated        = 0;
uint32_t roller_start_delay_counter = 0;

void setup()
{
    M5.begin();
    if (RollerI2C.begin(&Wire, 0x64, 21, 22, 400000)) {
        is_roller_valid            = 1;
        roller_start_delay_counter = millis();
    }
}

void loop()
{
    if (is_roller_valid) {
        if (millis() - roller_start_delay_counter < ROLLER_CALIBRATION_DELAY) {
            printf("Calibration will start after %dS\n",
                   (roller_start_delay_counter - (millis() - roller_start_delay_counter)) / 1000);
        } else {
            if (!is_roller_calibrated) {
                printf("Start encoder calibration\n");
                RollerI2C.setOutput(0);
                delay(100);
                RollerI2C.startAngleCal();
                delay(100);
                printf("Calibrationing...\n");
                while (RollerI2C.getCalBusyStatus()) {
                    printf("Calibrationing...\n");
                }
                RollerI2C.updateAngleCal();
                printf("Encoder calibration done\n");
                delay(500);
                RollerI2C.setOutput(0);
                RollerI2C.setMode(ROLLER_MODE_SPEED);
                RollerI2C.setSpeed(240000);
                RollerI2C.setSpeedMaxCurrent(100000);
                RollerI2C.setOutput(1);
                is_roller_calibrated = 1;
            }
        }
    } else {
        printf("No roller485 dectected\n");
    }
}
Page Tools
PDF
On This Page