Library for H-Bridge Motor Driver Using Bipolar Transistors

Embed: (wiki syntax)

« Back to documentation index

Motor Class Reference

Motor Class Reference

Interface to control a standard DC motor. More...

#include <motorlib.h>

Public Types

enum  MCtrlType { L293D_DISCRETE, L293D_PWM, COMPS_DISCRETE, COMPS_PWM }
 

Motor Control Type.

More...

Public Member Functions

 Motor (PinName r1, PinName r4, MCtrlType mctype=L293D_PWM)
 Create a motor control interface.
void coast (void)
 Set the motor to coast/roll/off.
void forward (void)
 Rotate motor in clockwise direction.
void backward (void)
 /** Rotate motor in Anti-clockwise direction.
void stop (void)
 Stop the motor.

Detailed Description

Interface to control a standard DC motor.

Definition at line 18 of file motorlib.h.


Member Enumeration Documentation

enum MCtrlType

Motor Control Type.

Enumerator:
L293D_DISCRETE 

0 or 100% duty cycle with L293D

L293D_PWM 

PWM based voltage control with L293D.

COMPS_DISCRETE 

0 or 100% duty cycle with transistor circuit

COMPS_PWM 

PWM based voltage control with transistor circuit.

Definition at line 21 of file motorlib.h.


Constructor & Destructor Documentation

Motor ( PinName  r1,
PinName  r4,
MCtrlType  mctype = L293D_PWM 
)

Create a motor control interface.

Parameters:
r1DigitalOut, driving H-bridge NPN transistor on the BOTTOm right
r2DigitalOut, driving H-bridge PNP transistor on the TOP right
r3DigitalOut, driving H-bridge NPN transistor on the BOTTOm left.
r4DigitalOut, driving H-bridge PNP transistor on the TOP left
mctypeDigitalOut, driving H-bridge PNP transistor on the TOP left

Definition at line 27 of file motorlib.cpp.


Member Function Documentation

void backward ( void   )

/** Rotate motor in Anti-clockwise direction.

Parameters:
void
Returns:
void

Definition at line 54 of file motorlib.cpp.

void coast ( void   )

Set the motor to coast/roll/off.

Parameters:
void
Returns:
void

Definition at line 34 of file motorlib.cpp.

void forward ( void   )

Rotate motor in clockwise direction.

Parameters:
void
Returns:
void

Definition at line 41 of file motorlib.cpp.

void stop ( void   )

Stop the motor.

Parameters:
void
Returns:
void

Definition at line 67 of file motorlib.cpp.