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
Diff: controls.cpp
- Revision:
- 9:76e4808df4cb
- Parent:
- 7:edd065946e9b
- Child:
- 10:4a825f818432
--- a/controls.cpp Wed Nov 22 06:58:41 2017 +0000 +++ b/controls.cpp Fri Dec 01 21:20:29 2017 +0000 @@ -79,14 +79,19 @@ if(cycle_speed_M1>1) // Can't go over 1 as that is the max speed cycle_speed_M1=1; - if(cycle_speed_M1<0) //Can't go under 0 either + if(cycle_speed_M1<0){ //Can't go under 0 either + // pc.printf("M1: %8.8f\n",cycle_speed_M1); cycle_speed_M1=0; + } if(cycle_speed_M2>1) cycle_speed_M2=1; - if(cycle_speed_M2<0) + if(cycle_speed_M2<0){ + //pc.printf("M2: %8.8f\n",cycle_speed_M2); cycle_speed_M2=0; - - + } + + //pc.printf("m1: %8.8f\n",cycle_speed_M1); + //pc.printf("m2: %8.8f\n",cycle_speed_M2); //adjusting delays based off PID_error corrections pulse_M1 = (pulse_cycle-pulse_cycle*(1-cycle_speed_M1)); period_M1 = (pulse_cycle-pulse_cycle*cycle_speed_M1); @@ -95,11 +100,15 @@ pulse_M2 = (pulse_cycle-pulse_cycle*(1-cycle_speed_M2)); period_M2 = (pulse_cycle-pulse_cycle*cycle_speed_M2); + //pc.printf("pulse2: %8.8f\n", pulse_M1); + // pc.printf("period2: %8.8f\n", period_M1); //controlling the speed for motor 1 if(High_M1) { High_M1=pulse_M1 > T_M1.read_ms(); + //pc.printf("timer m1 move: %8.8f\n",T_M1.read_ms()); if(!High_M1) { //pulse has finished and going LOW dir_control_M1(stall); + pc.printf("timer m1 stall: %f\n",T_M1.read_ms()); T_M1.reset(); //start the delay between pulse (note that it continues counting) } } else {