Smart Car Controller  1.0
Library to manage a two wheeled robotic vehicle (DC Motors)
SC_DCMotor_L29x Class Reference

#include <SC_DCMotor.h>

Inheritance diagram for SC_DCMotor_L29x:
Collaboration diagram for SC_DCMotor_L29x:

Public Member Functions

Class constructor and destructor.
 SC_DCMotor_L29x (uint8_t pinIn1, uint8_t pinIn2, uint8_t pinEn)
 
 ~SC_DCMotor_L29x (void)
 
Methods for core object control.
bool begin (void)
 
void run (runCmd_t cmd, uint8_t speed)
 
void setSpeed (uint16_t s)
 
- Public Member Functions inherited from SC_DCMotor
uint16_t getSpeed ()
 

Additional Inherited Members

- Public Types inherited from SC_DCMotor
enum  runCmd_t { DIR_FWD , DIR_REV }
 
- Protected Attributes inherited from SC_DCMotor
runCmd_t _mode
 The current mode for the motor.
 
uint16_t _speed
 The current speed setting for the motor.
 

Detailed Description

Core object for the derived SC_DCMotor_L298 class

This motor controller uses 2 standard digital pins for direction control and one PWM capable pin for speed control.

Constructor & Destructor Documentation

◆ SC_DCMotor_L29x()

SC_DCMotor_L29x::SC_DCMotor_L29x ( uint8_t  pinIn1,
uint8_t  pinIn2,
uint8_t  pinEn 
)

Class Constructor (with PWM control).

Instantiate a new instance of the class. This variant is for motor controllers that have a PWM input for speed control.

The main function for the core object is to reset the internal shared variables and timers to default values.

Parameters
pinIn1The In1 pin number for command output to the controller. This is a simple digital pin.
pinIn2The In2 pin number for command output to the controller. This is a simple digital pin.
pinEnThe En pin number for PWM output to the controller. This is a PWM enabled pin.

◆ ~SC_DCMotor_L29x()

SC_DCMotor_L29x::~SC_DCMotor_L29x ( void  )

Class Destructor.

Release any allocated memory and clean up anything else.

Member Function Documentation

◆ begin()

bool SC_DCMotor_L29x::begin ( void  )
virtual

Initialize the object.

Initialize the object data. Sets up the pins for output and puts the controlled in a stopped position.

Returns
true if initialization succeeded

Implements SC_DCMotor.

◆ run()

void SC_DCMotor_L29x::run ( runCmd_t  cmd,
uint8_t  speed 
)
virtual

Run/Stop the motor with speed.

This controls how the motor runs/stops. This sets the motor controller into the correct operating mode and then sets the speed to what is specified. The command specified is one of the runCmd_t values and the speed must be suitable for the setSpeed() method.

See also
setSpeed(), run()
Parameters
cmdthe run/stop mode.
speedthe speed to run at.

Implements SC_DCMotor.

◆ setSpeed()

void SC_DCMotor_L29x::setSpeed ( uint16_t  s)
virtual

Set the speed for the motor.

This controls the PWM setting for the motor. Note that the actual speed is dependent on the motor and it is unlikely that it will be a linear response across the range of valid values.

Parameters
sthe speed setting [0..255].

Implements SC_DCMotor.


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