UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

SmartDrive Class

Module: smartdrive
  • ID: smartdrive
  • Name: SmartDrive Advanced Motor Controller
  • Other Names: smartdrive
  • Category: motor
  • Manufacturer: openelectrons
  • Connection: i2c

SmartDrive is a multiplexer to control high current DC motors
This module has been tested on the SmartDrive .

Methods

SmartDrive

(
  • i2c_bus
  • address
)
Number

Initialize the class with the i2c address of your SmartDrive

Parameters:

  • i2c_bus Number

    I2C bus to use.

  • address Number

    Address of your SmartDrive .

Returns:

Number:

command

(
  • cmd
)

Writes a specified command on the command register of the SmartDrive

Parameters:

  • cmd Number

    The command you wish the SmartDrive to execute.

GetBattVoltage

() Number

Reads the battery voltage. Multiplier constant not yet verified

Returns:

Number:

ReadTachometerPosition

(
  • motor_id
)
Number

Reads the tacheometer position of the specified motor

Parameters:

  • motor_id Number

    Number of the motor you wish to read.

Returns:

Number:

Run_Unlimited

(
  • motor_id
  • direction
  • speed
)

Turns the specified motor(s) forever

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • direction Number

    The direction you wish to turn the motor(s).

  • speed Number

    The speed at which you wish to turn the motor(s).

StopMotor

(
  • motor_id
  • next_action
)

Stops the specified motor(s)

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • next_action Number

    How you wish to stop the motor(s).

Run_Seconds

(
  • motor_id
  • direction
  • speed
  • duration
  • wait_for_completion
  • next_action
)

Turns the specified motor(s) for a given amount of seconds

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • direction Number

    The direction you wish to turn the motor(s).

  • speed Number

    The speed at which you wish to turn the motor(s).

  • duration Number

    The time in seconds you wish to turn the motor(s).

  • wait_for_completion Boolean

    Tells the program when to handle the next line of code.

  • next_action Number

    How you wish to stop the motor(s).

WaitUntilTimeDone

(
  • motor_id
)

Waits until the specified time for the motor(s) to run is completed

Parameters:

  • motor_id Number

    Number of the motor(s) to wait for.

IsTimeDone

(
  • motor_id
)
Boolean

Checks to ensure the specified time for the motor(s) to run is completed.

Parameters:

  • motor_id Number

    Number of the motor(s) to check.

Returns:

Boolean:

Run_Degrees

(
  • motor_id
  • direction
  • speed
  • degrees
  • wait_for_completion
  • next_action
)

Turns the specified motor(s) for given relative tacheometer count

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • direction Number

    The direction you wish to turn the motor(s).

  • speed Number

    The speed at which you wish to turn the motor(s).

  • degrees Number

    The relative tacheometer count you wish to turn the motor(s).

  • wait_for_completion Boolean

    Tells the program when to handle the next line of code.

  • next_action Number

    How you wish to stop the motor(s).

Run_Rotations

(
  • motor_id
  • direction
  • speed
  • rotations
  • wait_for_completion
  • next_action
)

Turns the specified motor(s) for given relative tacheometer count

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • direction Number

    The direction you wish to turn the motor(s).

  • speed Number

    The speed at which you wish to turn the motor(s).

  • rotations Number

    The relative amount of rotations you wish to turn the motor(s).

  • wait_for_completion Boolean

    Tells the program when to handle the next line of code.

  • next_action Number

    How you wish to stop the motor(s).

Run_Tacho

(
  • motor_id
  • speed
  • tacho_count
  • wait_for_completion
  • next_action
)

Turns the specified motor(s) for given absolute tacheometer count

Parameters:

  • motor_id Number

    Number of the motor(s) you wish to turn.

  • speed Number

    The speed at which you wish to turn the motor(s).

  • tacho_count Number

    The absolute tacheometer count you wish to turn the motor(s).

  • wait_for_completion Boolean

    Tells the program when to handle the next line of code.

  • next_action Number

    How you wish to stop the motor(s).

WaitUntilTachoDone

(
  • motor_id
)

Waits until the specified tacheomter count for the motor(s) to run is reached.

Parameters:

  • motor_id Number

    Number of the motor(s) to wait for.

IsTachoDone

(
  • motor_id
)
Boolean

Checks to ensure the specified tacheomter count for the motor(s) to run is reached.

Parameters:

  • motor_id Number

    Number of the motor(s) to check.

Returns:

Boolean:

SetPerformanceParameters

(
  • Kp_tacho
  • Ki_tacho
  • Kd_tacho
  • Kp_speed
  • Ki_speed
  • Kd_speed
  • passcount
  • tolerance
)

Writes user specified values to the PID control registers

Parameters:

  • Kp_tacho Number

    Proportional-gain of the tacheometer position of the motor.

  • Ki_tacho Number

    Integral-gain of the tacheometer position of the motor.

  • Kd_tacho Number

    Derivative-gain of the tacheometer position of the motor.

  • Kp_speed Number

    Proportional-gain of the speed of the motor.

  • Ki_speed Number

    Integral-gain of the speed of the motor.

  • Kd_speed Number

    Derivative-gain of the speed of the motor.

  • passcount Number

    undefined

  • tolerance Number

    undefined

ReadPerformanceParameters

()

Reads the values of the PID control registers

GetMotorStatus

(
  • motor_id
)
Number

Read the status of a motor, and return it in a uint8_t param motor_id Number fo the motor to check

Parameters:

  • motor_id Number

    undefined

Returns:

Number:

PrintMotorStatus

(
  • motor_id
)

Print the detailed status of the motor

Parameters:

  • motor_id Number

    Number fo the motor to check