PID Motor Position Control using ESP8266 WiFi Module, US Digital E4P-100-079, LMD18200 H-Bridge Break Out, and HN-GH12-1634T 30:1 200RPM Motor
Dependencies: 4DGL-uLCD-SE PID QEI SDFileSystem mbed ESP8266_pid_mtrPos_webserver_SDcard_v2
Dependents: ESP8266_pid_mtrPos_webserver_SDcard_v2
main.cpp@3:6067780e2f45, 2015-11-25 (annotated)
- Committer:
- electromotivated
- Date:
- Wed Nov 25 01:33:27 2015 +0000
- Revision:
- 3:6067780e2f45
- Parent:
- 2:af4befcd02d6
- Child:
- 5:2c728eb9bc80
More comments... oh and commented out printf statements that were used for debugging;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
electromotivated | 0:a2a238159653 | 1 | /* |
electromotivated | 0:a2a238159653 | 2 | Uses the ESP8266 WiFi Chip to set up a WiFi Webserver used to control |
electromotivated | 2:af4befcd02d6 | 3 | the position of a motor using a PID controller. USE FIREFOX Web |
electromotivated | 2:af4befcd02d6 | 4 | Browser |
electromotivated | 0:a2a238159653 | 5 | |
electromotivated | 2:af4befcd02d6 | 6 | NOTES: |
electromotivated | 2:af4befcd02d6 | 7 | 1. Webpage Handling in this program is specific to a CUSTOM |
electromotivated | 0:a2a238159653 | 8 | WEBPAGE. Program must be modified to handle specfically a new |
electromotivated | 0:a2a238159653 | 9 | webpage. A copy of the webpage for this program can be found at |
electromotivated | 0:a2a238159653 | 10 | the end of this program page. Simply copy and past text into a |
electromotivated | 0:a2a238159653 | 11 | html file and save as the given name. |
electromotivated | 0:a2a238159653 | 12 | |
electromotivated | 2:af4befcd02d6 | 13 | 2. Developed and tested with FireFox 42.0 Web Browser. Does not seem to work |
electromotivated | 2:af4befcd02d6 | 14 | well with Google Chrome or Internet Explorer for some reason... they seem |
electromotivated | 2:af4befcd02d6 | 15 | to generate two post requests which messes with the user input values. |
electromotivated | 3:6067780e2f45 | 16 | |
electromotivated | 3:6067780e2f45 | 17 | 3. There are a bunch of printf statements in the code that can be |
electromotivated | 3:6067780e2f45 | 18 | uncommented for debugging in a serial terminal progrom. |
electromotivated | 2:af4befcd02d6 | 19 | |
electromotivated | 2:af4befcd02d6 | 20 | |
electromotivated | 0:a2a238159653 | 21 | TODO: ESP8366 has a max packet send size. Make sure we implement |
electromotivated | 0:a2a238159653 | 22 | a method to send webpages that exceed this value. The max size is |
electromotivated | 0:a2a238159653 | 23 | listed in the official ESP8266 AT Commands Documentation, I think |
electromotivated | 0:a2a238159653 | 24 | it is 2048 bytes/chars |
electromotivated | 0:a2a238159653 | 25 | |
electromotivated | 3:6067780e2f45 | 26 | TODO: CREATE CONFIG FUNCTION TO SET SSID, PASSWORD, BAUDRATE ETC. |
electromotivated | 3:6067780e2f45 | 27 | Perhaps have a serial terminal method to take user input, and |
electromotivated | 3:6067780e2f45 | 28 | put the function call into a #ifdef WiFiConfig statement, so |
electromotivated | 3:6067780e2f45 | 29 | that the user can enable it to config Wifi module then turn |
electromotivated | 3:6067780e2f45 | 30 | it off once Wifi module is configed so that this program can |
electromotivated | 3:6067780e2f45 | 31 | run in a "stand alone" mode. |
electromotivated | 0:a2a238159653 | 32 | |
electromotivated | 3:6067780e2f45 | 33 | TODO: Move debugging printf statements inside of #ifdef DEBUG |
electromotivated | 3:6067780e2f45 | 34 | statements, so that serial terminal print statements can be |
electromotivated | 3:6067780e2f45 | 35 | turned on and off easily for debugging. |
electromotivated | 0:a2a238159653 | 36 | */ |
electromotivated | 0:a2a238159653 | 37 | |
electromotivated | 0:a2a238159653 | 38 | |
electromotivated | 0:a2a238159653 | 39 | #include "mbed.h" |
electromotivated | 0:a2a238159653 | 40 | #include "SDFileSystem.h" |
electromotivated | 0:a2a238159653 | 41 | #include "PID.h" |
electromotivated | 0:a2a238159653 | 42 | #include "QEI.h" |
electromotivated | 0:a2a238159653 | 43 | #include <algorithm> |
electromotivated | 0:a2a238159653 | 44 | |
electromotivated | 0:a2a238159653 | 45 | /**********WEB SERVER SPECIFIC DECLARTATIONS**********************************/ |
electromotivated | 0:a2a238159653 | 46 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 47 | SDFileSystem sd(p5,p6,p7,p8,"sd"); // MOSI, MISO, SCLK, CS, |
electromotivated | 0:a2a238159653 | 48 | // Virtual File System Name |
electromotivated | 0:a2a238159653 | 49 | Serial esp(p13, p14); // tx, rx |
electromotivated | 0:a2a238159653 | 50 | DigitalOut espRstPin(p26); // ESP Reset |
electromotivated | 0:a2a238159653 | 51 | DigitalOut led(LED4); |
electromotivated | 0:a2a238159653 | 52 | |
electromotivated | 0:a2a238159653 | 53 | Timer t1; |
electromotivated | 0:a2a238159653 | 54 | Timer t2; |
electromotivated | 0:a2a238159653 | 55 | |
electromotivated | 0:a2a238159653 | 56 | void init(char* buffer, int size); |
electromotivated | 0:a2a238159653 | 57 | void getreply(int timeout_ms, char* buffer, int size, int numBytes); |
electromotivated | 0:a2a238159653 | 58 | void startserver(char* buffer, int size); |
electromotivated | 0:a2a238159653 | 59 | void update_webpage(char* webpage, float setpoint, float kp, float ki, float kd); |
electromotivated | 0:a2a238159653 | 60 | void parse_input(char* webpage_user_data, float* setpoint, float* kp, float* ki, float* kd); |
electromotivated | 0:a2a238159653 | 61 | int port =80; // set server port |
electromotivated | 0:a2a238159653 | 62 | int serverTimeout_secs =5; // set server timeout in seconds in case |
electromotivated | 0:a2a238159653 | 63 | // link breaks. |
electromotivated | 0:a2a238159653 | 64 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 65 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 66 | |
electromotivated | 0:a2a238159653 | 67 | /*********PID CONTROLLER SPECIFIC DECLARATIONS********************************/ |
electromotivated | 0:a2a238159653 | 68 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 69 | static float setpoint, feedback, output; |
electromotivated | 0:a2a238159653 | 70 | const float output_lower_limit = -1.0; |
electromotivated | 0:a2a238159653 | 71 | const float output_upper_limit = 1.0; |
electromotivated | 0:a2a238159653 | 72 | const float FEEDBACK_SCALE = 1.0/3000.0; // Scale feedback to 1rev/3000cnts |
electromotivated | 0:a2a238159653 | 73 | // this is encoder specific. |
electromotivated | 0:a2a238159653 | 74 | const float setpoint_init = 0.0; |
electromotivated | 0:a2a238159653 | 75 | const float kp_init = 2.5; |
electromotivated | 0:a2a238159653 | 76 | const float ki_init = 5.0; |
electromotivated | 0:a2a238159653 | 77 | const float kd_init = 0.5; |
electromotivated | 0:a2a238159653 | 78 | const float Ts_init = 0.04; // 25Hz Sample Freq (40ms Sample Time) |
electromotivated | 0:a2a238159653 | 79 | |
electromotivated | 0:a2a238159653 | 80 | PID pid(&setpoint, &feedback, &output, output_lower_limit, output_upper_limit, |
electromotivated | 0:a2a238159653 | 81 | kp_init, ki_init, kd_init, Ts_init); |
electromotivated | 0:a2a238159653 | 82 | QEI encoder(p15, p16); |
electromotivated | 0:a2a238159653 | 83 | PwmOut mtr_pwm(p25); |
electromotivated | 0:a2a238159653 | 84 | DigitalOut mtr_dir(p24); |
electromotivated | 0:a2a238159653 | 85 | void pid_callback(); // Updates encoder feedback and motor output |
electromotivated | 0:a2a238159653 | 86 | Ticker motor; |
electromotivated | 0:a2a238159653 | 87 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 88 | /*****************************************************************************/ |
electromotivated | 0:a2a238159653 | 89 | |
electromotivated | 0:a2a238159653 | 90 | // Common Application Declarations |
electromotivated | 0:a2a238159653 | 91 | Serial pc(USBTX, USBRX); |
electromotivated | 0:a2a238159653 | 92 | float clip(float value, float lower, float upper); |
electromotivated | 0:a2a238159653 | 93 | |
electromotivated | 0:a2a238159653 | 94 | int main() |
electromotivated | 0:a2a238159653 | 95 | { |
electromotivated | 0:a2a238159653 | 96 | printf("Starting\n"); |
electromotivated | 0:a2a238159653 | 97 | |
electromotivated | 0:a2a238159653 | 98 | /****************** Load Webpage from SD Card***************************************/ |
electromotivated | 0:a2a238159653 | 99 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 100 | char file[] = "/sd/pid_pos.html"; |
electromotivated | 0:a2a238159653 | 101 | |
electromotivated | 0:a2a238159653 | 102 | // Get file size so we can dynamically allocate buffer size |
electromotivated | 0:a2a238159653 | 103 | int num_chars = 0; |
electromotivated | 0:a2a238159653 | 104 | FILE *fp = fopen(file, "r"); |
electromotivated | 0:a2a238159653 | 105 | while(!feof(fp)){ |
electromotivated | 0:a2a238159653 | 106 | fgetc(fp); |
electromotivated | 0:a2a238159653 | 107 | num_chars++; |
electromotivated | 0:a2a238159653 | 108 | } |
electromotivated | 0:a2a238159653 | 109 | rewind(fp); // Go to beginning of file |
electromotivated | 0:a2a238159653 | 110 | |
electromotivated | 0:a2a238159653 | 111 | // printf("Webpage Data Size: %d byte\r\n", num_chars); |
electromotivated | 0:a2a238159653 | 112 | |
electromotivated | 0:a2a238159653 | 113 | const int WEBPAGE_SIZE = num_chars; |
electromotivated | 0:a2a238159653 | 114 | char webpage[WEBPAGE_SIZE]; |
electromotivated | 0:a2a238159653 | 115 | webpage[0] = NULL; // Init our array so that element zero contains a null |
electromotivated | 0:a2a238159653 | 116 | // This is important, ensures strings are placed into |
electromotivated | 0:a2a238159653 | 117 | // buffer starting at element 0... not some random |
electromotivated | 0:a2a238159653 | 118 | // elment |
electromotivated | 0:a2a238159653 | 119 | // Read in and buffer file to memory |
electromotivated | 0:a2a238159653 | 120 | if(fp == NULL){ |
electromotivated | 0:a2a238159653 | 121 | printf("Error: No Such File or something :("); |
electromotivated | 0:a2a238159653 | 122 | return 1; |
electromotivated | 0:a2a238159653 | 123 | } |
electromotivated | 0:a2a238159653 | 124 | else{ |
electromotivated | 0:a2a238159653 | 125 | while(!feof(fp)){ |
electromotivated | 0:a2a238159653 | 126 | fgets(webpage + strlen(webpage), WEBPAGE_SIZE, fp); // Get a string from stream, add to buffer |
electromotivated | 0:a2a238159653 | 127 | } |
electromotivated | 0:a2a238159653 | 128 | } |
electromotivated | 0:a2a238159653 | 129 | fclose(fp); |
electromotivated | 0:a2a238159653 | 130 | printf("Webpage Buffer Size: %d bytes\r\n", sizeof(webpage)); |
electromotivated | 0:a2a238159653 | 131 | update_webpage(webpage, setpoint, kp_init, ki_init, kd_init); |
electromotivated | 0:a2a238159653 | 132 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 133 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 134 | |
electromotivated | 0:a2a238159653 | 135 | /***************BRING UP SERVER*****************************************************/ |
electromotivated | 0:a2a238159653 | 136 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 137 | char buff[5000]; // Working buffer |
electromotivated | 0:a2a238159653 | 138 | init(buff, sizeof(buff)); // Init ESP8266 |
electromotivated | 0:a2a238159653 | 139 | |
electromotivated | 0:a2a238159653 | 140 | esp.baud(115200); // ESP8266 baudrate. Maximum on KLxx' is 115200, 230400 works on K20 and K22F |
electromotivated | 0:a2a238159653 | 141 | |
electromotivated | 0:a2a238159653 | 142 | startserver(buff, sizeof(buff)); // Configure the ESP8266 and Setup as Server |
electromotivated | 0:a2a238159653 | 143 | |
electromotivated | 0:a2a238159653 | 144 | printf(buff); // If start successful buff contains IP address... |
electromotivated | 0:a2a238159653 | 145 | // if not if contains an error. |
electromotivated | 0:a2a238159653 | 146 | led =1; |
electromotivated | 0:a2a238159653 | 147 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 148 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 149 | |
electromotivated | 0:a2a238159653 | 150 | /************Initialize the PID*****************************************************/ |
electromotivated | 0:a2a238159653 | 151 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 152 | // Working paramater variables |
electromotivated | 0:a2a238159653 | 153 | setpoint = setpoint_init; |
electromotivated | 1:26a13ee574e9 | 154 | encoder.reset(); |
electromotivated | 0:a2a238159653 | 155 | feedback = encoder.read(); |
electromotivated | 0:a2a238159653 | 156 | float kp = kp_init; |
electromotivated | 0:a2a238159653 | 157 | float ki = ki_init; |
electromotivated | 0:a2a238159653 | 158 | float kd = kd_init; |
electromotivated | 0:a2a238159653 | 159 | pid.set_parameters(kp, ki, kd, Ts_init); |
electromotivated | 0:a2a238159653 | 160 | |
electromotivated | 0:a2a238159653 | 161 | // Init the motor |
electromotivated | 0:a2a238159653 | 162 | mtr_dir = 0; // Can be 0 or 1, sets the direction |
electromotivated | 0:a2a238159653 | 163 | mtr_pwm = 0.0; |
electromotivated | 0:a2a238159653 | 164 | |
electromotivated | 0:a2a238159653 | 165 | // Clear encoder count |
electromotivated | 0:a2a238159653 | 166 | encoder.reset(); |
electromotivated | 0:a2a238159653 | 167 | |
electromotivated | 0:a2a238159653 | 168 | // Update sensors and feedback twice as fast as PID sample time |
electromotivated | 0:a2a238159653 | 169 | // this makes pid react in real-time avoiding errors due to |
electromotivated | 0:a2a238159653 | 170 | // missing counts etc. |
electromotivated | 0:a2a238159653 | 171 | motor.attach(&pid_callback, Ts_init/2.0); |
electromotivated | 0:a2a238159653 | 172 | |
electromotivated | 0:a2a238159653 | 173 | // Start PID sampling |
electromotivated | 0:a2a238159653 | 174 | pid.start(); |
electromotivated | 0:a2a238159653 | 175 | |
electromotivated | 0:a2a238159653 | 176 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 177 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 178 | |
electromotivated | 0:a2a238159653 | 179 | while(1){ |
electromotivated | 0:a2a238159653 | 180 | /**************SERVICE WEBPAGE******************************************************/ |
electromotivated | 0:a2a238159653 | 181 | /***********************************************************************************/ |
electromotivated | 0:a2a238159653 | 182 | if(esp.readable()){ |
electromotivated | 0:a2a238159653 | 183 | getreply(500, buff, sizeof(buff), sizeof(buff) -1); // Get full buff, leave last element for null char |
electromotivated | 0:a2a238159653 | 184 | // printf("\r\n*************WORKING BUFFER******************************\r\n"); |
electromotivated | 3:6067780e2f45 | 185 | // printf(buff); printf("\n"); |
electromotivated | 0:a2a238159653 | 186 | // printf("\r\n**************END WORKING BUFFER**************************\r\n"); |
electromotivated | 0:a2a238159653 | 187 | |
electromotivated | 0:a2a238159653 | 188 | // If Recieved Data get ID, Length, and Data |
electromotivated | 0:a2a238159653 | 189 | char* rqstPnt = strstr(buff, "+IPD"); |
electromotivated | 0:a2a238159653 | 190 | if(rqstPnt != NULL){ |
electromotivated | 0:a2a238159653 | 191 | int id, len; |
electromotivated | 0:a2a238159653 | 192 | char type[10]; memset(type, '\0', sizeof(type)); // Create and null out data buff |
electromotivated | 0:a2a238159653 | 193 | sscanf(rqstPnt, "+IPD,%d,%d:%s ", &id, &len, type); |
electromotivated | 0:a2a238159653 | 194 | // printf("ID: %i\nLen: %i\nType: %s\n", id, len, type); |
electromotivated | 0:a2a238159653 | 195 | |
electromotivated | 0:a2a238159653 | 196 | // If GET or POST request "type" parse and update user input then send webpage |
electromotivated | 0:a2a238159653 | 197 | if(strstr(type, "GET") != NULL || strstr(type, "POST") != NULL){ |
electromotivated | 0:a2a238159653 | 198 | // printf("I got web request\n"); |
electromotivated | 0:a2a238159653 | 199 | |
electromotivated | 0:a2a238159653 | 200 | /* Read Webpage <Form> data sent using "method=POST"... |
electromotivated | 0:a2a238159653 | 201 | Note: Input elements in the <Form> need a set name attribute to |
electromotivated | 0:a2a238159653 | 202 | appear in the returned HTML body. Thus to "POST" data ensure: |
electromotivated | 0:a2a238159653 | 203 | <Form method="POST"> <input type="xxx" name="xxx" value="xxx"> |
electromotivated | 0:a2a238159653 | 204 | <input type="xxx" value="xxx"> </Form> |
electromotivated | 0:a2a238159653 | 205 | Only the input with name="xxx" will appear in body of HTML |
electromotivated | 0:a2a238159653 | 206 | */ |
electromotivated | 3:6067780e2f45 | 207 | // printf("\r\n*************USER INPUT**********************************\r\n"); |
electromotivated | 0:a2a238159653 | 208 | parse_input(buff, &setpoint, &kp, &ki, &kd); |
electromotivated | 0:a2a238159653 | 209 | setpoint = clip(setpoint, -999.99, 999.99); |
electromotivated | 0:a2a238159653 | 210 | kp = clip(kp, 0.00, 999.99); |
electromotivated | 0:a2a238159653 | 211 | ki = clip(ki, 0.00, 999.99); |
electromotivated | 0:a2a238159653 | 212 | kd = clip(kd, 0.00, 999.99); |
electromotivated | 3:6067780e2f45 | 213 | // printf("User Entered: \nSetpoint: %7.2f\nKp: %6.2f\nKi: %6.2f\nKd: %6.2f\n", setpoint, kp, ki, kd); |
electromotivated | 0:a2a238159653 | 214 | pid.set_parameters(kp, ki, kd, Ts_init); // Updata PID params |
electromotivated | 3:6067780e2f45 | 215 | // printf("Updated to Kp: %1.2f Ki: %1.2f Kd: %1.2f Ts: %1.2f\r\n", |
electromotivated | 3:6067780e2f45 | 216 | // pid.getKp(), pid.getKi(), pid.getKd(), pid.getTs()); |
electromotivated | 3:6067780e2f45 | 217 | // printf("Setpoint: %1.2f\r\n", setpoint); |
electromotivated | 3:6067780e2f45 | 218 | // printf("Output: %1.2f\r\n", output); |
electromotivated | 3:6067780e2f45 | 219 | // printf("\r\n*************END USER INPUT******************************\r\n"); |
electromotivated | 0:a2a238159653 | 220 | |
electromotivated | 0:a2a238159653 | 221 | // Update Webpage to reflect new values POSTED by client |
electromotivated | 0:a2a238159653 | 222 | static bool isFirstRequest = true; |
electromotivated | 0:a2a238159653 | 223 | if(!isFirstRequest) update_webpage(webpage, setpoint, kp, ki, kd); |
electromotivated | 0:a2a238159653 | 224 | else isFirstRequest = false; // First Request just send page with initial values |
electromotivated | 3:6067780e2f45 | 225 | // printf(webpage); // DEBUGGING ONLY!!! REMOVE FOR RELEASE!!! |
electromotivated | 0:a2a238159653 | 226 | |
electromotivated | 0:a2a238159653 | 227 | // Command TCP/IP Data Tx |
electromotivated | 0:a2a238159653 | 228 | esp.printf("AT+CIPSEND=%d,%d\r\n", id, strlen(webpage)); |
electromotivated | 0:a2a238159653 | 229 | getreply(200, buff, sizeof(buff), 15); /*TODO: Wait for "OK\r\n>"*/ |
electromotivated | 0:a2a238159653 | 230 | // printf(buff); printf("\n"); |
electromotivated | 0:a2a238159653 | 231 | |
electromotivated | 0:a2a238159653 | 232 | // Send webpage |
electromotivated | 0:a2a238159653 | 233 | // while(!esp.writeable()); // Wait until esp ready to send data |
electromotivated | 0:a2a238159653 | 234 | int idx = 0; |
electromotivated | 0:a2a238159653 | 235 | while(webpage[idx] != '\0'){ |
electromotivated | 0:a2a238159653 | 236 | esp.putc(webpage[idx]); |
electromotivated | 0:a2a238159653 | 237 | idx++; |
electromotivated | 0:a2a238159653 | 238 | } |
electromotivated | 0:a2a238159653 | 239 | |
electromotivated | 0:a2a238159653 | 240 | // Check status - Success: close channel and update PID controller, Error: reconnect |
electromotivated | 0:a2a238159653 | 241 | bool weberror = true; |
electromotivated | 0:a2a238159653 | 242 | t2.reset(); t2.start(); |
electromotivated | 0:a2a238159653 | 243 | while(weberror ==1 && t2.read_ms() < 5000){ |
electromotivated | 0:a2a238159653 | 244 | getreply(500, buff, sizeof(buff), 24); |
electromotivated | 0:a2a238159653 | 245 | if(strstr(buff, "SEND OK") != NULL) weberror = false; |
electromotivated | 0:a2a238159653 | 246 | } |
electromotivated | 0:a2a238159653 | 247 | if(weberror){ |
electromotivated | 0:a2a238159653 | 248 | esp.printf("AT+CIPMUX=1\r\n"); |
electromotivated | 0:a2a238159653 | 249 | getreply(500, buff, sizeof(buff), 10); |
electromotivated | 0:a2a238159653 | 250 | // printf(buff); printf("\n"); |
electromotivated | 0:a2a238159653 | 251 | |
electromotivated | 0:a2a238159653 | 252 | esp.printf("AT+CIPSERVER=1,%d\r\n", port); |
electromotivated | 0:a2a238159653 | 253 | getreply(500, buff, sizeof(buff), 10); |
electromotivated | 0:a2a238159653 | 254 | // printf(buff); printf("\n"); |
electromotivated | 0:a2a238159653 | 255 | } |
electromotivated | 0:a2a238159653 | 256 | else{ |
electromotivated | 0:a2a238159653 | 257 | esp.printf("AT+CIPCLOSE=%d\r\n", id); // Notice id is an int formatted to string |
electromotivated | 0:a2a238159653 | 258 | getreply(500, buff, sizeof(buff), 24); |
electromotivated | 0:a2a238159653 | 259 | // printf(buff); printf("\n"); |
electromotivated | 0:a2a238159653 | 260 | } |
electromotivated | 0:a2a238159653 | 261 | } |
electromotivated | 0:a2a238159653 | 262 | } |
electromotivated | 0:a2a238159653 | 263 | } |
electromotivated | 0:a2a238159653 | 264 | /*********************************************************************/ |
electromotivated | 0:a2a238159653 | 265 | /*********************************************************************/ |
electromotivated | 0:a2a238159653 | 266 | |
electromotivated | 0:a2a238159653 | 267 | |
electromotivated | 0:a2a238159653 | 268 | } |
electromotivated | 0:a2a238159653 | 269 | } |
electromotivated | 0:a2a238159653 | 270 | |
electromotivated | 0:a2a238159653 | 271 | // Initialize ESP8266 |
electromotivated | 0:a2a238159653 | 272 | void init(char* buffer, int size){ |
electromotivated | 0:a2a238159653 | 273 | // Hardware Reset ESP |
electromotivated | 0:a2a238159653 | 274 | espRstPin=0; |
electromotivated | 0:a2a238159653 | 275 | wait(0.5); |
electromotivated | 0:a2a238159653 | 276 | espRstPin=1; |
electromotivated | 0:a2a238159653 | 277 | // Get start up junk from ESP8266 |
electromotivated | 0:a2a238159653 | 278 | getreply(6000, buffer, size, 500); |
electromotivated | 0:a2a238159653 | 279 | } |
electromotivated | 0:a2a238159653 | 280 | |
electromotivated | 0:a2a238159653 | 281 | // Get Command and ESP status replies |
electromotivated | 0:a2a238159653 | 282 | void getreply(int timeout_ms, char* buffer, int size, int numBytes) |
electromotivated | 0:a2a238159653 | 283 | { |
electromotivated | 0:a2a238159653 | 284 | memset(buffer, '\0', size); // Null out buffer |
electromotivated | 0:a2a238159653 | 285 | t1.reset(); |
electromotivated | 0:a2a238159653 | 286 | t1.start(); |
electromotivated | 0:a2a238159653 | 287 | int idx = 0; |
electromotivated | 0:a2a238159653 | 288 | while(t1.read_ms()< timeout_ms && idx < numBytes) { |
electromotivated | 0:a2a238159653 | 289 | if(esp.readable()) { |
electromotivated | 0:a2a238159653 | 290 | buffer[idx] = esp.getc(); |
electromotivated | 0:a2a238159653 | 291 | idx++; |
electromotivated | 0:a2a238159653 | 292 | } |
electromotivated | 0:a2a238159653 | 293 | } |
electromotivated | 0:a2a238159653 | 294 | t1.stop(); |
electromotivated | 0:a2a238159653 | 295 | } |
electromotivated | 0:a2a238159653 | 296 | |
electromotivated | 0:a2a238159653 | 297 | // Starts and restarts webserver if errors detected. |
electromotivated | 0:a2a238159653 | 298 | void startserver(char* buffer, int size) |
electromotivated | 0:a2a238159653 | 299 | { |
electromotivated | 0:a2a238159653 | 300 | esp.printf("AT+RST\r\n"); // BWW: Reset the ESP8266 |
electromotivated | 0:a2a238159653 | 301 | getreply(8000, buffer, size, 1000); |
electromotivated | 0:a2a238159653 | 302 | |
electromotivated | 0:a2a238159653 | 303 | if (strstr(buffer, "OK") != NULL) { |
electromotivated | 0:a2a238159653 | 304 | // BWW: Set ESP8266 for multiple connections |
electromotivated | 0:a2a238159653 | 305 | esp.printf("AT+CIPMUX=1\r\n"); |
electromotivated | 0:a2a238159653 | 306 | getreply(500, buffer, size, 20); |
electromotivated | 0:a2a238159653 | 307 | |
electromotivated | 0:a2a238159653 | 308 | // BWW: Set ESP8266 as Server on given port |
electromotivated | 0:a2a238159653 | 309 | esp.printf("AT+CIPSERVER=1,%d\r\n", port); |
electromotivated | 0:a2a238159653 | 310 | getreply(500, buffer, size, 20); // BWW: Wait for reply |
electromotivated | 0:a2a238159653 | 311 | |
electromotivated | 0:a2a238159653 | 312 | // wait(1); |
electromotivated | 0:a2a238159653 | 313 | |
electromotivated | 0:a2a238159653 | 314 | // BWW: Set ESP8266 Server Timeout |
electromotivated | 0:a2a238159653 | 315 | esp.printf("AT+CIPSTO=%d\r\n", serverTimeout_secs); |
electromotivated | 0:a2a238159653 | 316 | getreply(500, buffer, size, 50); // BWW: Wait for reply |
electromotivated | 0:a2a238159653 | 317 | |
electromotivated | 0:a2a238159653 | 318 | // wait(5); |
electromotivated | 0:a2a238159653 | 319 | |
electromotivated | 0:a2a238159653 | 320 | // BWW: Request IP Address from router for ESP8266 |
electromotivated | 0:a2a238159653 | 321 | int weberror = 0; |
electromotivated | 0:a2a238159653 | 322 | while(weberror==0) { |
electromotivated | 0:a2a238159653 | 323 | esp.printf("AT+CIFSR\r\n"); |
electromotivated | 0:a2a238159653 | 324 | getreply(2500, buffer, size, 200); |
electromotivated | 0:a2a238159653 | 325 | if(strstr(buffer, "0.0.0.0") == NULL) { |
electromotivated | 0:a2a238159653 | 326 | weberror=1; // wait for valid IP |
electromotivated | 0:a2a238159653 | 327 | } |
electromotivated | 0:a2a238159653 | 328 | } |
electromotivated | 0:a2a238159653 | 329 | } |
electromotivated | 0:a2a238159653 | 330 | // else ESP8266 did not reply "OK" something is messed up |
electromotivated | 0:a2a238159653 | 331 | else { |
electromotivated | 0:a2a238159653 | 332 | strcpy(buffer, "ESP8266 Error\n"); |
electromotivated | 0:a2a238159653 | 333 | } |
electromotivated | 0:a2a238159653 | 334 | } |
electromotivated | 0:a2a238159653 | 335 | |
electromotivated | 0:a2a238159653 | 336 | /* |
electromotivated | 0:a2a238159653 | 337 | update_webpage() updates output fields based on webpage user inputs "POSTED" |
electromotivated | 0:a2a238159653 | 338 | Preconditions: webpage[] must have the following elements |
electromotivated | 0:a2a238159653 | 339 | "kp_output" value="xxx.xx" |
electromotivated | 0:a2a238159653 | 340 | "ki_output" value="xxx.xx" |
electromotivated | 0:a2a238159653 | 341 | "kp_output" value="xxx.xx" |
electromotivated | 0:a2a238159653 | 342 | @param webpage Pointer to webpage char[] |
electromotivated | 0:a2a238159653 | 343 | @param kp New kp value posted by user |
electromotivated | 0:a2a238159653 | 344 | @param ki New ki value posted by user |
electromotivated | 0:a2a238159653 | 345 | @param kd New kd value posted by user |
electromotivated | 0:a2a238159653 | 346 | |
electromotivated | 0:a2a238159653 | 347 | NOTE: THIS IS WEBPAGE SPECIFIC!!!! CHANGE THE CODE IN HERE TO SUITE THE |
electromotivated | 0:a2a238159653 | 348 | SPECIFIC APPLICATION WEBPAGE!!! ALSO USED TO REFLECT THE CUSTOM |
electromotivated | 0:a2a238159653 | 349 | IMPLEMENTATION OF THE parse_intput() function. MAKE SURE THESE TWO FUNCTIONS |
electromotivated | 0:a2a238159653 | 350 | INTEGRATE PROPERLY!!! |
electromotivated | 0:a2a238159653 | 351 | */ |
electromotivated | 0:a2a238159653 | 352 | void update_webpage(char* webpage, float setpoint, float kp, float ki, float kd){ |
electromotivated | 0:a2a238159653 | 353 | // Change output value to reflect new setpoint kp, ki, kd values |
electromotivated | 0:a2a238159653 | 354 | char* begin; |
electromotivated | 0:a2a238159653 | 355 | // char* end; |
electromotivated | 0:a2a238159653 | 356 | char temp[8]; |
electromotivated | 0:a2a238159653 | 357 | int idx; |
electromotivated | 0:a2a238159653 | 358 | |
electromotivated | 0:a2a238159653 | 359 | memset(temp, '\0', sizeof(temp)); |
electromotivated | 0:a2a238159653 | 360 | idx = 0; |
electromotivated | 0:a2a238159653 | 361 | begin = strstr(webpage, "name=\"kp_input\" value=\"") + |
electromotivated | 0:a2a238159653 | 362 | sizeof("name=\"kp_input\" value="); // Points to start of kp_output field |
electromotivated | 0:a2a238159653 | 363 | // end = begin + 5; // Points to end of kp_output value |
electromotivated | 0:a2a238159653 | 364 | // Determine precision of float such temp string has no empty spaces; |
electromotivated | 0:a2a238159653 | 365 | // i.e. each space must have a value or a decimal point, other wise webbrowser may not recognize value |
electromotivated | 0:a2a238159653 | 366 | if(kp >= 100) sprintf(temp, "%6.2f", kp); // xxx.00 |
electromotivated | 0:a2a238159653 | 367 | else if(10 <= kp && kp < 100) sprintf(temp, "%6.3f", kp); // xx.000 |
electromotivated | 0:a2a238159653 | 368 | else sprintf(temp, "%6.4f", kp); // x.0000 |
electromotivated | 0:a2a238159653 | 369 | while(temp[idx] != '\0'){ // Overwrite old digits with new digits |
electromotivated | 0:a2a238159653 | 370 | begin[idx] = temp[idx]; |
electromotivated | 0:a2a238159653 | 371 | idx++; |
electromotivated | 0:a2a238159653 | 372 | } |
electromotivated | 0:a2a238159653 | 373 | |
electromotivated | 0:a2a238159653 | 374 | memset(temp, '\0', sizeof(temp)); |
electromotivated | 0:a2a238159653 | 375 | idx = 0; |
electromotivated | 0:a2a238159653 | 376 | begin = strstr(webpage, "name=\"ki_input\" value=\"") + |
electromotivated | 0:a2a238159653 | 377 | sizeof("name=\"ki_input\" value="); // Points to start of ki_output field |
electromotivated | 0:a2a238159653 | 378 | // end = begin + 5; // Points to end of ki_output value |
electromotivated | 0:a2a238159653 | 379 | if(ki >= 100) sprintf(temp, "%6.2f", ki); // xxx.00 |
electromotivated | 0:a2a238159653 | 380 | else if(10 <= ki && ki < 100) sprintf(temp, "%6.3f", ki); // xx.000 |
electromotivated | 0:a2a238159653 | 381 | else sprintf(temp, "%6.4f", ki); // x.0000 |
electromotivated | 0:a2a238159653 | 382 | while(temp[idx] != '\0'){ // Overwrite old digits with new digits |
electromotivated | 0:a2a238159653 | 383 | begin[idx] = temp[idx]; |
electromotivated | 0:a2a238159653 | 384 | idx++; |
electromotivated | 0:a2a238159653 | 385 | } |
electromotivated | 0:a2a238159653 | 386 | |
electromotivated | 0:a2a238159653 | 387 | memset(temp, '\0', sizeof(temp)); |
electromotivated | 0:a2a238159653 | 388 | idx = 0; |
electromotivated | 0:a2a238159653 | 389 | begin = strstr(webpage, "name=\"kd_input\" value=\"")+ |
electromotivated | 0:a2a238159653 | 390 | sizeof("name=\"kd_input\" value="); // Points to start of kd_output field |
electromotivated | 0:a2a238159653 | 391 | // end = begin + 5; // Points to end of kd_output value |
electromotivated | 0:a2a238159653 | 392 | if(kd >= 100) sprintf(temp, "%6.2f", kd); // xxx.00 |
electromotivated | 0:a2a238159653 | 393 | else if(10 <= kd && kd < 100) sprintf(temp, "%6.3f", kd); // xx.000 |
electromotivated | 0:a2a238159653 | 394 | else sprintf(temp, "%6.4f", kd); // x.0000 |
electromotivated | 0:a2a238159653 | 395 | while(temp[idx] != '\0'){ // Overwrite old digits with new digits |
electromotivated | 0:a2a238159653 | 396 | begin[idx] = temp[idx]; |
electromotivated | 0:a2a238159653 | 397 | idx++; |
electromotivated | 0:a2a238159653 | 398 | } |
electromotivated | 0:a2a238159653 | 399 | |
electromotivated | 0:a2a238159653 | 400 | // Determine precision of float such temp string has no empty spaces; |
electromotivated | 0:a2a238159653 | 401 | // i.e. each space must have a value or a decimal point or neg sign, |
electromotivated | 0:a2a238159653 | 402 | // other wise webbrowser may not recognize value |
electromotivated | 0:a2a238159653 | 403 | memset(temp, '\0', sizeof(temp)); |
electromotivated | 0:a2a238159653 | 404 | idx = 0; |
electromotivated | 0:a2a238159653 | 405 | begin = strstr(webpage, "name=\"setpoint_input\" value=\"")+ |
electromotivated | 0:a2a238159653 | 406 | sizeof("name=\"setpoint_input\" value="); // Points to start of kp_output field |
electromotivated | 0:a2a238159653 | 407 | // end = begin + 6; // Points to end of kp_output value. +6 to accomadate negative sign |
electromotivated | 0:a2a238159653 | 408 | if(setpoint >= 0.00){ |
electromotivated | 0:a2a238159653 | 409 | if(setpoint >= 100) sprintf(temp, "%6.3f", setpoint); // xxx.000 |
electromotivated | 0:a2a238159653 | 410 | else if(10 <= setpoint && setpoint < 100) sprintf(temp, "%7.4f", setpoint); // xx.0000 |
electromotivated | 0:a2a238159653 | 411 | else sprintf(temp, "%6.5f", setpoint); // x.00000 |
electromotivated | 0:a2a238159653 | 412 | } |
electromotivated | 0:a2a238159653 | 413 | else{ |
electromotivated | 0:a2a238159653 | 414 | if(setpoint <= -100) sprintf(temp, "%6.2f", setpoint); // -xxx.00 |
electromotivated | 0:a2a238159653 | 415 | else if(-100 < setpoint && setpoint <= -10) sprintf(temp, "%6.3f", setpoint); // -xx.000 |
electromotivated | 0:a2a238159653 | 416 | else sprintf(temp, "%6.4f", setpoint); // -x.0000 |
electromotivated | 0:a2a238159653 | 417 | } |
electromotivated | 0:a2a238159653 | 418 | while(temp[idx] != '\0'){ // Overwrite old digits with new digits |
electromotivated | 0:a2a238159653 | 419 | begin[idx] = temp[idx]; |
electromotivated | 0:a2a238159653 | 420 | idx++; |
electromotivated | 0:a2a238159653 | 421 | } |
electromotivated | 0:a2a238159653 | 422 | } |
electromotivated | 0:a2a238159653 | 423 | |
electromotivated | 0:a2a238159653 | 424 | /* |
electromotivated | 0:a2a238159653 | 425 | parse_input() take a char*, in particular a pointer to Webpage User |
electromotivated | 0:a2a238159653 | 426 | Input Data, for example: |
electromotivated | 0:a2a238159653 | 427 | char str[] = "+IPD,0,44:kp_input=0.12&ki_input=14.25&kd_input=125.42"; |
electromotivated | 0:a2a238159653 | 428 | |
electromotivated | 0:a2a238159653 | 429 | and parses out the Setpoint Kp, Ki, Kd values that the user entered |
electromotivated | 0:a2a238159653 | 430 | and posted in the webpage. Values are converted to floats and |
electromotivated | 0:a2a238159653 | 431 | assigned to the given argurments. |
electromotivated | 0:a2a238159653 | 432 | |
electromotivated | 0:a2a238159653 | 433 | NOTE: THIS IS WEBPAGE SPECIFIC!!!! CHANGE THE CODE IN HERE TO SUITE THE |
electromotivated | 0:a2a238159653 | 434 | SPECIFIC APPLICATION WEBPAGE!!! THESE EXTRACTED VALUES WILL BE USED IN |
electromotivated | 0:a2a238159653 | 435 | THE update_webpage() function. MAKE SURE THESE TWO FUNCTIONS INTEGRATE |
electromotivated | 0:a2a238159653 | 436 | PROPERLY!!! |
electromotivated | 0:a2a238159653 | 437 | */ |
electromotivated | 0:a2a238159653 | 438 | void parse_input(char* webpage_user_data,float *setpoint, float* kp, float* ki, float* kd){ |
electromotivated | 0:a2a238159653 | 439 | char keys[] = {'&', '\0'}; |
electromotivated | 0:a2a238159653 | 440 | |
electromotivated | 0:a2a238159653 | 441 | // Parse out user input values |
electromotivated | 0:a2a238159653 | 442 | char input_buff[50]; |
electromotivated | 0:a2a238159653 | 443 | char* begin; |
electromotivated | 0:a2a238159653 | 444 | char* end; |
electromotivated | 3:6067780e2f45 | 445 | // printf("**************Parsing**************\n"); |
electromotivated | 0:a2a238159653 | 446 | memset(input_buff, '\0', sizeof(input_buff)); // Null out input buff |
electromotivated | 0:a2a238159653 | 447 | begin = strstr(webpage_user_data, "setpoint_input=") + |
electromotivated | 0:a2a238159653 | 448 | sizeof("setpoint_input"); // Points to start of setpoint_input value |
electromotivated | 0:a2a238159653 | 449 | end = begin + strcspn(begin, keys); // Points to end of setpoint_input value |
electromotivated | 0:a2a238159653 | 450 | for(long i = 0; i < end - begin; i++){ // Parse out the value one char at a time |
electromotivated | 0:a2a238159653 | 451 | input_buff[i] = begin[i]; |
electromotivated | 0:a2a238159653 | 452 | } |
electromotivated | 3:6067780e2f45 | 453 | // printf("Setpoint Parsed Data: %s\n", input_buff); |
electromotivated | 0:a2a238159653 | 454 | *setpoint = atof(input_buff); |
electromotivated | 0:a2a238159653 | 455 | |
electromotivated | 0:a2a238159653 | 456 | memset(input_buff, '\0', sizeof(input_buff)); // Null out input buff |
electromotivated | 0:a2a238159653 | 457 | begin = strstr(webpage_user_data, "kp_input=") + |
electromotivated | 0:a2a238159653 | 458 | sizeof("kp_input"); // Points to start of kp_input value |
electromotivated | 0:a2a238159653 | 459 | end = begin + strcspn(begin, keys); // Points to end of kp_input value |
electromotivated | 0:a2a238159653 | 460 | for(long i = 0; i < end - begin; i++){ // Parse out the value one char at a time |
electromotivated | 0:a2a238159653 | 461 | input_buff[i] = begin[i]; |
electromotivated | 0:a2a238159653 | 462 | } |
electromotivated | 3:6067780e2f45 | 463 | // printf("Kp Parsed Data: %s\n", input_buff); |
electromotivated | 0:a2a238159653 | 464 | *kp = atof(input_buff); |
electromotivated | 0:a2a238159653 | 465 | |
electromotivated | 0:a2a238159653 | 466 | memset(input_buff, '\0', sizeof(input_buff)); // Null out input buff |
electromotivated | 0:a2a238159653 | 467 | begin = strstr(webpage_user_data, "ki_input=") + |
electromotivated | 0:a2a238159653 | 468 | sizeof("ki_input"); // Points to start of ki_input value |
electromotivated | 0:a2a238159653 | 469 | end = begin + strcspn(begin, keys); // Points to end of ki_input value |
electromotivated | 0:a2a238159653 | 470 | for(long i = 0; i < end - begin; i++){ // Parse out the value one char at a time |
electromotivated | 0:a2a238159653 | 471 | input_buff[i] = begin[i]; |
electromotivated | 0:a2a238159653 | 472 | } |
electromotivated | 3:6067780e2f45 | 473 | // printf("Ki Parsed Data: %s\n", input_buff); |
electromotivated | 0:a2a238159653 | 474 | *ki = atof(input_buff); |
electromotivated | 0:a2a238159653 | 475 | |
electromotivated | 0:a2a238159653 | 476 | memset(input_buff, '\0', sizeof(input_buff)); // Null out input buff |
electromotivated | 0:a2a238159653 | 477 | begin = strstr(webpage_user_data, "kd_input=") + |
electromotivated | 0:a2a238159653 | 478 | sizeof("kd_input"); // Points to start of kd_input value |
electromotivated | 0:a2a238159653 | 479 | end = begin + strcspn(begin, keys); // Points to end of kd_input value |
electromotivated | 0:a2a238159653 | 480 | for(long i = 0; i < end - begin; i++){ // Parse out the value one char at a time |
electromotivated | 0:a2a238159653 | 481 | input_buff[i] = begin[i]; |
electromotivated | 0:a2a238159653 | 482 | } |
electromotivated | 3:6067780e2f45 | 483 | // printf("Kd Parsed Data: %s\n", input_buff); |
electromotivated | 0:a2a238159653 | 484 | *kd = atof(input_buff); |
electromotivated | 3:6067780e2f45 | 485 | // printf("**********End Parsing***************\n"); |
electromotivated | 0:a2a238159653 | 486 | } |
electromotivated | 0:a2a238159653 | 487 | |
electromotivated | 0:a2a238159653 | 488 | void pid_callback(){ |
electromotivated | 0:a2a238159653 | 489 | // Update motor |
electromotivated | 0:a2a238159653 | 490 | if(output >= 0.0) mtr_dir = 1; // Set direction to sign of output |
electromotivated | 0:a2a238159653 | 491 | else mtr_dir = 0; |
electromotivated | 0:a2a238159653 | 492 | mtr_pwm = abs(output); // Apply motor output |
electromotivated | 0:a2a238159653 | 493 | |
electromotivated | 0:a2a238159653 | 494 | // Update feedback |
electromotivated | 0:a2a238159653 | 495 | feedback = encoder.read()*FEEDBACK_SCALE;// Scale feedback to num wheel revs |
electromotivated | 0:a2a238159653 | 496 | } |
electromotivated | 0:a2a238159653 | 497 | |
electromotivated | 0:a2a238159653 | 498 | /* |
electromotivated | 0:a2a238159653 | 499 | Clips value to lower/ uppper |
electromotivated | 0:a2a238159653 | 500 | @param value The value to clip |
electromotivated | 0:a2a238159653 | 501 | @param lower The mininum allowable value |
electromotivated | 0:a2a238159653 | 502 | @param upper The maximum allowable value |
electromotivated | 0:a2a238159653 | 503 | @return The resulting clipped value |
electromotivated | 0:a2a238159653 | 504 | */ |
electromotivated | 0:a2a238159653 | 505 | float clip(float value, float lower, float upper){ |
electromotivated | 0:a2a238159653 | 506 | return std::max(lower, std::min(value, upper)); |
electromotivated | 0:a2a238159653 | 507 | } |
electromotivated | 0:a2a238159653 | 508 | |
electromotivated | 0:a2a238159653 | 509 | /**************************WEB PAGE TEXT**************************************/ |
electromotivated | 0:a2a238159653 | 510 | /***************************************************************************** |
electromotivated | 0:a2a238159653 | 511 | Copy and past text below into a html file and save as the given file name to |
electromotivated | 0:a2a238159653 | 512 | your SD card. |
electromotivated | 0:a2a238159653 | 513 | |
electromotivated | 0:a2a238159653 | 514 | file name: pid_pos.html |
electromotivated | 0:a2a238159653 | 515 | |
electromotivated | 0:a2a238159653 | 516 | html text: |
electromotivated | 0:a2a238159653 | 517 | |
electromotivated | 0:a2a238159653 | 518 | <!DOCTYPE html> |
electromotivated | 0:a2a238159653 | 519 | <html> |
electromotivated | 0:a2a238159653 | 520 | <head> |
electromotivated | 0:a2a238159653 | 521 | <title>PID Motor Position Control</title> |
electromotivated | 0:a2a238159653 | 522 | </head> |
electromotivated | 0:a2a238159653 | 523 | <body> |
electromotivated | 0:a2a238159653 | 524 | <h1>PID Motor Position Control</h1> |
electromotivated | 0:a2a238159653 | 525 | <h2>Motor Status</h2> |
electromotivated | 0:a2a238159653 | 526 | <p> |
electromotivated | 0:a2a238159653 | 527 | <form title="Motor Status"> |
electromotivated | 0:a2a238159653 | 528 | <input type="text" value="Some user information" size="25" readonly /><br> |
electromotivated | 0:a2a238159653 | 529 | Current Setpoint: |
electromotivated | 0:a2a238159653 | 530 | <input type="number" name="current_setpoint" value="0000.00" readonly /><br> |
electromotivated | 0:a2a238159653 | 531 | Current Position: |
electromotivated | 0:a2a238159653 | 532 | <input type="number" name="current_position" value="0000.00" readonly /><br> |
electromotivated | 0:a2a238159653 | 533 | </form> |
electromotivated | 0:a2a238159653 | 534 | </p> |
electromotivated | 0:a2a238159653 | 535 | <h2>PID Status</h2> |
electromotivated | 0:a2a238159653 | 536 | <form title="User Input" method="post"> |
electromotivated | 0:a2a238159653 | 537 | PID Controls: <br> |
electromotivated | 0:a2a238159653 | 538 | Setpoint: |
electromotivated | 0:a2a238159653 | 539 | <input type="number" name="setpoint_input" value="0000.00" step="0.01" size="6" /><br> |
electromotivated | 0:a2a238159653 | 540 | Proportional Gain: |
electromotivated | 0:a2a238159653 | 541 | <input type="number" name="kp_input" value="002.50" step="0.01" size="6" /><br> |
electromotivated | 0:a2a238159653 | 542 | Integral Gain: |
electromotivated | 0:a2a238159653 | 543 | <input type="number" name="ki_input" value="005.00" step="0.01" size="6" /><br> |
electromotivated | 0:a2a238159653 | 544 | Derivative Gain: |
electromotivated | 0:a2a238159653 | 545 | <input type="number" name="kd_input" value="000.25" step="0.01" size="6" /><br> |
electromotivated | 0:a2a238159653 | 546 | <br> |
electromotivated | 0:a2a238159653 | 547 | <input type="submit" value="Submit" /> |
electromotivated | 0:a2a238159653 | 548 | <input type="submit" name="update" value="Update"> |
electromotivated | 0:a2a238159653 | 549 | <input type="submit" name="estop" value="STOP"> |
electromotivated | 0:a2a238159653 | 550 | </form> |
electromotivated | 0:a2a238159653 | 551 | </body> |
electromotivated | 0:a2a238159653 | 552 | </html> |
electromotivated | 0:a2a238159653 | 553 | |
electromotivated | 0:a2a238159653 | 554 | |
electromotivated | 0:a2a238159653 | 555 | *****************************************************************************/ |
electromotivated | 0:a2a238159653 | 556 | /*****************************************************************************/ |