upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the L298 Dual H-Bridge Motor Driver. More...

Detailed Description

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.jpg


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

Example driving a DC motor

Example driving a stepper motor

Classes

class  L298_DIRECTION_T
 

Public Member Functions

synchronized void delete ()
 
 L298 (int pwm, int dir1, int dir2)
 
 L298 (int stepsPerRev, int en, int i1, int i2, int i3, int i4)
 
long getMillis ()
 
void initClock ()
 
void setPeriodMS (int ms)
 
void enable (boolean enable)
 
void setSpeed (int speed)
 
void setDirection (L298.L298_DIRECTION_T dir)
 
void stepperSteps (long steps)
 

Constructor & Destructor Documentation

L298 ( int  pwm,
int  dir1,
int  dir2 
)

L298 constructor for DC motor(s) connected.

Parameters
pwmDigital pin to use for a DC motor - must be PWM-capable
dir1Digital pin to use for motor direction pin 1
dir2Digital pin to use for motor direction pin 2
L298 ( int  stepsPerRev,
int  en,
int  i1,
int  i2,
int  i3,
int  i4 
)

L298 constructor for a 4-wire stepper motor

Parameters
stepsPerRevNumber of steps per full revolution
enEnables the pin
i1Digital pin to use for stepper input 1
i2Digital pin to use for stepper input 2
i3Digital pin to use for stepper input 3
i4Digital pin to use for stepper input 4

Member Function Documentation

void enable ( boolean  enable)

Enables the PWM output for a motor

Parameters
enableEnables the PWM output if true, disables if false
long getMillis ( )

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

Returns
Elapsed milliseconds
void initClock ( )

Resets the clock

void setDirection ( L298.L298_DIRECTION_T  dir)

Sets the direction of the motor, clockwise or counterclockwise

Parameters
dirDirection to set the motor to
void setPeriodMS ( int  ms)

Sets the period in milliseconds

Parameters
msPeriod in milliseconds
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.

Parameters
speedSpeed to set the motor to
void stepperSteps ( long  steps)

Steps the stepper motor a specified number of steps

Parameters
stepsNumber of steps to move the stepper motor

The documentation for this class was generated from the following file: