![]() |
MatrixMiniR4 1.1.5
Matrix Mini R4 Arduino Library API Documentation
|
Class for controlling a DC motor with encoder functionality. More...
#include <MiniR4DC.h>
Public Member Functions | |
MiniR4DC () | |
bool | begin (void) |
Initializes the DC motor settings. | |
bool | setReverse (bool dir) |
Sets the direction of the DC motor. | |
bool | setPower (int16_t power) |
Sets the power level of the DC motor. | |
bool | setSpeed (int16_t speed) |
Sets the speed of the DC motor. | |
bool | rotateFor (int16_t speed, uint16_t degree) |
Rotates the DC motor for a specific degree at a given speed. | |
bool | setFixSpeedPID (float kp, float ki, float kd) |
Sets the PID parameters for fixed speed control. (For SetSpeed()) | |
bool | setRotatePID (float kp, float ki, float kd) |
Sets the PID parameters for rotation control. (For rotateFor()) | |
int32_t | getCounter (void) |
Gets the current encoder counter value. (Not Degree) | |
int32_t | getDegrees (void) |
Gets the current rotation in degrees based on the encoder count. | |
bool | resetCounter (void) |
Resets the encoder counter to zero. | |
bool | setBrake (bool brake) |
Sets the brake mode for the DC motor. | |
bool | ChkRotateEnd (bool &isEnd) |
Checks if the rotation has ended. | |
Class for controlling a DC motor with encoder functionality.
This template class provides methods for initializing, controlling speed, power, and direction of a DC motor, as well as for managing its encoder.
ID | The identifier for the motor. |
Definition at line 20 of file MiniR4DC.h.
|
inline |
Definition at line 23 of file MiniR4DC.h.
|
inline |
Initializes the DC motor settings.
This function sets the speed range, resets the encoder counter, powers off the motor, and sets the direction to forward.
Note: Once you call MiniR4.begin(), M1-M4 motor will automaticlly begin.
Definition at line 35 of file MiniR4DC.h.
|
inline |
Checks if the rotation has ended.
isEnd | Reference to a boolean that will be set to true if rotation has ended, false otherwise. |
Definition at line 197 of file MiniR4DC.h.
|
inline |
Gets the current encoder counter value. (Not Degree)
Definition at line 142 of file MiniR4DC.h.
|
inline |
Gets the current rotation in degrees based on the encoder count.
Definition at line 154 of file MiniR4DC.h.
|
inline |
Resets the encoder counter to zero.
Definition at line 166 of file MiniR4DC.h.
|
inline |
Rotates the DC motor for a specific degree at a given speed.
It's like LEGO EV3/SPIKE Motor rotate for degress block. Note: Non-Blocking function, you can use ChkRotateEnd() to check motor finish rotate or not. Note: If motor not complete rotate and revice other command like setSpeed(), the rotate will be skip.
speed | The speed at which to rotate the motor. |
degree | The degree of rotation. |
Definition at line 103 of file MiniR4DC.h.
|
inline |
Sets the brake mode for the DC motor.
Like LEGO EV3/SPIKE, True is Brake, False is Coast.
brake | True to engage the brake, false to stop the motor. |
Definition at line 180 of file MiniR4DC.h.
|
inline |
Sets the PID parameters for fixed speed control. (For SetSpeed())
kp | Proportional gain. |
ki | Integral gain. |
kd | Derivative gain. |
Definition at line 117 of file MiniR4DC.h.
|
inline |
Sets the power level of the DC motor.
It's like LEGO EV3/SPIKE Power block (Unregulated Motor) It will output the Motor PWM from 0% to 100%
power | The power level to set (-100 to 100). |
Definition at line 71 of file MiniR4DC.h.
|
inline |
Sets the direction of the DC motor.
dir | True to set direction to reverse, false for forward. |
Definition at line 53 of file MiniR4DC.h.
|
inline |
Sets the PID parameters for rotation control. (For rotateFor())
kp | Proportional gain. |
ki | Integral gain. |
kd | Derivative gain. |
Definition at line 131 of file MiniR4DC.h.
|
inline |
Sets the speed of the DC motor.
It's like LEGO EV3/SPIKE Speed block (EV3 Green Motor) The Lower MCU (STM32) will control the motor PWM to try keep the speed you set.
speed | The speed to set (-100 to 100). |
Definition at line 86 of file MiniR4DC.h.