Callum and Adel's changes on 12/02/19
Dependencies: Crypto
Revision 41:6e730621622b, committed 2019-03-20
- Comitter:
- adehadd
- Date:
- Wed Mar 20 14:37:39 2019 +0000
- Parent:
- 40:9fae84f111e6
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Mar 20 13:49:57 2019 +0000 +++ b/main.cpp Wed Mar 20 14:37:39 2019 +0000 @@ -532,6 +532,7 @@ //~~~Controller constants~~~~ int32_t Kp1=22; //Proportional controller constants int32_t Kp2=22; //Calculated by trial and error to give optimal accuracy + int32_t Ki = 12; float Kd=15.5; @@ -539,7 +540,7 @@ int32_t Yr; //Initialise controller output Yr (r=rotations) int32_t old_pos = 0; - + uint32_t cur_time = 0, old_time = 0, time_diff; @@ -614,9 +615,9 @@ else torque = min(Ys, Yr); - if(torque < 0) { //Variable torque cannot be negative since it sets the PWM + if(torque < 0) //Variable torque cannot be negative since it sets the PWM torque = -torque; lead = -2; //Hence we make the value positive, - } else //and instead set the direction to the opposite one + else //and instead set the direction to the opposite one lead = 2; if(torque > MAXPWM_PRD){ //In case the calculated PWM is higher than our maximum 50% allowance,