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.
Dependents: Nucleo_motors HTU21D_HELLOWORLD Major_dHome pixyMajordhome ... more
Diff: MD25.h
- Revision:
- 1:8046f460a725
- Parent:
- 0:e7f4a9247af2
- Child:
- 2:e575d390c730
diff -r e7f4a9247af2 -r 8046f460a725 MD25.h
--- a/MD25.h Thu May 19 12:42:06 2011 +0000
+++ b/MD25.h Fri May 20 21:18:59 2011 +0000
@@ -1,5 +1,5 @@
// ***********************************************************************
-// Class to control the MD25 Motor Controller.
+// MBED MD25 H-bridge Motor Controller.
//
// Based on Arduino code by Richie Reynolds
// ***********************************************************************
@@ -73,33 +73,91 @@
*/
MD25(PinName sda, PinName scl);
- int32_t getEncoder1();
- int32_t getEncoder2();
+ /** Read encoder for channel 1
+ *
+ * @return 32-bit signed integer value of current encoder value for channel 1
+ */
+ int32_t getEncoder1(void);
+
+ /** Read encoder for channel 2
+ *
+ * @return 32-bit signed integer value of current encoder value for channel 2
+ */
+ int32_t getEncoder2(void);
+
+ /** set speed registers for both channels
+ *
+ * Effect of value is dependent on system mode
+ *
+ * @param speed_1 speed register for channel 1 (0->255)
+ * @param speed_2 speed register for channel 2 (0->255)
+ */
+ void setSpeedRegisters(uint8_t speed_1, uint8_t speed_2);
+
+ /** set speed register for channel 1
+ *
+ * Effect of value is dependent on system mode
+ *
+ * @param speed_1 speed register for channel 1 (0->255)
+ */
void setSpeed1Reg(uint8_t speed);
+
+ /** set speed register for channel 2
+ *
+ * Effect of value is dependent on system mode
+ *
+ * @param speed_2 speed register for channel 2 (0->255)
+ */
void setSpeed2Reg(uint8_t speed);
- void stopMotor1();
- void stopMotor2();
- void stopMotors();
- uint32_t getSoftwareVersion();
- float getBatteryVolts();
- uint8_t getAccelerationRate();
- uint8_t getMotor1Current();
- uint8_t getMotor2Current();
- uint8_t getMotor1Speed();
- uint8_t getMotor2Speed();
- uint8_t getMode();
+
+ /** switch motor 1 off
+ */
+ void stopMotor1(void);
+
+ /** switch motor 2 off
+ */
+ void stopMotor2(void);
+
+ /** switch both motors off
+ */
+ void stopMotors(void);
+
+ /** read current software version
+ *
+ * @return version number
+ */
+ uint32_t getSoftwareVersion(void);
+
+ /** read battery voltage
+ *
+ * Actual voltage = (10 * value)
+ *
+ * @return voltage value in units of 0.1v
+ */
+ float getBatteryVolts(void);
+
+ /** read acceleration rate
+ *
+ * @return acceleration rate
+ */
+ uint8_t getAccelerationRate(void);
+
+ uint8_t getMotor1Current(void);
+ uint8_t getMotor2Current(void);
+ uint8_t getMotor1Speed(void);
+ uint8_t getMotor2Speed(void);
+ uint8_t getMode(void);
void setMode(uint8_t mode);
void setAccelerationRate(uint8_t rate);
- void setSpeedRegisters(uint8_t speed_1, uint8_t speed_2);
void setCommand(uint8_t command);
private:
- I2C _i2c;
- uint8_t current_mode;
+ I2C _i2c;
+ uint8_t current_mode;
uint8_t MD25_i2cAddress;
- uint8_t readRegisterbyte(uint8_t reg);
- void writeRegisterbyte(uint8_t reg, uint8_t value);
+ uint8_t readRegisterbyte(uint8_t reg);
+ void writeRegisterbyte(uint8_t reg, uint8_t value);
};
#endif // MBED_md25_h