TB6612FNG.Motor (tb6612fng v0.1.0)

Controls a motor attached to the TB6612FNG. Has a number of required settings:

  • in01_pin - A GPIO pin number for the first input pin for this motor
  • in02_pin - A GPIO pin number for the second input pin for this motor
  • pwm_pin - A GPIO pin number for the PWM pin for this motor. Must be a hardware PWM pin.
  • name - A unique atom that will be used as both the ID and name of the GenServer controlling this motor. Used to control the motor from elsewhere.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Return the config for the motor, mostly for troubleshooting purposes or running manual commands using the GPIO references.

Set the direction of rotation and output for the motor specified.

Short brake the motor. This sets the output to 0.

Stop the motor. This leaves the PWM pin set at the current rate but sets both input pins low.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_config(name)

Return the config for the motor, mostly for troubleshooting purposes or running manual commands using the GPIO references.

Link to this function

set_output(name, direction, output)

Set the direction of rotation and output for the motor specified.

Accepts three parameters:

  • name - The name (atom) of the GenServer controlling the motor.
  • direction - Either :cw for clockwise or :ccw for counter-clockwise rotation
  • output - The PWM output requested. This should be an integer value between 0 and 1_000_000
Link to this function

short_brake(name)

Short brake the motor. This sets the output to 0.

Link to this function

start_link(opts)

Stop the motor. This leaves the PWM pin set at the current rate but sets both input pins low.