Multi Half-Bridge  4.0.0
Library of Infineon's Multi Half-Bridge IC controllers family
tle94112-motor.hpp
Go to the documentation of this file.
1 
13 #ifndef TLE94112_MOTOR_HPP_
14 #define TLE94112_MOTOR_HPP_
15 
16 #include "tle94112.hpp"
17 
28 #define TLE94112_MAX_SPEED 255
29 
38 #define TLE94112MOTOR_MAX_CONNECTORS 4
39 
51 {
52  public:
53 
57  enum ePolarity
58  {
59  LOWSIDE = 0,
60  HIGHSIDE
61  };
62 
73  Tle94112Motor(Tle94112 &driver);
74 
79 
91  void begin(void);
92 
105  void end(void);
106 
122  Tle94112::PWMChannel channel,
126  Tle94112::HalfBridge out4);
127 
144  Tle94112::PWMChannel channel,
145  Tle94112::PWMFreq freq,
149  Tle94112::HalfBridge out4);
150 
158 
164  void disconnect(Tle94112::HalfBridge connector);
165 
173 
182 
190 
202  void setActiveFreeWheeling(Tle94112Motor::ePolarity pol, uint8_t active_fw);
203 
209  void stop(uint8_t force=255);
210 
214  void coast();
215 
229  void start(int16_t speed);
230 
248  void setSpeed(int16_t speed);
249 
255  int16_t getSpeed(void);
256 
263  void rampSpeed(int16_t speed, uint16_t slope);
264 
265  protected:
266 
268  enum eMode
269  {
273  STOP
274  };
275 
277  typedef struct
278  {
282  uint8_t active_fw;
283  } Connector_t, *Connector_p;
284 
287  {
288  {
293  .channel = Tle94112::TLE_NOPWM,
294  .freq = Tle94112::TLE_FREQ80HZ,
295  .active_fw = false
296  },
297  {
298  .halfbridges = {Tle94112::TLE_NOHB,
302  .channel = Tle94112::TLE_NOPWM,
303  .freq = Tle94112::TLE_FREQ80HZ,
304  .active_fw = false
305  }
306  };
307 
310 
313 
315  uint8_t mEnabled;
316 
318  uint8_t mSpeed;
319 
328  uint32_t _measureSetSpeedDuration(int16_t speed, int16_t start_speed);
329 
338  void _performSpeedStepping(int16_t start_speed, int16_t ramp_delta_speed, int16_t num_steps, uint16_t steptime);
339 };
342 #endif
PWMFreq
enum for the frequencies of a PWM channel
Definition: tle94112.hpp:96
@ TLE_FREQ80HZ
Definition: tle94112.hpp:97
PWMChannel
enum for the PWM channels of a halfbridge on TLE94112
Definition: tle94112.hpp:78
@ TLE_NOPWM
Definition: tle94112.hpp:79
HalfBridge
enum for the halfbridges on a TLE94112
Definition: tle94112.hpp:71
@ TLE_NOHB
Definition: tle94112.hpp:72
represents a basic TLE94112
Definition: tle94112.hpp:67
void begin(void)
finishes configuration and enables motor controls
Definition: tle94112-motor.cpp:33
eMode mMode
current operation mode
Definition: tle94112-motor.hpp:312
void setPwmFreq(Tle94112Motor::ePolarity pol, Tle94112::PWMFreq freq)
Sets the PWM frequency for driving a motor connector.
Definition: tle94112-motor.cpp:140
uint8_t mSpeed
value of the current motor speed
Definition: tle94112-motor.hpp:318
Connector_t mConnectors[2]
array of motor connectors
Definition: tle94112-motor.hpp:286
ePolarity
Enum to select polarity of a motor connector.
Definition: tle94112-motor.hpp:58
@ HIGHSIDE
Definition: tle94112-motor.hpp:60
@ LOWSIDE
Definition: tle94112-motor.hpp:59
Tle94112 * mDriver
Tle94112 instance acting as output driver.
Definition: tle94112-motor.hpp:309
Tle94112::PWMChannel channel
Definition: tle94112-motor.hpp:280
Tle94112Motor(Tle94112 &driver)
Construct a new Tle94112Motor object.
Definition: tle94112-motor.cpp:20
void setPwm(Tle94112Motor::ePolarity pol, Tle94112::PWMChannel channel)
Sets the PWM channel to be used for a motor connector.
Definition: tle94112-motor.cpp:119
~Tle94112Motor()
Destroy the Tle94112Motor object.
Definition: tle94112-motor.cpp:28
void _performSpeedStepping(int16_t start_speed, int16_t ramp_delta_speed, int16_t num_steps, uint16_t steptime)
private function needed by rampSpeed
Definition: tle94112-motor.cpp:369
int16_t getSpeed(void)
Returns the motor's current speed setting.
Definition: tle94112-motor.cpp:307
void disconnect(Tle94112::HalfBridge connector)
disconnects a single halfbridge output from a motor connector
Definition: tle94112-motor.cpp:100
Tle94112::PWMFreq freq
Definition: tle94112-motor.hpp:281
void initConnector(Tle94112Motor::ePolarity pol, Tle94112::PWMChannel channel, Tle94112::HalfBridge out1, Tle94112::HalfBridge out2, Tle94112::HalfBridge out3, Tle94112::HalfBridge out4)
configures most important settings for one motor connector
Definition: tle94112-motor.cpp:49
void setSpeed(int16_t speed)
equivalent to start()
Definition: tle94112-motor.cpp:242
void rampSpeed(int16_t speed, uint16_t slope)
function to gradually change the motors speed
Definition: tle94112-motor.cpp:323
void connect(Tle94112Motor::ePolarity pol, Tle94112::HalfBridge connector)
connects a single halfbridge output to a motor connector
Definition: tle94112-motor.cpp:83
void coast()
releases the motor without driving or active breaking
Definition: tle94112-motor.cpp:160
void start(int16_t speed)
starts the motor with a certain speed in a certain direction
Definition: tle94112-motor.cpp:235
void setActiveFreeWheeling(Tle94112Motor::ePolarity pol, uint8_t active_fw)
Enables or disables active freewheeling.
Definition: tle94112-motor.cpp:150
uint32_t _measureSetSpeedDuration(int16_t speed, int16_t start_speed)
private function needed by rampSpeed
Definition: tle94112-motor.cpp:351
uint8_t active_fw
Definition: tle94112-motor.hpp:282
Tle94112::HalfBridge halfbridges[TLE94112MOTOR_MAX_CONNECTORS]
Definition: tle94112-motor.hpp:279
eMode
enum for motor operation modes
Definition: tle94112-motor.hpp:269
@ FORWARD
Definition: tle94112-motor.hpp:271
@ STOP
Definition: tle94112-motor.hpp:273
@ COAST
Definition: tle94112-motor.hpp:270
@ BACKWARD
Definition: tle94112-motor.hpp:272
uint8_t mEnabled
flag indicating if motor controls are enabled
Definition: tle94112-motor.hpp:315
struct Tle94112Motor::Connector_t * Connector_p
void stop(uint8_t force=255)
actively breaks the motor to stop it
Definition: tle94112-motor.cpp:182
void end(void)
disables motor controls and switches back to configuration mode
Definition: tle94112-motor.cpp:41
struct representing one motor connector
Definition: tle94112-motor.hpp:278
represents a motor connected to a TLE94112
Definition: tle94112-motor.hpp:51
#define TLE94112MOTOR_MAX_CONNECTORS
maximum number of Tle94112 outputs per motor connector
Definition: tle94112-motor.hpp:38
TLE94112 Core API.