As used for motor testing May / June 2016
Dependencies: iC_MU mbed-rtos mbed
Fork of SweptSine by
ServiceKeyboard.cpp@3:463edcfc09c5, 2016-06-08 (annotated)
- Committer:
- acodd
- Date:
- Wed Jun 08 13:56:25 2016 +0000
- Revision:
- 3:463edcfc09c5
As used for scoping motors May / June 2016
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
acodd | 3:463edcfc09c5 | 1 | #include "mbed.h" |
acodd | 3:463edcfc09c5 | 2 | #include "rtos.h" |
acodd | 3:463edcfc09c5 | 3 | #include "MyAxis.h" |
acodd | 3:463edcfc09c5 | 4 | |
acodd | 3:463edcfc09c5 | 5 | |
acodd | 3:463edcfc09c5 | 6 | extern Serial pc; |
acodd | 3:463edcfc09c5 | 7 | extern float DeadBand; |
acodd | 3:463edcfc09c5 | 8 | extern bool scoping; |
acodd | 3:463edcfc09c5 | 9 | extern int scope_duration; |
acodd | 3:463edcfc09c5 | 10 | extern int scope_time; |
acodd | 3:463edcfc09c5 | 11 | extern bool sinusoid; |
acodd | 3:463edcfc09c5 | 12 | extern bool ratiocalc; |
acodd | 3:463edcfc09c5 | 13 | extern float jogaccel_time; |
acodd | 3:463edcfc09c5 | 14 | extern float jogaccel; |
acodd | 3:463edcfc09c5 | 15 | extern int pos_enc_start; |
acodd | 3:463edcfc09c5 | 16 | extern int run_count_jog; |
acodd | 3:463edcfc09c5 | 17 | extern int primed; |
acodd | 3:463edcfc09c5 | 18 | float temp; |
acodd | 3:463edcfc09c5 | 19 | |
acodd | 3:463edcfc09c5 | 20 | |
acodd | 3:463edcfc09c5 | 21 | // Returns the new set point entered via the keyboard |
acodd | 3:463edcfc09c5 | 22 | int ServiceKeyboard () |
acodd | 3:463edcfc09c5 | 23 | { |
acodd | 3:463edcfc09c5 | 24 | int key; // The keypress by the user |
acodd | 3:463edcfc09c5 | 25 | int value = 0; // The variable to return |
acodd | 3:463edcfc09c5 | 26 | |
acodd | 3:463edcfc09c5 | 27 | key = pc.getc(); // Read the intial keypress |
acodd | 3:463edcfc09c5 | 28 | |
acodd | 3:463edcfc09c5 | 29 | switch (key) { |
acodd | 3:463edcfc09c5 | 30 | // List keypresses used: |
acodd | 3:463edcfc09c5 | 31 | case 'q': |
acodd | 3:463edcfc09c5 | 32 | // To move up and down: 8, 2: To move left and right 4,6. To start stop both: 5: |
acodd | 3:463edcfc09c5 | 33 | pc.printf("\n\r Left, Right, Up Down: 4,6,8,2. \n\r Start & Stop both: 5 \n\r Toggle all directions = d \n\r"); |
acodd | 3:463edcfc09c5 | 34 | pc.printf("\n\r Scope = s \n\r Run Test sinusoid = t \n\r Run Ratio Calculator = r \n\r Set Motor Kp = g \n\r Set Sys Kp_Sys = h \n\r Fetch Gain = f \n\r Set Kff_Sys = k \n\r Prime Start Scope = p \n\r Set Kff = 2 \n\r Set Gearbox Ratio = 1 \n\r"); |
acodd | 3:463edcfc09c5 | 35 | pc.printf(" Set Stationary c value = c \n\r Set Moving c value = b \n\r Set Jog_2 value = 3 \n\r \n\r \n\r Jog Speed PAN,TILT = j,m \n\r Set Jog Acceleration = a \n\r Cycle to hard Stop = z \n\r Fade = x \n\r"); |
acodd | 3:463edcfc09c5 | 36 | break; |
acodd | 3:463edcfc09c5 | 37 | |
acodd | 3:463edcfc09c5 | 38 | // Turn on Scope Tool: |
acodd | 3:463edcfc09c5 | 39 | case 's': |
acodd | 3:463edcfc09c5 | 40 | if (!scoping) { |
acodd | 3:463edcfc09c5 | 41 | scope_time = 0; |
acodd | 3:463edcfc09c5 | 42 | scoping = true; |
acodd | 3:463edcfc09c5 | 43 | } else { |
acodd | 3:463edcfc09c5 | 44 | scoping = false; |
acodd | 3:463edcfc09c5 | 45 | } |
acodd | 3:463edcfc09c5 | 46 | break; |
acodd | 3:463edcfc09c5 | 47 | // Turn on Ratio Calculator: |
acodd | 3:463edcfc09c5 | 48 | case 'r': |
acodd | 3:463edcfc09c5 | 49 | if (!ratiocalc) { |
acodd | 3:463edcfc09c5 | 50 | ratiocalc = true; |
acodd | 3:463edcfc09c5 | 51 | pc.printf("\n\r Running Ratio Calculator"); |
acodd | 3:463edcfc09c5 | 52 | } else { |
acodd | 3:463edcfc09c5 | 53 | Tilt.calcmyratio = false; |
acodd | 3:463edcfc09c5 | 54 | Pan.calcmyratio = false; |
acodd | 3:463edcfc09c5 | 55 | } |
acodd | 3:463edcfc09c5 | 56 | break; |
acodd | 3:463edcfc09c5 | 57 | // We are going to jog Tilt up |
acodd | 3:463edcfc09c5 | 58 | case '8': |
acodd | 3:463edcfc09c5 | 59 | Tilt.sysjogdir = -1; |
acodd | 3:463edcfc09c5 | 60 | if (Tilt.moveme) { |
acodd | 3:463edcfc09c5 | 61 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 62 | Tilt.moveme = false; |
acodd | 3:463edcfc09c5 | 63 | } else { |
acodd | 3:463edcfc09c5 | 64 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 65 | Tilt.moveme = true; |
acodd | 3:463edcfc09c5 | 66 | } |
acodd | 3:463edcfc09c5 | 67 | break; |
acodd | 3:463edcfc09c5 | 68 | // We are going to jog Tilt down |
acodd | 3:463edcfc09c5 | 69 | case '2': |
acodd | 3:463edcfc09c5 | 70 | Tilt.sysjogdir = 1; |
acodd | 3:463edcfc09c5 | 71 | if (Tilt.moveme) { |
acodd | 3:463edcfc09c5 | 72 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 73 | Tilt.moveme = false; |
acodd | 3:463edcfc09c5 | 74 | } else { |
acodd | 3:463edcfc09c5 | 75 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 76 | Tilt.moveme = true; |
acodd | 3:463edcfc09c5 | 77 | } |
acodd | 3:463edcfc09c5 | 78 | break; |
acodd | 3:463edcfc09c5 | 79 | // We are going to jog Tilt up |
acodd | 3:463edcfc09c5 | 80 | case '4': |
acodd | 3:463edcfc09c5 | 81 | Pan.sysjogdir = -1; |
acodd | 3:463edcfc09c5 | 82 | if (Pan.moveme) { |
acodd | 3:463edcfc09c5 | 83 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 84 | Pan.moveme = false; |
acodd | 3:463edcfc09c5 | 85 | } else { |
acodd | 3:463edcfc09c5 | 86 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 87 | Pan.moveme = true; |
acodd | 3:463edcfc09c5 | 88 | } |
acodd | 3:463edcfc09c5 | 89 | break; |
acodd | 3:463edcfc09c5 | 90 | // We are going to jog Tilt down |
acodd | 3:463edcfc09c5 | 91 | case '6': |
acodd | 3:463edcfc09c5 | 92 | Pan.sysjogdir = 1; |
acodd | 3:463edcfc09c5 | 93 | if (Pan.moveme) { |
acodd | 3:463edcfc09c5 | 94 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 95 | Pan.moveme = false; |
acodd | 3:463edcfc09c5 | 96 | } else { |
acodd | 3:463edcfc09c5 | 97 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 98 | Pan.moveme = true; |
acodd | 3:463edcfc09c5 | 99 | } |
acodd | 3:463edcfc09c5 | 100 | break; |
acodd | 3:463edcfc09c5 | 101 | // We are going to jog everything |
acodd | 3:463edcfc09c5 | 102 | case '5': |
acodd | 3:463edcfc09c5 | 103 | if (Pan.moveme) { |
acodd | 3:463edcfc09c5 | 104 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 105 | Pan.moveme = false; |
acodd | 3:463edcfc09c5 | 106 | } else { |
acodd | 3:463edcfc09c5 | 107 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 108 | Pan.moveme = true; |
acodd | 3:463edcfc09c5 | 109 | } |
acodd | 3:463edcfc09c5 | 110 | if (Tilt.moveme) { |
acodd | 3:463edcfc09c5 | 111 | //pc.printf("\n\r Moving stop"); |
acodd | 3:463edcfc09c5 | 112 | Tilt.moveme = false; |
acodd | 3:463edcfc09c5 | 113 | } else { |
acodd | 3:463edcfc09c5 | 114 | //pc.printf("\n\r Moving Start"); |
acodd | 3:463edcfc09c5 | 115 | Tilt.moveme = true; |
acodd | 3:463edcfc09c5 | 116 | } |
acodd | 3:463edcfc09c5 | 117 | break; |
acodd | 3:463edcfc09c5 | 118 | // We are going to toggle all directions |
acodd | 3:463edcfc09c5 | 119 | case 'd': |
acodd | 3:463edcfc09c5 | 120 | Pan.sysjogdir = -Pan.sysjogdir; |
acodd | 3:463edcfc09c5 | 121 | Tilt.sysjogdir = -Tilt.sysjogdir; |
acodd | 3:463edcfc09c5 | 122 | break; |
acodd | 3:463edcfc09c5 | 123 | |
acodd | 3:463edcfc09c5 | 124 | // Turn on Potentiometer control: |
acodd | 3:463edcfc09c5 | 125 | case 't': |
acodd | 3:463edcfc09c5 | 126 | if (!sinusoid) { |
acodd | 3:463edcfc09c5 | 127 | pc.printf("\n\r Running sinusoid test"); |
acodd | 3:463edcfc09c5 | 128 | sinusoid = true; |
acodd | 3:463edcfc09c5 | 129 | } else { |
acodd | 3:463edcfc09c5 | 130 | sinusoid = false; |
acodd | 3:463edcfc09c5 | 131 | } |
acodd | 3:463edcfc09c5 | 132 | break; |
acodd | 3:463edcfc09c5 | 133 | // We are going to set the Motor gain |
acodd | 3:463edcfc09c5 | 134 | case 'g': |
acodd | 3:463edcfc09c5 | 135 | pc.printf("\n\r Enter a new Motor Kp gain x 1000: "); |
acodd | 3:463edcfc09c5 | 136 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 137 | do { |
acodd | 3:463edcfc09c5 | 138 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 139 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 140 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 141 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 142 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 143 | } |
acodd | 3:463edcfc09c5 | 144 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 145 | Pan.Kp = value; |
acodd | 3:463edcfc09c5 | 146 | Pan.Kp = Pan.Kp / 1000; |
acodd | 3:463edcfc09c5 | 147 | Tilt.Kp = Pan.Kp; |
acodd | 3:463edcfc09c5 | 148 | //PanVelocityPID.setKp(Kp/1000); |
acodd | 3:463edcfc09c5 | 149 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 150 | break; |
acodd | 3:463edcfc09c5 | 151 | // We are going to set the System gain |
acodd | 3:463edcfc09c5 | 152 | case 'h': |
acodd | 3:463edcfc09c5 | 153 | pc.printf("\n\r Enter a new System Sys_Kp gain x 10000: "); |
acodd | 3:463edcfc09c5 | 154 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 155 | do { |
acodd | 3:463edcfc09c5 | 156 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 157 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 158 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 159 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 160 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 161 | } |
acodd | 3:463edcfc09c5 | 162 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 163 | Pan.Kp_Sys = value; |
acodd | 3:463edcfc09c5 | 164 | Pan.Kp_Sys = Pan.Kp_Sys / 10000; |
acodd | 3:463edcfc09c5 | 165 | Tilt.Kp_Sys = Pan.Kp_Sys; |
acodd | 3:463edcfc09c5 | 166 | //PanVelocityPID.setKp(Kp/1000); |
acodd | 3:463edcfc09c5 | 167 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 168 | break; |
acodd | 3:463edcfc09c5 | 169 | // We are going to confirm what the gain is |
acodd | 3:463edcfc09c5 | 170 | case 'f': |
acodd | 3:463edcfc09c5 | 171 | //Kp = PanVelocityPID.getKp(); |
acodd | 3:463edcfc09c5 | 172 | pc.printf("\n\r Kp = %f, Kff = %f, Kp_Sys = %f, Kff_Sys = %f, Ratio = %f, c_stationary = %f, c_moving = %f, Jog_2 = %f \n\r", Pan.Kp,Pan.Kff,Pan.Kp_Sys,Pan.Kff_Sys,Pan.ratio,Pan.c_stationary, Pan.c_moving, Pan.Jog_2); |
acodd | 3:463edcfc09c5 | 173 | break; |
acodd | 3:463edcfc09c5 | 174 | |
acodd | 3:463edcfc09c5 | 175 | // We are going to set the Jog_2 Value: |
acodd | 3:463edcfc09c5 | 176 | case '3': |
acodd | 3:463edcfc09c5 | 177 | pc.printf("\n\r Enter a new Jog_2 value: "); |
acodd | 3:463edcfc09c5 | 178 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 179 | do { |
acodd | 3:463edcfc09c5 | 180 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 181 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 182 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 183 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 184 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 185 | } |
acodd | 3:463edcfc09c5 | 186 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 187 | Pan.Jog_2 = value; |
acodd | 3:463edcfc09c5 | 188 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 189 | break; |
acodd | 3:463edcfc09c5 | 190 | // We are going to set the new threshold: |
acodd | 3:463edcfc09c5 | 191 | case '1': |
acodd | 3:463edcfc09c5 | 192 | pc.printf("\n\r Enter a new gearbox ratio: "); |
acodd | 3:463edcfc09c5 | 193 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 194 | do { |
acodd | 3:463edcfc09c5 | 195 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 196 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 197 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 198 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 199 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 200 | } |
acodd | 3:463edcfc09c5 | 201 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 202 | Pan.ratio = value; |
acodd | 3:463edcfc09c5 | 203 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 204 | break; |
acodd | 3:463edcfc09c5 | 205 | // We are going to set the Kff gain |
acodd | 3:463edcfc09c5 | 206 | case 'w': |
acodd | 3:463edcfc09c5 | 207 | pc.printf("\n\r Enter a new Kff gain x 100: "); |
acodd | 3:463edcfc09c5 | 208 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 209 | do { |
acodd | 3:463edcfc09c5 | 210 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 211 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 212 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 213 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 214 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 215 | } |
acodd | 3:463edcfc09c5 | 216 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 217 | Pan.Kff = value; |
acodd | 3:463edcfc09c5 | 218 | Pan.Kff = Pan.Kff / 100; |
acodd | 3:463edcfc09c5 | 219 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 220 | break; |
acodd | 3:463edcfc09c5 | 221 | // We are going to set the dead band for the Motor PWM |
acodd | 3:463edcfc09c5 | 222 | case 'k': |
acodd | 3:463edcfc09c5 | 223 | pc.printf("\n\r Enter a new Kff_Sys x 100: "); |
acodd | 3:463edcfc09c5 | 224 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 225 | do { |
acodd | 3:463edcfc09c5 | 226 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 227 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 228 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 229 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 230 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 231 | } |
acodd | 3:463edcfc09c5 | 232 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 233 | temp = value; |
acodd | 3:463edcfc09c5 | 234 | Pan.Kff_Sys = temp / 100; |
acodd | 3:463edcfc09c5 | 235 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 236 | break; |
acodd | 3:463edcfc09c5 | 237 | // We are going to set a stationary c value |
acodd | 3:463edcfc09c5 | 238 | case 'c': |
acodd | 3:463edcfc09c5 | 239 | pc.printf("\n\r Enter a new stationary c value: "); |
acodd | 3:463edcfc09c5 | 240 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 241 | do { |
acodd | 3:463edcfc09c5 | 242 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 243 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 244 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 245 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 246 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 247 | } |
acodd | 3:463edcfc09c5 | 248 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 249 | Pan.c_stationary = value; |
acodd | 3:463edcfc09c5 | 250 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 251 | break; |
acodd | 3:463edcfc09c5 | 252 | // We are going to set a moving b value |
acodd | 3:463edcfc09c5 | 253 | case 'b': |
acodd | 3:463edcfc09c5 | 254 | pc.printf("\n\r Enter a new moving c value: "); |
acodd | 3:463edcfc09c5 | 255 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 256 | do { |
acodd | 3:463edcfc09c5 | 257 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 258 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 259 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 260 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 261 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 262 | } |
acodd | 3:463edcfc09c5 | 263 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 264 | Pan.c_moving = value; |
acodd | 3:463edcfc09c5 | 265 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 266 | break; |
acodd | 3:463edcfc09c5 | 267 | // Set a jog speed |
acodd | 3:463edcfc09c5 | 268 | case 'j': |
acodd | 3:463edcfc09c5 | 269 | pc.printf("\n\r Set Jog PAN speed (Deg/s) x100 "); |
acodd | 3:463edcfc09c5 | 270 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 271 | do { |
acodd | 3:463edcfc09c5 | 272 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 273 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 274 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 275 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 276 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 277 | } |
acodd | 3:463edcfc09c5 | 278 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 279 | Pan.jog = value; |
acodd | 3:463edcfc09c5 | 280 | Pan.jog = (Pan.jog * 0.0145); |
acodd | 3:463edcfc09c5 | 281 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 282 | break; |
acodd | 3:463edcfc09c5 | 283 | // Set a jog speed |
acodd | 3:463edcfc09c5 | 284 | case 'm': |
acodd | 3:463edcfc09c5 | 285 | pc.printf("\n\r Set Jog TILT speed (Deg/s) x100 "); |
acodd | 3:463edcfc09c5 | 286 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 287 | do { |
acodd | 3:463edcfc09c5 | 288 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 289 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 290 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 291 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 292 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 293 | } |
acodd | 3:463edcfc09c5 | 294 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 295 | Tilt.jog = value; |
acodd | 3:463edcfc09c5 | 296 | Tilt.jog = (Tilt.jog * 0.0145); |
acodd | 3:463edcfc09c5 | 297 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 298 | break; |
acodd | 3:463edcfc09c5 | 299 | // Set the jog function to cycle to a stop |
acodd | 3:463edcfc09c5 | 300 | case 'z': |
acodd | 3:463edcfc09c5 | 301 | pc.printf("\n\r Set to ramp to stop \n\r"); |
acodd | 3:463edcfc09c5 | 302 | Pan.ramp = Pan.jog / jogaccel_time; |
acodd | 3:463edcfc09c5 | 303 | Pan.run_count_jog = 0; |
acodd | 3:463edcfc09c5 | 304 | scope_time = 0; |
acodd | 3:463edcfc09c5 | 305 | Pan.setramp = true; |
acodd | 3:463edcfc09c5 | 306 | break; |
acodd | 3:463edcfc09c5 | 307 | // Set a Fade like move |
acodd | 3:463edcfc09c5 | 308 | case 'x': |
acodd | 3:463edcfc09c5 | 309 | pc.printf("\n\r Set to Fade like move \n\r"); |
acodd | 3:463edcfc09c5 | 310 | Pan.ramp = Pan.jog / jogaccel_time; |
acodd | 3:463edcfc09c5 | 311 | Pan.run_count_jog = 0; |
acodd | 3:463edcfc09c5 | 312 | scope_time = 0; |
acodd | 3:463edcfc09c5 | 313 | Pan.setramp_x = true; |
acodd | 3:463edcfc09c5 | 314 | |
acodd | 3:463edcfc09c5 | 315 | Tilt.ramp = Tilt.jog / jogaccel_time; |
acodd | 3:463edcfc09c5 | 316 | Tilt.run_count_jog = 0; |
acodd | 3:463edcfc09c5 | 317 | scope_time = 0; |
acodd | 3:463edcfc09c5 | 318 | Tilt.setramp_x = true; |
acodd | 3:463edcfc09c5 | 319 | break; |
acodd | 3:463edcfc09c5 | 320 | // Set a jog acceleration |
acodd | 3:463edcfc09c5 | 321 | case 'a': |
acodd | 3:463edcfc09c5 | 322 | pc.printf("\n\r Set ramp jogaccel_time, (ms) "); |
acodd | 3:463edcfc09c5 | 323 | //key = pc.getc(); |
acodd | 3:463edcfc09c5 | 324 | do { |
acodd | 3:463edcfc09c5 | 325 | key = pc.getc(); // Wait for a keypress |
acodd | 3:463edcfc09c5 | 326 | if(key >= '0' && key <= '9') { // Check it is a number |
acodd | 3:463edcfc09c5 | 327 | value *= 10; // Index the old number |
acodd | 3:463edcfc09c5 | 328 | value += (key - '0'); // Add on the new number |
acodd | 3:463edcfc09c5 | 329 | pc.printf("%c",key); // Display the new number |
acodd | 3:463edcfc09c5 | 330 | } |
acodd | 3:463edcfc09c5 | 331 | } while(key != 0x0D); |
acodd | 3:463edcfc09c5 | 332 | temp = value; |
acodd | 3:463edcfc09c5 | 333 | jogaccel_time = temp; |
acodd | 3:463edcfc09c5 | 334 | //ramp = ramp / 1000; |
acodd | 3:463edcfc09c5 | 335 | pc.printf("\n\r"); |
acodd | 3:463edcfc09c5 | 336 | break; |
acodd | 3:463edcfc09c5 | 337 | // Prime the scope tool |
acodd | 3:463edcfc09c5 | 338 | case 'p': |
acodd | 3:463edcfc09c5 | 339 | pc.printf("\n\r Prime the scope tool \n\r"); |
acodd | 3:463edcfc09c5 | 340 | primed = true; |
acodd | 3:463edcfc09c5 | 341 | break; |
acodd | 3:463edcfc09c5 | 342 | } |
acodd | 3:463edcfc09c5 | 343 | return(1); |
acodd | 3:463edcfc09c5 | 344 | } |
acodd | 3:463edcfc09c5 | 345 | |
acodd | 3:463edcfc09c5 | 346 | |
acodd | 3:463edcfc09c5 | 347 | |
acodd | 3:463edcfc09c5 | 348 | |
acodd | 3:463edcfc09c5 | 349 |