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:
- 12:8295c02d740f
- Parent:
- 2:fc869e45e672
--- a/arm.h Wed Nov 02 16:29:13 2016 +0000
+++ b/arm.h Thu Nov 03 13:08:44 2016 +0000
@@ -5,16 +5,17 @@
Constants
*/
+const float pi = 3.14159265359f;
+
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
-const float pi = 3.14159265359f;
-
const float gearRatio = 1/131.25; // Gear ratio of the motor
const int pulsesPerRevolution = 32; // Encoder pulses per revolution
const float outputShaftResolution = pulsesPerRevolution/(gearRatio * 2 * pi); // In counts per rad
@@ -31,7 +32,8 @@
volatile float velocity;
// Real velocity according to the encoder
volatile float encoderVelocity;
-
+ // Maximum allowed velocity in rad/s
+ float maxAllowedVelocity;
// Motor PWM
PwmOut motorControl;
// Motor direction
@@ -45,7 +47,7 @@
void updateEncoderVelocity();
public:
// Constructor
- Arm(float initialLength, PinName motorPWM, PinName motorDir, PinName encoderPin1, PinName encoderPin2);
+ Arm(float initialLength, float maxVelocity, PinName motorPWM, PinName motorDir, PinName encoderPin1, PinName encoderPin2);
// Update instance variables
void update();