Motion

Atomic Motion Base is a servo and DC motor driver designed specifically for the ATOM series controllers. It integrates an STM32 control chip internally and uses I2C communication for control. Atomic Motion Base provides 4 servo channels and 2 DC motor interfaces, offering convenience for scenarios that require control of multiple servos or motor drivers, such as multi-axis servo robotic arms or small car motor control.

Support the following products:

Motion

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import *
 9from base import Motion
10
11
12i2c0 = None
13motion = None
14
15
16def setup():
17    global i2c0, motion
18
19    M5.begin()
20    i2c0 = I2C(0, scl=Pin(39), sda=Pin(38), freq=100000)
21    motion = Motion(i2c0, 0x38)
22    motion.set_servo_angle(1, 70)
23    motion.set_motor_speed(1, 46)
24    print(motion.get_servo_angle(1))
25
26
27def loop():
28    global i2c0, motion
29    M5.update()
30
31
32if __name__ == "__main__":
33    try:
34        setup()
35        while True:
36            loop()
37    except (Exception, KeyboardInterrupt) as e:
38        try:
39            from utility import print_error_msg
40
41            print_error_msg(e)
42        except ImportError:
43            print("please update to latest firmware")

UIFLOW2 Example:

example.png

atoms3_lite_motion_base_example.m5f2

class Motion

Constructors

Motion(i2c, address)

Initialize the Servo8.

  • i2c: I2C port to use.

  • address: I2C address of the servo8.

UIFLOW2:

__init__.png

Methods

Motion.get_servo_angle(ch)

Get the angle of the servo.

  • ch: Servo channel (1 to 4).

UIFLOW2:

get_servo_angle.png

Motion.set_servo_angle(ch, angle)

Set the angle of the servo.

  • ch: Servo channel (1 to 4).

  • angle: Angle of the servo (0 to 180).

UIFLOW2:

set_servo_angle.png

Motion.get_servo_pulse(ch)

Get the pulse width of the servo.

  • ch: Servo channel (1 to 4).

UIFLOW2:

get_servo_pulse.png

Motion.write_servo_pulse(ch, pulse)

Set the pulse width of the servo.

  • ch: Servo channel (1 to 4).

  • pulse: Pulse width of the servo (500 to 2500).

UIFLOW2:

write_servo_pulse.png

Motion.get_motor_speed(ch)

Get the speed of the motor.

  • ch: Motor channel (1 or 2).

UIFLOW2:

get_motor_speed.png

Motion.set_motor_speed(ch, speed)

Set the speed of the motor.

  • ch: Motor channel (1 or 2).

  • speed: Speed of the motor (-127 to 127).

UIFLOW2:

set_motor_speed.png