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.
Dependencies: mbed QEI biquadFilter
Diff: arm.h
- Revision:
- 0:494acf21d3bc
- Child:
- 2:fc869e45e672
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/arm.h Mon Oct 31 13:05:53 2016 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+/*
+ Constants
+*/
+
+const bool clockwise = true;
+const bool counterClockwise = false;
+
+const float motorGain = 8.4f; // Rad/s
+const float maxVelocity = 8.4f; // Rad/s (max velocity: 80 rpm = 80*2*pi/60 = 8.4 rad/s)
+const float tick = 0.1f; // In seconds
+const float gearRadius = 5.2f; // In cm
+
+/*
+ Arm class
+*/
+
+class Arm {
+ private:
+ // Instance Variables
+ float length; // Current length of the arm in centimeters
+ float velocity; // Angular velocity in rotations per second
+ PwmOut motorControl;
+ DigitalOut motorDirection;
+ Ticker ticker; // Keeps the arm's instance variables up to date
+ // Methods
+ void setMotor(float motorValue);
+ void doTick();
+ public:
+ // Constructor
+ Arm(float initialLength, PinName motorPWM, PinName motorDir);
+ // Methods
+ float getLength();
+ float getVelocity();
+ void setVelocity(float referenceVelocity);
+
+};
\ No newline at end of file