Changeset 14511 for firmware


Ignore:
Timestamp:
10/24/12 06:26:20 (12 years ago)
Author:
neise
Message:
renamed some buttons
File:
1 edited

Legend:

Unmodified
Added
Removed
  • firmware/InterlockArduino/src/webserver/webserver.ino

    r14252 r14511  
    1 
    21/*
    32  Arduino Ethernet for FACT Interlock
     
    3635  FC_OFF: disable pump : digital output D6
    3736 */
    38 
    3937#include <SPI.h>
    4038#include <Ethernet.h>
     
    5149int Z_OK = 19;
    5250
    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"};
     51int 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
     54char * 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?"};
     62int 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.
     65char * 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
     73char * button_name[] = {
     74    "cam_on",
     75    "cam_off",
     76    "drive_toggle"};
    5577
    5678  // outputs
     
    6688unsigned int fc_off_time = 0;// time in ms, for FC_OFF to be HIGH
    6789
    68 //byte mac[] = { 0xFA, 0xC7, 0x0F, 0xAD, 0x22, 0x01 }; // ETHZ
    69 byte mac[] = { 0xFA, 0xC7, 0xFC, 0xB1, 0x00, 0x01 }; // TUDO
     90
     91byte mac[] = { 0xFA, 0xC7, 0xFC, 0xB1, 0x00, 0x01 }; // FACT internal network
     92
    7093
    7194
     
    80103
    81104
    82 
    83105void setup() {
    84106 // Open serial communications and wait for port to open:
    85107  Serial.begin(9600);
    86    while (!Serial) {
    87     ; // wait for serial port to connect. Needed for Leonardo only
    88   }
    89108
    90109
     
    95114  Serial.println(Ethernet.localIP());
    96115 
    97  // Enable ATmega Pullups
    98  for (int i = 0 ; i<8; i++)
    99  {
    100   digitalWrite(my_inputs[i], HIGH);
    101  }
    102 
    103 
    104 
    105116  pinMode( FC_ON, OUTPUT );
    106117  pinMode( FC_OFF,OUTPUT );
    107118  pinMode( X, OUTPUT );
    108119  pinMode( Y,OUTPUT );
    109 
    110 }
     120  // the others are all INPUTs
     121}
     122
     123
    111124
    112125
    113126void loop() {
    114127   Check_n_Set_FC_ON_OFF();
     128   
    115129   unsigned long before = millis();
     130   
    116131   if (Check_for_clients() )
    117132   {
     
    123138   delay(300);
    124139}
     140
     141
     142
     143
    125144/////////////////////////////////////////////////////////////////////////////////////////////
    126145int Check_for_clients()
     
    144163        {
    145164         eth += c;
    146 //        Serial.write(c);
     165         //Serial.write(c);
    147166         //Serial.println(eth.length(), DEC);
    148167         if ( eth.indexOf('\n') != -1 )
     
    151170           {
    152171             get_http_found = true;
    153              if (eth.indexOf(String("D2on=")) !=-1){
     172             if (eth.indexOf(String("pump_on=")) !=-1){
    154173               Serial.println("User request: Enable Pump");
    155174               digitalWrite( FC_ON, HIGH);
    156                fc_on_time = 3000;
     175               if ((fc_on_time+3000) > fc_on_time)
     176                  fc_on_time += 3000;
    157177             }
    158              else if (eth.indexOf(String("D2off=")) !=-1)
     178             else if (eth.indexOf(String("pump_off=")) !=-1)
    159179             {
    160180               Serial.println("User request: Disable Pump");
     
    162182               fc_off_time = 500;
    163183             }
    164              else if (eth.indexOf(String("toggle_x=")) !=-1)
     184             else if (eth.indexOf(String("toggle_drive=")) !=-1)
    165185             {
    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 );
    169191             }
    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             //}
    176198              else
    177199              {
     
    232254}
    233255
    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)
     256void print_input_status( EthernetClient *client)
    272257{
    273258  for (int ch = 0; ch < 8; ch++)
     
    289274}
    290275
     276void 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}
    291295
    292296
    293297void html_page( EthernetClient *client)
    294298{
    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 );
    304301}
    305302
     
    315312Check_n_Set_FC_ON_OFF()
    316313{
    317 //  Serial.print("FC ON TIME");
    318 //  Serial.println(fc_on_time);
    319 //  Serial.print("FC OFF TIME");
    320 //  Serial.println(fc_off_time);
    321314 
    322315  unsigned long since_last = millis() - last_time;
Note: See TracChangeset for help on using the changeset viewer.