pyupm_l298 module

class pyupm_l298.L298(*args)[source]

Bases: object

API for the L298 Dual H-Bridge Motor Driver.

ID: l298

Name: Dual H-bridge Motor Driver

Category: motor

Manufacturer: seeed sparkfun

Link:https://www.sparkfun.com/products/9670

Connection: gpio pwm It was developed using the RobotBase Dual H-Bridge module.

This module can support 2 DC motors, or one 2-phase stepper motor. It requires 3 pins per DC motor (or H-bridge), or 4 pins for the stepper motor (uses both H-bridges).

L298 Dual H-Bridge Motor Driver image provided by SparkFun* underCC BY-NC-SA-3.0.

Example driving a DC motorExample driving a stepper motor

C++ includes: l298.hpp

DIR_CCW = 2
DIR_CW = 1
DIR_NONE = 0
enable(enable)[source]

void enable(bool enable)

Enables the PWM output for a motor

enable: Enables the PWM output if true, disables if false

getMillis()[source]

uint32_t getMillis()

Returns the number of milliseconds elapsed since initClock() was last called.

Elapsed milliseconds

initClock()[source]

void initClock()

Resets the clock

setDirection(dir)[source]

void setDirection(L298_DIRECTION_T dir)

Sets the direction of the motor, clockwise or counterclockwise

dir: Direction to set the motor to

setPeriodMS(ms)[source]

void setPeriodMS(int ms)

Sets the period in milliseconds

ms: Period in milliseconds

setSpeed(speed)[source]

void setSpeed(int speed)

Sets the speed of a DC or stepper motor. For a DC motor, values can range from 0 (off) to 100 (full speed). For a stepper motor, specify the desired RPM.

speed: Speed to set the motor to

stepperSteps(steps)[source]

void stepperSteps(unsigned int steps)

Steps the stepper motor a specified number of steps

steps: Number of steps to move the stepper motor