Changeset 14511 for firmware/InterlockArduino/src
- Timestamp:
- 10/24/12 06:26:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/InterlockArduino/src/webserver/webserver.ino
r14252 r14511 1 2 1 /* 3 2 Arduino Ethernet for FACT Interlock … … 36 35 FC_OFF: disable pump : digital output D6 37 36 */ 38 39 37 #include <SPI.h> 40 38 #include <Ethernet.h> … … 51 49 int Z_OK = 19; 52 50 53 int my_inputs[] = {FC_OK, BP_ON, IL_ON, FL_OK, FP_EN, X_ON, Y_ON, Z_OK}; 54 char * my_input_names[] = {"FC_OK", "BP_ON", "IL_ON", "FL_OK", "FP_EN", "X_ON", "Y_ON", "Z_OK"}; 51 int my_inputs[] = {FC_OK, BP_ON, IL_ON, FL_OK, FP_EN, X_ON, Y_ON, Z_OK}; 52 //char * my_input_names[] = {"FC_OK", "BP_ON", "IL_ON", "FL_OK", "FP_EN", "X_ON", "Y_ON", "Z_OK"}; 53 54 char * my_input_names[] = { "Is the cooling liquid flow meter measuring enough throuput?", 55 "Is Bias Power enabled?", 56 "Is 24VDC Interlock power supply enabled?", 57 "Is the Level of the cooling liquid ok?", 58 "Is the Pump powered?", 59 "Is the Drive Cabinet Enable Signal on?", 60 "Is the Drive Cabinet Power Signal on?", 61 "Is Drive Container Enabled?"}; 62 int Number_of_Buttons = 3; 63 // This is in HTML called the VALUE of the button, 64 // but it is in fact what is written on it. 65 char * button_caption[] = { 66 "Camera ON", 67 "Camera OFF", 68 "Drive ON/OFF"}; 69 70 // This is in HTML called the NAME of the button, and it is, what is transmit 71 // within the request. So this is a kind of reference string .. which i searh for 72 // in the request ... so the strings schould be nice ... no capital letters no spaces 73 char * button_name[] = { 74 "cam_on", 75 "cam_off", 76 "drive_toggle"}; 55 77 56 78 // outputs … … 66 88 unsigned int fc_off_time = 0;// time in ms, for FC_OFF to be HIGH 67 89 68 //byte mac[] = { 0xFA, 0xC7, 0x0F, 0xAD, 0x22, 0x01 }; // ETHZ 69 byte mac[] = { 0xFA, 0xC7, 0xFC, 0xB1, 0x00, 0x01 }; // TUDO 90 91 byte mac[] = { 0xFA, 0xC7, 0xFC, 0xB1, 0x00, 0x01 }; // FACT internal network 92 70 93 71 94 … … 80 103 81 104 82 83 105 void setup() { 84 106 // Open serial communications and wait for port to open: 85 107 Serial.begin(9600); 86 while (!Serial) {87 ; // wait for serial port to connect. Needed for Leonardo only88 }89 108 90 109 … … 95 114 Serial.println(Ethernet.localIP()); 96 115 97 // Enable ATmega Pullups98 for (int i = 0 ; i<8; i++)99 {100 digitalWrite(my_inputs[i], HIGH);101 }102 103 104 105 116 pinMode( FC_ON, OUTPUT ); 106 117 pinMode( FC_OFF,OUTPUT ); 107 118 pinMode( X, OUTPUT ); 108 119 pinMode( Y,OUTPUT ); 109 110 } 120 // the others are all INPUTs 121 } 122 123 111 124 112 125 113 126 void loop() { 114 127 Check_n_Set_FC_ON_OFF(); 128 115 129 unsigned long before = millis(); 130 116 131 if (Check_for_clients() ) 117 132 { … … 123 138 delay(300); 124 139 } 140 141 142 143 125 144 ///////////////////////////////////////////////////////////////////////////////////////////// 126 145 int Check_for_clients() … … 144 163 { 145 164 eth += c; 146 //Serial.write(c);165 //Serial.write(c); 147 166 //Serial.println(eth.length(), DEC); 148 167 if ( eth.indexOf('\n') != -1 ) … … 151 170 { 152 171 get_http_found = true; 153 if (eth.indexOf(String(" D2on=")) !=-1){172 if (eth.indexOf(String("pump_on=")) !=-1){ 154 173 Serial.println("User request: Enable Pump"); 155 174 digitalWrite( FC_ON, HIGH); 156 fc_on_time = 3000; 175 if ((fc_on_time+3000) > fc_on_time) 176 fc_on_time += 3000; 157 177 } 158 else if (eth.indexOf(String(" D2off=")) !=-1)178 else if (eth.indexOf(String("pump_off=")) !=-1) 159 179 { 160 180 Serial.println("User request: Disable Pump"); … … 162 182 fc_off_time = 500; 163 183 } 164 else if (eth.indexOf(String("toggle_ x=")) !=-1)184 else if (eth.indexOf(String("toggle_drive=")) !=-1) 165 185 { 166 Serial.println("User request: Toggle X"); 167 x_signal = !x_signal; 168 digitalWrite( X, x_signal ); 186 Serial.println("User request: Toggle Drive"); 187 x_signal = !x_signal; 188 digitalWrite( X, x_signal ); 189 y_signal = !y_signal; 190 digitalWrite( Y, y_signal ); 169 191 } 170 else if (eth.indexOf(String("toggle_y=")) !=-1)171 {172 Serial.println("User request: Toggle Y");173 y_signal = !y_signal;174 digitalWrite( Y, y_signal );175 }192 //else if (eth.indexOf(String("toggle_y=")) !=-1) 193 //{ 194 // Serial.println("User request: Toggle Y"); 195 // y_signal = !y_signal; 196 // digitalWrite( Y, y_signal ); 197 //} 176 198 else 177 199 { … … 232 254 } 233 255 234 void send_ana_outs_example( EthernetClient *client) { 235 // output the value of each analog input pin 236 for (int analogChannel = 0; analogChannel < 6; analogChannel++) 237 { 238 client->print("analog input "); 239 client->print(analogChannel); 240 client->print(" is "); 241 client->print(analogRead(analogChannel)); 242 client->println("<br />"); 243 } 244 } 245 246 void send_dig_ins( EthernetClient *client) 247 { 248 for (int ch = 4; ch < 9; ch++) 249 { 250 client->print("digital input "); 251 client->print(ch); 252 client->print(" is "); 253 if (digitalRead(ch)) 254 { 255 client->print("<font color=\"green\" size=20>HIGH</font>"); 256 } 257 else 258 { 259 client->print("<font color=\"red\" size=20>LOW</font>"); 260 } 261 262 263 264 client->println("<br />"); 265 } 266 267 } 268 269 270 271 void send_my_inputs( EthernetClient *client) 256 void print_input_status( EthernetClient *client) 272 257 { 273 258 for (int ch = 0; ch < 8; ch++) … … 289 274 } 290 275 276 void make_buttons( EthernetClient *client ) 277 { 278 for ( int button_id = 0; button_id < Number_of_Buttons; ++button_id ) 279 { 280 client->print("<P><INPUT TYPE=SUBMIT NAME=\""); 281 client->print(button_name[button_id]); 282 client->print("\" VALUE=\""); 283 client->print(button_caption[button_id]); 284 client->print("\" "); 285 286 // the 'OFF' button should be disabled 287 // in case somebody just pressed the 'ON' button. 288 if (fc_on_time != 0 && button_id == 1){ 289 client->print("disabled"); 290 } 291 292 client->println("><br />"); 293 } 294 } 291 295 292 296 293 297 void html_page( EthernetClient *client) 294 298 { 295 client->println("<P><INPUT TYPE=SUBMIT NAME=\"D2on\" VALUE=\"Enable Pump\"> --> FC_ON HIGH for 3 seconds <br />"); 296 client->println("<P><INPUT TYPE=SUBMIT NAME=\"D2off\" VALUE=\"Disable Pump\">--> FC_OFF HIGH for 0.5 seconds <br />"); 297 client->println("<P><INPUT TYPE=SUBMIT NAME=\"toggle_x\" VALUE=\"Toggle X\">--> ... well it toggles X <br />"); 298 client->println("<P><INPUT TYPE=SUBMIT NAME=\"toggle_y\" VALUE=\"Toggle Y\">--> ... well it toggles Y <br />"); 299 300 // send_dig_ins( client ); 301 send_my_inputs( client ); 302 303 //send_ana_outs_example( client ); 299 make_buttons( client ); 300 print_input_status( client ); 304 301 } 305 302 … … 315 312 Check_n_Set_FC_ON_OFF() 316 313 { 317 // Serial.print("FC ON TIME");318 // Serial.println(fc_on_time);319 // Serial.print("FC OFF TIME");320 // Serial.println(fc_off_time);321 314 322 315 unsigned long since_last = millis() - last_time;
Note:
See TracChangeset
for help on using the changeset viewer.