Library for driving a motor with one PWM and one DIR signal using PI control.
Fork of Motor2 by
Motor Class Reference
Class for controlling motors trough PCA9555. More...
#include <motor.h>
Public Member Functions | |
Motor (PinName PWMpin, PCA9555 *ioExt, unsigned int dirPin, PinName encA, PinName encB) | |
Create an instance of the motor connected to specfied pins, and IO-expander. | |
void | setSpeed (int newSpeed) |
Set speed setpoint. | |
int | getSpeed () |
Get current speed setpoint value. | |
void | pid () |
Method that calculates appropriate PWM values for keeping motor speed close to setpoint This method shoud be called periodically (60Hz) |
Detailed Description
Class for controlling motors trough PCA9555.
Definition at line 8 of file motor.h.
Constructor & Destructor Documentation
Motor | ( | PinName | PWMpin, |
PCA9555 * | ioExt, | ||
unsigned int | dirPin, | ||
PinName | encA, | ||
PinName | encB | ||
) |
Create an instance of the motor connected to specfied pins, and IO-expander.
- Parameters:
-
PWMpin Pin for PWM output *ioExt Pointer to IO-expander object dir1Pin Direction pin 1 number (on IO-expander) dir2Pin Direction pin 2 number (on IO-expander) encA Encoder pin encB Encoder pin
Member Function Documentation
void pid | ( | ) |
Generated on Fri Jul 15 2022 14:17:41 by 1.7.2