Richard Wunderlich / IBT2
Embed: (wiki syntax)

« Back to documentation index

IBT2 Class Reference

IBT2 Class Reference

Interface to the IBT-2 H-bridge motor controller. More...

#include <IBT2.h>

Public Member Functions

 IBT2 (PinName L_pwm, PinName R_pwm, PinName en, float freq)
 Create an IBT-2 control interface.
void setSpeed (float speed)
 Set the speed and direction of the motor.
float getSpeed (void)
 Get the speed and direction of the motor.

Detailed Description

Interface to the IBT-2 H-bridge motor controller.

Control a DC motor connected to the IBT-2 H-bridge using one of two modes:

Mode 1: 2 PwmOuts and 1 DigitalOut

  • L_PWM controlled with a PwmOut
  • R_PWM controlled with a PwmOut
  • L_EN, R_EN connected to a DigitalOut (High is Enabled)

Mode 2: 1 PwmOut and 2 DigitalOuts

  • L_PWM connected to a DigitalOut (High is Forward; keep R_PWM Low)
  • R_PWM connected to a DigitalOut (High is Reverse; keep L_PWM Low)
  • L_EN, R_EN controlled with a PwmOut

For now, only Mode 1 is used.

Definition at line 46 of file IBT2.h.


Constructor & Destructor Documentation

IBT2 ( PinName  L_pwm,
PinName  R_pwm,
PinName  en,
float  freq 
)

Create an IBT-2 control interface.

Parameters:
L_pwmA PwmOut pin, driving the L_PWM H-bridge line to control the forward speed.
R_pwmA PwmOut pin, driving the R_PWM H-bridge line to control the reverse speed.
enA DigitalOut pin, driving the L_EN and R_EN H-bridge enable lines.
freqThe frequency of the H-bridge PWM lines in Hz.

Definition at line 25 of file IBT2.cpp.


Member Function Documentation

float getSpeed ( void   )

Get the speed and direction of the motor.

Returns:
The speed of the motor as a normalized value between -1.0 and 1.0. A positive value is forward and a negative value is reverse.

Definition at line 56 of file IBT2.cpp.

void setSpeed ( float  speed )

Set the speed and direction of the motor.

Parameters:
speedThe speed of the motor as a normalized value between -1.0 and 1.0. Use a positive value for forward and a negative value for reverse.

Definition at line 37 of file IBT2.cpp.