RoboidControl for Arduino
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Attributes | Static Protected Attributes | List of all members
Passer::RoboidControl::TB6612Motor Class Reference

A single port of the TB6612 motor controller. More...

#include <TB6612.h>

Inheritance diagram for Passer::RoboidControl::TB6612Motor:
Passer::RoboidControl::Motor Passer::RoboidControl::Thing

Public Types

enum class  Direction { Clockwise = 1 , CounterClockwise = -1 }
 Motor turning direction. More...
 

Public Member Functions

 TB6612Motor ()
 
 TB6612Motor (byte pinIn1, byte pinIn2)
 Create a motor driver without speed control.
 
 TB6612Motor (byte pinIn1, byte pinIn2, byte pinPWM)
 Create a motor driver with speed control.
 
void SetSpeed (float speed)
 Turning direction of the motor.
 
virtual float GetSpeed ()
 Get the current target speed of the motor.
 
bool IsMotor ()
 Check if the Thing is a Motor.
 
bool IsSensor ()
 Check if the Thing is a Sensor.
 

Public Attributes

byte pinIn1
 The pin number for the in1 signal.
 
byte pinIn2
 The pin number for the in2 signal.
 
byte pinPWM
 The pin for the PWM speed signal.
 
Direction direction = Direction::Clockwise
 The forward turning direction of the motor.
 
unsigned int type
 The type of Thing.
 

Static Public Attributes

static const unsigned int SwitchType = SensorType | (unsigned int)Type::Switch
 
static const unsigned int DistanceSensorType
 
static const unsigned int ControlledMotorType
 
static const unsigned int UncontrolledMotorType
 

Protected Types

enum class  Type {
  Undetermined , Switch , DistanceSensor , ControlledMotor ,
  UncontrolledMotor
}
 Basic Thing types. More...
 

Protected Attributes

float currentTargetSpeed = 0
 

Static Protected Attributes

static const unsigned int MotorType = 0x8000
 Bitmask for Motor type.
 
static const unsigned int SensorType = 0x4000
 Bitmap for Sensor type.
 

Detailed Description

A single port of the TB6612 motor controller.

Member Enumeration Documentation

◆ Direction

enum class Passer::RoboidControl::Motor::Direction
stronginherited

Motor turning direction.

Enumerator
Clockwise 
CounterClockwise 

◆ Type

enum class Passer::RoboidControl::Thing::Type
strongprotectedinherited

Basic Thing types.

Enumerator
Undetermined 
Switch 
DistanceSensor 
ControlledMotor 
UncontrolledMotor 

Constructor & Destructor Documentation

◆ TB6612Motor() [1/3]

TB6612Motor::TB6612Motor ( )

◆ TB6612Motor() [2/3]

TB6612Motor::TB6612Motor ( byte  pinIn1,
byte  pinIn2 
)

Create a motor driver without speed control.

Parameters
pinIn1See note below
pinIn2See note below
Note
pinIn1 = H, pinIn2 = L give clockwise rotation
pinIn1 = L, pinIn2 = H gives counter clock wise rotation
all other combinations will result in a short brake
Warning
- Note that without PWM, the speed of the motor cannot be controlled.
- Make sure the standby pin is pulled high.

◆ TB6612Motor() [3/3]

TB6612Motor::TB6612Motor ( byte  pinIn1,
byte  pinIn2,
byte  pinPWM 
)

Create a motor driver with speed control.

Parameters
pinIn1See note below
pinIn2See note below
pinPWMthe speed of the rotation, 0 = short break, 255 = max speed
Note
pinIn1 = H, pinIn2 = L give clockwise rotation
pinIn1 = L, pinIn2 = H gives counter clock wise rotation
all other combinations will result in a short brake
Warning
- Make sure the standby pin is pulled high.

Member Function Documentation

◆ SetSpeed()

void TB6612Motor::SetSpeed ( float  speed)
virtual

Turning direction of the motor.

Set the turning direction of the motor

Reimplemented from Passer::RoboidControl::Motor.

◆ GetSpeed()

float Motor::GetSpeed ( )
virtualinherited

Get the current target speed of the motor.

Returns
The speed between -1 (full backward), 0 (stop) and 1 (full forward)

◆ IsMotor()

bool Thing::IsMotor ( )
inherited

Check if the Thing is a Motor.

Returns
True when the Thing is a Motor and False otherwise

◆ IsSensor()

bool Thing::IsSensor ( )
inherited

Check if the Thing is a Sensor.

Returns
True when the Thing is a Sensor and False otherwise

Member Data Documentation

◆ pinIn1

byte Passer::RoboidControl::TB6612Motor::pinIn1

The pin number for the in1 signal.

◆ pinIn2

byte Passer::RoboidControl::TB6612Motor::pinIn2

The pin number for the in2 signal.

◆ pinPWM

byte Passer::RoboidControl::TB6612Motor::pinPWM

The pin for the PWM speed signal.

◆ direction

Direction Passer::RoboidControl::Motor::direction = Direction::Clockwise
inherited

The forward turning direction of the motor.

◆ currentTargetSpeed

float Passer::RoboidControl::Motor::currentTargetSpeed = 0
protectedinherited

◆ type

unsigned int Passer::RoboidControl::Thing::type
inherited

The type of Thing.

◆ SwitchType

const unsigned int Thing::SwitchType = SensorType | (unsigned int)Type::Switch
staticinherited

◆ DistanceSensorType

const unsigned int Thing::DistanceSensorType
staticinherited
Initial value:
=
static const unsigned int SensorType
Bitmap for Sensor type.
Definition Thing.h:31

◆ ControlledMotorType

const unsigned int Thing::ControlledMotorType
staticinherited
Initial value:
=
static const unsigned int MotorType
Bitmask for Motor type.
Definition Thing.h:29

◆ UncontrolledMotorType

const unsigned int Thing::UncontrolledMotorType
staticinherited

◆ MotorType

const unsigned int Passer::RoboidControl::Thing::MotorType = 0x8000
staticprotectedinherited

Bitmask for Motor type.

◆ SensorType

const unsigned int Passer::RoboidControl::Thing::SensorType = 0x4000
staticprotectedinherited

Bitmap for Sensor type.


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