API Documentation of Me Encoder Motor

MeEncoderMotor(uint8_t addr,uint8_t slot); Description: Constructor of Encoder Motor. Parameters: uint8_t addr: I2C address of driver module uint8_t slot: the motor number, can be SLOT1 or SLOT2. Example: MeEncoderMotor motor1(0x09, SLOT1); MeEncoderMotor motor2(0x09, SLOT2); void begin(); Description: Initialize the motor and start it. Example: motor1.begin(); boolean Reset(); Description: Reset the position to 0 and reinitialize the […]

MeEncoderMotor(uint8_t addr,uint8_t slot);

Description:
Constructor of Encoder Motor.

Parameters:
uint8_t addr: I2C address of driver module
uint8_t slot: the motor number, can be SLOT1 or SLOT2.

Example:

  1. MeEncoderMotor motor1(0x09, SLOT1);
  2. MeEncoderMotor motor2(0x09, SLOT2);

void begin();

Description:
Initialize the motor and start it.

Example:

  1. motor1.begin();

boolean Reset();

Description:
Reset the position to 0 and reinitialize the motor.

Example:

  1. motor1.Reset();

boolean Move(float angle, float speed);

Description:
Run the motor by a angle, with a specified speed.

Parameters:
float angle: The relative angle (in degrees). It can be positive and nagative.
float speed: The running speed (in RPM).

Example:

  1. // Run 360° with the speed of 100 RPM
  2. motor1.Move(360, 100);

boolean MoveTo(float angle, float speed);

Description:
Move to the absolute angle, with a specified speed.

Parameters:
float angle: The absolute angle (in degrees). It can be positive and nagative.
fleat speed: The running speed (in RPM).

Example:

  1. // Run to the initial position, with the speed of 150 RPM
  2. motor1.Movo(0, 150);

boolean RunTurns(float turns, float speed);

Description:
It is like Move(float angle, float speed), 1 turn equals 360 degrees.

Parameters:
float turns: The relative turns. It can be positive and negative.
float speed: The running speed (in RPM).

Example:

  1. //Run five turns
  2. motor1.RunTurns(5, 100);

boolean RunSpeed(float speed);

Description:
Run in a specified speed and keep it.

Parameters:
float speed: The running speed (in RPM).

Example:

  1. // Run with the speed of 42 RPM
  2. motor1.RunSpeed(42);

boolean RunSpeedAndTime(float speed, float time);

Description:
Run in a specified speed and time.

Parameters:
float speed: The running speed (in RPM).
float time: The running time (in milli-seconds).

Example:

  1. // Run for 3 seconds with the speed of 20 RPM
  2. motor1.RunSpeedAndTime(20, 3000);

float GetCurrentSpeed();

Decription:
Get the current speed.

Return:
The current speed (in RPM).

Example:

  1. float currentSpeed = motor1.GetCurrentSpeed();

float GetCurrentPosition();

Description:
Get the current position.

Return:
The current position (in degrees).

Example:

  1. float currentPos = motor1.GetCurrentPosition();

Добавить комментарий