pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit Roller485

Example

Start the motor to rotate

from m5stack import *
from m5stack_ui import *
from uiflow import *
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
roller485_0 = unit.get(unit.ROLLER485, unit.PORTA)

roller485_0.init_device(0, 0x64)
roller485_0.set_motor_mode(1)
roller485_0.set_motor_output_state(1)
while True:
  roller485_0.set_motor_speed_current_setting(1000, 400)
  roller485_0.set_motor_speed_pid(15, 0.0001, 400)
  wait_ms(2)

API

roller485_0.init_device(0, 0x64)
  • Initialize Roller Communication Mode to I2C
print((str('spec:') + str((roller485_0.get_device_spec(0xFE)))))
  • Get Device Information (returns int)
    • FIRMWARE:Firmware Version
    • I2C ADDRESS:I2C Address
print((str('count value:') + str((roller485_0.get_encoder_value()))))
  • Get Motor Encoder Count (returns float)
print((str('485 baudrate:') + str((roller485_0.get_485_baudrate()))))
  • Get Motor RS485 Baud Rate (returns int)
print((str('current mode:') + str((roller485_0.get_motor_mode()))))
  • Get Motor Operating Mode (returns int)
print((str('readback value:') + str((roller485_0.get_motor_current_readback()))))
  • Get Motor Current Feedback (returns float)
print((str('error code:') + str((roller485_0.get_motor_error_code()))))
  • Get Motor Error Code (returns int)
print((str('485 id:') + str((roller485_0.get_motor_id()))))
  • Get Motor RS485 Device ID (returns int)
print((str('speed max current setting value:') + str((roller485_0.get_motor_speed_max_current()))))
  • Get Motor Max Current Limit (mA, returns float)
print((str('output status:') + str((roller485_0.get_motor_output_status()))))
  • Get Motor Output Status (returns int)
print((str('position max current setting value:') + str((roller485_0.get_motor_position_max_current()))))
  • Get Position Mode Max Current (mA, returns float)
print((str('position pid:') + str((roller485_0.get_motor_position_pid()))))
  • Get Position Loop PID Parameters
print((str('readback value:') + str((roller485_0.get_motor_position_readback()))))
  • Get Position readback value (returns float)
print((str('position setting value:') + str((roller485_0.get_motor_position_setting()))))
  • Get Position Setpoint (returns float)
print((str('speed max current setting value:') + str((roller485_0.get_motor_speed_max_current()))))
  • Get Speed Mode Max Current (mA, returns float)
print((str('speed id:') + str((roller485_0.get_motor_speed_pid()))))
  • Get Speed Loop PID Parameters
print((str('readback value:') + str((roller485_0.get_motor_speed_readback()))))
  • Get Speed Feedback (RPM, returns float)
print((str('setting value:') + str((roller485_0.get_motor_speed_setting()))))
  • Get Speed Feedback (RPM, returns float)
print((str('brightness:') + str((roller485_0.get_rgb_brightness()))))
  • Get Speed Setpoint (RPM, returns float)
print((str('RGB color:') + str((roller485_0.get_rgb_color()))))
  • Get RGB Color Value (returns tuple: R,G,B)
print((str('RGB mode:') + str((roller485_0.get_rgb_mode()))))
  • Get RGB Operating Mode (returns int)
print((str('temperature:') + str((roller485_0.get_temperature_value()))))
  • Get Device Temperature (°C, returns int)
print((str('voltage:') + str((roller485_0.get_vin_value()))))
  • Get Input Voltage (mV, returns int)
roller485_0.set_button_change_mode(0)
  • Toggle Motor Mode via Button (Disable/Enable)
roller485_0.set_data_save_in_flash()
  • Save Current Settings to Flash
roller485_0.set_encoder_value(1000)
  • Set Motor Encoder Count
roller485_0.set_i2c_address(0x64)
  • Set Motor RS485 Baud Rate
roller485_0.set_485_baudrate(0)
  • Set Motor RS485 Baud Rate
roller485_0.set_motor_id(0x01)
  • Set Motor RS485 Device ID
roller485_0.set_motor_max_current(400)
  • Set Motor Max Current Limit
roller485_0.set_motor_mode(1)
  • Set Motor Operating Mode
    • Speed
    • Position
    • Current
    • Encoder
roller485_0.set_motor_output_state(1)
  • Enable/Disable Motor Output
roller485_0.set_motor_position_current_setting(1000, 400)
  • Set Position Mode Target (Pulse) and Max Current
roller485_0.set_motor_position_pid(15, 0.0001, 400)
  • Set Position Loop PID Parameters
roller485_0.set_motor_speed_current_setting(1000, 400)
  • Set Speed Mode Target (RPM) and Max Current
roller485_0.set_motor_speed_pid(15, 0.0001, 400)
  • Set Speed Loop PID Parameters
roller485_0.set_motor_over_range_protect(0)
  • Disable/Enable Motor Overrange Protection
roller485_0.set_remove_protect()
  • Enable Stall Recovery Protection
roller485_0.set_rgb_brightness(50)
  • Set RGB Brightness Level
roller485_0.set_rgb_color((0xff0000))
  • Set RGB Color Palette
roller485_0.set_rgb_mode(0)
  • Set RGB Operating Mode
    • disable
    • enable
roller485_0.set_motor_stall_protect(0)
  • Enable/Disable Motor Stall Protection
On This Page