Callum and Adel's changes on 12/02/19

Dependencies:   Crypto

Files at this revision

API Documentation at this revision

Comitter:
CallumAlder
Date:
Mon Mar 18 19:47:19 2019 +0000
Parent:
35:132413ec3d65
Commit message:
yes

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Mar 18 19:22:27 2019 +0000
+++ b/main.cpp	Mon Mar 18 19:47:19 2019 +0000
@@ -277,12 +277,7 @@
             // Thread t_comm_in(osPriorityAboveNormal, 1024);
             // Thread t_comm_out(osPriorityAboveNormal, 1024);
             // Thread t_motor_ctrl(osPriorityAboveNormal, 1024);
-    
-            motorPower = 300;
-            targetVel = 45.0;
-            targetRot = 459.0;
-    
-    
+     
     
             /*MsgChar = {'m', 'R', 'V', 'r', 'v',
     
@@ -359,6 +354,11 @@
         Thread t_motor_ctrl;    // Thread for motor Control
         
         uint32_t MAXPWM;
+        
+        float motorPower;
+        float targetVel;
+        float targetRot;
+    
     
     public:
     
@@ -385,7 +385,10 @@
             _RUN = false;
             
             MAXPWM = mtrPeriod*dutyC;
-    
+            
+            motorPower = 300;
+            targetVel = 45.0;
+            targetRot = 459.0;
         }
     
     
@@ -494,7 +497,7 @@
             int32_t locMotorPos;                                //Local copy of motor position
             static int32_t oldMotorPos = 0;                     //Old motor position used for calculations
             static uint8_t motorCtrlCounter = 0;                //Counter to be reset every 10 iterations to get velocity calculation in seconds
-            int32_t torque;                                     //Local variable to set motor torque
+            float torque;                                     //Local variable to set motor torque
             float sError;                                       //Velocity error between target and reality
             float rError;                                       //Rotation error between target and reality
             static float rErrorOld;                             //Old rotation error used for calculation