GRBL Module
GRBL 13.2 is a three-axis stepper motor driver module in the M5Stack stacking module series. It uses an ATmega328P-AU controller with three sets of DRV8825PWPR stepper motor driver chip control ways, which can drive three bipolar steppers at the same time.
Support the following products:
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 module import GRBLModule 9 10 11grbl_0 = None 12 13 14def setup(): 15 global grbl_0 16 17 M5.begin() 18 Widgets.fillScreen(0x222222) 19 20 grbl_0 = GRBLModule(address=0x70) 21 print(grbl_0.get_message()) 22 print(grbl_0.get_status()) 23 print(grbl_0.get_idle_state()) 24 print(grbl_0.get_lock_state()) 25 grbl_0.set_mode(GRBLModule.MODE_ABSOLUTE) 26 grbl_0.unlock() 27 grbl_0.turn(5, 5, 10, 5) 28 grbl_0.wait_idle() 29 grbl_0.lock() 30 31 32def loop(): 33 global grbl_0 34 M5.update() 35 36 37if __name__ == "__main__": 38 try: 39 setup() 40 while True: 41 loop() 42 except (Exception, KeyboardInterrupt) as e: 43 try: 44 from utility import print_error_msg 45 46 print_error_msg(e) 47 except ImportError: 48 print("please update to latest firmware")
UIFLOW2 Example:
class GRBLModule
Constructors
- class GRBLModule(address)
Initialize the GRBLModule.
- Parameters:
address (hex) – The I2C address of the device.
UIFLOW2:
Methods
- GRBLModule.g_code(command)
Send the G-code command.
- Parameters:
command – The G-code command.
UIFLOW2:
- GRBLModule.get_code_time(code)
Get the time of the code.
- Return (int):
The estimated time of the command.
- Parameters:
code – The G-code command
UIFLOW2:
- GRBLModule.turn(x, y, z, speed)
Turn the motor to a specific position.
- Parameters:
x – The position of the X motor, 1.6=360°.
y – The position of the Y motor, 1.6=360°.
z – The position of the Z motor, 1.6=360°.
speed – The speed of the motor.
UIFLOW2:
- GRBLModule.set_mode(mode)
Set the mode of the motor.
- Parameters:
mode – The mode of the motor. Options: -
Absolute
: GRBLModule.MODE_ABSOLUTE -Relative
: GRBLModule.MODE_RELATIVE
UIFLOW2:
- GRBLModule.init(x_step, y_step, z_step, acc)
Initialize the motor.
- Parameters:
x_step – The step of the X motor.
y_step – The step of the Y motor.
z_step – The step of the Z motor.
acc – The acceleration of the motor.
UIFLOW2:
- GRBLModule.flush()
Flush the buffer.
UIFLOW2:
- GRBLModule.get_message()
Get the message.
- Return (str):
The message string.
UIFLOW2:
- GRBLModule.get_status()
Get the status.
- Return (str):
The status string.
UIFLOW2:
- GRBLModule.get_idle_state()
Get the idle state.
- Return (bool):
The idle state.
UIFLOW2:
- GRBLModule.get_lock_state()
Get the lock state.
- Return (bool):
The lock state.
UIFLOW2:
- GRBLModule.wait_idle()
Wait until the motor is idle.
UIFLOW2:
- GRBLModule.unlock_alarm_state()
Unlock the alarm state.
UIFLOW2:
- GRBLModule.lock()
Lock the motor.
UIFLOW2:
- GRBLModule.unlock()
Unlock the motor.
UIFLOW2: