Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Motor2 by
Revision 6:37199f371bf8, committed 2013-09-16
- Comitter:
- Reiko
- Date:
- Mon Sep 16 17:54:14 2013 +0000
- Parent:
- 5:99fa6dffea40
- Parent:
- 4:2b77f4656e92
- Child:
- 7:fbd3fa0445e5
- Commit message:
- Merge
Changed in this revision
| motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/motor.h Mon Sep 16 17:53:13 2013 +0000
+++ b/motor.h Mon Sep 16 17:54:14 2013 +0000
@@ -4,17 +4,35 @@
#include "mbed.h"
#include "PCA9555.h"
#include "qed.h"
-
+ /** Class for controlling motors trough PCA9555 */
class Motor {
protected:
FunctionPointer stallWarningCallback;
FunctionPointer stallErrorCallback;
public:
+ /** Create an instance of the motor connected to specfied pins, and IO-expander.
+ *
+ * @param PWMpin Pin for PWM output
+ * @param *ioExt Pointer to IO-expander object
+ * @param dir1Pin Direction pin 1 number (on IO-expander)
+ * @param dir2Pin Direction pin 2 number (on IO-expander)
+ * @param encA Encoder pin
+ * @param encB Encoder pin
+ */
Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dir1Pin, unsigned int dir2Pin, PinName encA, PinName encB);
-
- void setPWM(int newPWM);
+
+ /** Set speed setpoint
+ *
+ * @param newSpeed New setpoint
+ */
void setSpeed(int newSpeed);
+
+ /** Get current speed setpoint value */
int getSpeed();
+
+ /**Method that calculates appropriate PWM values for keeping motor speed close to setpoint
+ * This method shoud be called periodically (60Hz)
+ */
void pid();
void stallWarning(void (*function)(void));
@@ -43,6 +61,17 @@
void resetPID();
+<<<<<<< local
+=======
+ /** Set pwm duty cycle
+ *
+ * @param newPWM Duty cycle
+ */
+ void setPWM(int newPWM);
+
+ //void pid();
+
+>>>>>>> other
int setPoint;
int pMulti;
int iDiv;
