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 4:2b77f4656e92, committed 2013-09-15
- Comitter:
- mlaane
- Date:
- Sun Sep 15 14:57:03 2013 +0000
- Parent:
- 3:94db629c0a83
- Child:
- 6:37199f371bf8
- Commit message:
- documentation; moved setPWM to private methods
Changed in this revision
| motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/motor.h Sat Sep 14 17:18:51 2013 +0000
+++ b/motor.h Sun Sep 15 14:57:03 2013 +0000
@@ -4,14 +4,32 @@
#include "mbed.h"
#include "PCA9555.h"
#include "qed.h"
-
+ /** Class for controlling motors trough PCA9555 */
class Motor {
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();
private:
@@ -26,6 +44,12 @@
void resetPID();
+ /** Set pwm duty cycle
+ *
+ * @param newPWM Duty cycle
+ */
+ void setPWM(int newPWM);
+
//void pid();
int setPoint;
