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: FastPWM HIDScope MODSERIAL QEI Matrix biquadFilter controller errorFetch mbed motorConfig refGen MatrixMath inverseKinematics
Fork of Minor_test_serial by
Revision 30:65f0c9ecf810, committed 2017-10-16
- Comitter:
- tvlogman
- Date:
- Mon Oct 16 09:42:04 2017 +0000
- Parent:
- 29:9aa4d63a9bd1
- Child:
- 31:cc08254ab7b5
- Commit message:
- Now with the controller contained in a seperate library;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controller.lib Mon Oct 16 09:42:04 2017 +0000 @@ -0,0 +1,1 @@ +controller#229271adbb37
--- a/main.cpp Mon Oct 16 08:45:03 2017 +0000
+++ b/main.cpp Mon Oct 16 09:42:04 2017 +0000
@@ -4,6 +4,7 @@
#include "QEI.h"
#include "FastPWM.h"
#include "refGen.h"
+#include "controller.h"
// Defining relevant constant parameters
const float gearRatio = 131;
@@ -107,11 +108,7 @@
}
// motorController sets a motorValue based on the position error. Sign indicates direction and magnitude indicates speed. Right now this is a simple feedforward
-float motorController(float e_pos, float e_int, float e_der){
- float motorValue;
- motorValue = k_p*e_pos + k_d*e_der + k_i*e_int;
- return motorValue;
- }
+controller motorController1(k_p, k_d, k_i);
// setMotor1 sets the direction and magnitude pins of motor1 depending on the given motorValue. Negative motorValue means clockwise rotation
void setMotor1(float motorValue){
@@ -158,7 +155,7 @@
void measureAndControl(){
getError(e_pos, e_int, e_der);
- float motorValue = motorController(e_pos, e_int, e_der);
+ float motorValue = motorController1.control(e_pos, e_int, e_der);
float r = ref.getReferencePosition(maxAngle, r_direction);
sendDataToPc(r, e_pos, e_int, e_der, motorValue);
pc.printf("Motorvalue is %.2f \r\n", motorValue);
--- a/refGen.lib Mon Oct 16 08:45:03 2017 +0000 +++ b/refGen.lib Mon Oct 16 09:42:04 2017 +0000 @@ -1,1 +1,1 @@ -refGen#5c67195a412d +refGen#ac2d82dfd334
