This is a program to drive a stepper servomotor from SerialUSB without any other interrution but the serial one.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

L293D Class Reference

L293D Class Reference

Class to handle L293D in two modes, Pwm or Digital. More...

#include <L293D.h>

Public Member Functions

 L293D (PwmOut pwmLeft, PwmOut right, DigitalOut left, DigitalOut right)
 Two PWM for speed Cpntrol & two digital outs needed for setting direction on each side of the L293D.
void setSpeedLeft (float speed)
 Set the left PWM to current speed and Direction.
void setSpeedRight (float speed)
 Set the right PWM to current speed and direction.
float getSpeedLeft ()
 Read the left PWM current speed & direction Ranges from -1.0 to 1.0, as being set.
float getSpeedRight ()
 Read the left PWM current speed & direction.

Detailed Description

Class to handle L293D in two modes, Pwm or Digital.

Pwm Mode requires constructing an object with two PwmOut'puts to handle Speed. Enable, or Digital Mode requires One DigitalOut'put to Enable or Disable both sides of the L293D driver.

This of course requires an 'special' wiring of the driver, using one transistor for each side. The transistor is effectively a NOT gate, assuring that the direction of the current of the driver output will be controlled using just one pin. _____________ Enable/ Pwm --->[1] _5V__ | L | _______________ [2] _|_ / | 2 | | | ---------[3] |1k| | | | 9 |__| | | (GND)[4] /_________/ ( ~ ) | 3 _left |/ | (GND)[5] -.---|470ohm|----|\ (Q 2N3904) | | | | \ | -------[6] D | |_(GND) | | | [7] | 5~15V-->[8]_____________

Hope you get my ASCII Art. same goes for the other side, thus allowing a complete control of the driver with a few pins.

Also for Sake of Simplicity SetSpeedLeft/Right will control Motor Speed and Direction, from -1.0 to 1.0 Reverse if < 0.

Definition at line 38 of file L293D.h.


Constructor & Destructor Documentation

L293D ( PwmOut  pwmLeft,
PwmOut  right,
DigitalOut  left,
DigitalOut  right 
)

Two PWM for speed Cpntrol & two digital outs needed for setting direction on each side of the L293D.

Parameters:
left,:Output to the left side of the driver
right,:Output to the right side of the driver
pwmLeft,:Left side PWM.
pwmRight,:Right side PWM.

Definition at line 6 of file L293D.cpp.


Member Function Documentation

float getSpeedLeft (  )

Read the left PWM current speed & direction Ranges from -1.0 to 1.0, as being set.

Returns:
Current PWM duty cycle.

Definition at line 35 of file L293D.cpp.

float getSpeedRight (  )

Read the left PWM current speed & direction.

Ranges from -1.0 to 1.0 as being set.

Returns:
Current PWM duty cycle.

Definition at line 47 of file L293D.cpp.

void setSpeedLeft ( float  speed )

Set the left PWM to current speed and Direction.

Values from -1.0 to 1.0, to control direction and speed, if Enable mode, only use -1.0 & 1.0

Definition at line 17 of file L293D.cpp.

void setSpeedRight ( float  speed )

Set the right PWM to current speed and direction.

Values from -1.0 to 1.0, to control direction and speed, if Enable mode, only use -1.0 & 1.0 Only to use when PWM mode is declared

Definition at line 26 of file L293D.cpp.