Control project for the Lift-arm. Works with ROS Melodic

Dependencies:   mbed Servo ros_lib_melodic ULN2003_StepperDriver Async_4pin_Stepper

Revision:
0:441289ea4e29
Child:
3:4b6080e86761
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/MotorControl.h	Thu May 27 18:36:23 2021 +0000
@@ -0,0 +1,48 @@
+#ifndef KARBOT_MOTOR_CONTROL_H
+#define KARBOT_MOTOR_CONTROL_H
+
+/* Karbot motor control class
+ * Written by Simon Krogedal
+ * 27/05/21
+ * Team 9 4th Year project
+ * 
+ * for NUCLEO-F401RE
+ * 
+ */
+ 
+ #include "mbed.h"
+ #include "encoder.h"
+ #include "motor.h"
+ 
+class MotorControl : public encoder {                                   //controls the speed of an individual motor, helping the system keep symmetric with asymmetric components
+    private:
+        motor*      mot;
+        
+        double      Kp, Ki, r_speed, r_clicks, max_speed, output, acc_err;
+        bool        dir, max_out;                                       //driving direction and error flag
+        
+        double getError(void);
+        
+        void algorithm(void);
+    
+    public:
+        MotorControl(PinName a, PinName b, PinName i, int r, bool c, double p, motor* m, double ms, double kp, double ki, double ec);
+        
+        void setSpeed(double s);
+        void drive(void);
+        
+        void stop(void);
+        
+        void driveManual(void);
+        
+        void samplecall(void);
+        
+        void setK(double k);
+
+        void start(void);       //this function is overridden to avoid bugs
+//      double getError(void);
+        double getOutput(void);
+        bool checkFlag(void);
+};
+
+#endif
\ No newline at end of file