Fire Detector with Two Zones

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
josmy
Date:
Tue Mar 10 11:13:43 2015 +0000
Parent:
2:ad0b044d0a10
Commit message:
Fire Detector with two zones;

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r ad0b044d0a10 -r d23f3885fa07 TextLCD.lib
--- a/TextLCD.lib	Sat Dec 04 11:31:07 2010 +0000
+++ b/TextLCD.lib	Tue Mar 10 11:13:43 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r ad0b044d0a10 -r d23f3885fa07 main.cpp
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Tue Mar 10 11:13:43 2015 +0000
@@ -1,10 +1,1036 @@
-// Hello World! for the TextLCD
-
 #include "mbed.h"
 #include "TextLCD.h"
+#define Maxsamples 50
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+Serial pc(SERIAL_TX,SERIAL_RX);
+Ticker  Test;
+unsigned mydelay;
+AnalogIn potpin1(PA_0);
+AnalogIn potpin2(PA_1);
+AnalogIn batpin(PC_0);
+AnalogIn Mains(PC_1);
+DigitalIn itz1k(PB_14);
+DigitalIn itz2k(PB_13);
+DigitalIn Userbutton(PA_15);
+//DigitalIn Reset(PB_9);
+DigitalIn sbutton(PB_12);
+DigitalIn silbutton(PB_11);
+DigitalOut myled(LED1);
+DigitalOut z1fled(PA_5, 1);
+DigitalOut z2fled(PA_4, 1);
+DigitalOut z1ftled(PA_7, 1);
+DigitalOut z2ftled(PA_6, 1);
+DigitalOut z1iled(PC_5, 1);
+DigitalOut z2iled(PC_4,1);
+DigitalOut silenceled(PB_1, 1);
+DigitalOut soundled(PB_0, 1);
+DigitalOut z1testled(PB_10, 1);
+DigitalOut z2testled(PB_2, 1);
+DigitalOut hooter(PC_8);
+DigitalOut buzzer(PA_9);
+DigitalOut z1r(PB_15);
+DigitalOut z2r(PC_6);
+DigitalOut Tx(PA_2);
+DigitalOut Rx(PA_3);
+DigitalOut TREN(PA_10);
+DigitalOut z1drv(PC_9);
+DigitalOut z2drv(PA_8);
+DigitalOut fr(PC_7);
+DigitalOut commonfire(PC_12, 1);
+uint16_t z1tflag=0;
+uint16_t z2tflag=0;
+uint16_t z1iflag=0;
+uint16_t z2iflag=0;
+TextLCD lcd(PA_11,PF_6,PF_7,PA_15,PC_10,PC_11);//RW- PA_12,
+float fval1=0.0;
+float fval2=0.0;
+float fval3=0.0;
+float fval4=0.0;
+float sense=0.20;
+//float Zone2sense=2.2;
+float scsense=2.2;
+float shortsense = 3.0;
+float ocsense=0.11;
+float mains = 2.7;  
+float batsense=2.0;
+unsigned long val1=0;
+unsigned long val2=0;
+unsigned long val3=0;
+unsigned long val4=0;
+uint16_t i = 0;
+uint16_t j = 0;
+uint16_t it1flag = 0;
+uint16_t it2flag = 0;
+int SilFlag, SouFlag;
+int a;
+int HBTest;
+int OCflag;
+int w, x;
+void TestISR (void){
+    if (mydelay) mydelay--;
+}
+
+void HooterON(void){
+    hooter=1;
+}
+
+void BuzzerON(void){
+    buzzer=1;
+}     
+
+void HooterOFF(void){
+    hooter=0;
+}
+
+void BuzzerOFF(void){
+    buzzer=0;
+}
+
+void HooterTest(unsigned counter){
+        //if(HBTest == 0)HBTest = 1 ;
+        //if(HBTest == 1){  
+            HooterON();
+            BuzzerON();
+            mydelay = counter;
+            while(mydelay);
+            HooterOFF();
+            BuzzerOFF();
+            //mydelay = counter;  
+            //while(mydelay);
+            //HBTest = 2; 
+        //}
+}
+     
+
+
+
+void Z1FON(void){
+    z1fled = 0;
+}
+
+void Z1FOFF(void){
+    z1fled = 1;
+}
+
+void Z2FON(void){        
+    z2fled = 0;
+}
+
+void Z2FOFF(void){        
+    z2fled = 1;
+}
+
+void Z1FTON(void){
+    z1ftled = 0;
+}
+
+void Z1FTOFF(void){
+    z1ftled = 1;
+}
+
+
+void Z2FTON(void){
+    z2ftled = 0;
+}
+
+void Z2FTOFF(void){
+    z2ftled = 1;
+}
+
+void Z1ION(void){
+    z1iled = 0;
+}
+
+void Z1IOFF(void){
+    z1iled = 1;
+}
+
+
+void Z2ION(void){
+    z2iled = 0;
+}
+
+void Z2IOFF(void){
+    z2iled = 1;
+}
+
+
+void SILENCEON(void){
+    silenceled = 0;
+}
+
+void SILENCEOFF(void){
+    silenceled = 1;
+}
+
+
+void SOUNDON(void){
+    soundled = 0;
+}
+
+void SOUNDOFF(void){
+    soundled = 1;
+}
+
+
+
+void Z1TESTON(void){
+    z1testled = 0;
+}
+
+void Z1TESTOFF(void){
+    z1testled = 1;
+}
+
+
+void Z2TESTON(void){
+    z2testled = 0;
+}
+
+void Z2TESTOFF(void){
+    z2testled = 1;
+}
+
+
+
+void CFIREON(void){
+    commonfire= 0;
+}
+
+void CFIREOFF(void){
+    commonfire= 1;
+}
+
+void Z1RON(void){ 
+    z1r = 1;
+}
+
+void Z1ROFF(void){ 
+    z1r = 0;
+}
+
+void Z2RON(void){ 
+    z2r = 1;
+}
+
+void Z2ROFF(void){ 
+    z2r = 0;
+}
+
+void FRON(void){
+    fr = 1;
+}
+
+void FROFF(void){
+    fr = 0;
+}
+
+void avg(void){
+    
+
+    
+            fval1 = fval2 = fval3= fval4= 0;
+    
+    for (int k=1; k<=Maxsamples; k++ ){
+         fval1 += potpin1.read();
+         fval2 += potpin2.read();
+         fval3 += batpin.read();
+         fval4 += Mains.read();
+    }
+    fval1/=Maxsamples;
+    fval2/=Maxsamples;
+    fval3/=Maxsamples;
+    fval4/=Maxsamples;
+        
+    fval1 = fval1 *3.3;
+    fval2 = fval2 *3.3;    
+    fval3 = fval3 *3.3;
+    fval4 = fval4 *3.3;
+        
+}       
+
+void Autofirez1_test(void){
+    avg();
+    //if ((fval1>=sense) && (fval1<3.0)){
+        if ((fval1>=0.11) && (fval1 < 3.0)){
+        //lcd.locate(0,0);
+        //lcd.printf("Fire Zn1 ");
+        Z1FON();
+        Z1RON();
+        CFIREON();          
+        if((SilFlag == 0)){
+                    HooterTest(6);
+                }
+                                
+        z1drv =0;
+        wait(1);
+        z1drv =1;
+                
+        //HooterTest(6);
+
+    }
+    else{  
+        //lcd.locate(0,0);
+        //lcd.printf("        ");
+        //HooterOFF();
+        //BuzzerOFF();
+        //Z1FOFF();
+        //CFIREOFF();
+        Z1ROFF();
+    }         
+}
+void IsolateZ1(void){
+        Z1FOFF();
+        Z1ROFF();
+}   
+void Autofirez1(void){
+    avg();
+    //if ((fval1>=sense) && (fval1<3.0)){
+        if ((fval1>=0.11) && (fval1 < 3.0)){
+        Z1RON();
+        lcd.locate(0,0);
+        lcd.printf("Fire Zn1 ");
+        Z1FON();
+                if((SilFlag == 0)){
+                    //if(z2iflag != 1){
+                    HooterON();
+                    BuzzerON();
+                    //}
+                }   
+        CFIREON();
+    }
+    else{  
+        //lcd.locate(0,0);
+        //lcd.printf("        ");
+        //HooterOFF();
+        //BuzzerOFF();
+        //CFIREOFF();
+        //Z1FOFF();
+        Z1ROFF();
+    }   
+}
+
+void Autofirez2(){
+    avg();
+    //if ((fval2>=sense) && (fval2<3.0)){
+        if ((fval2>=0.11) && (fval2 < 3.0)){
+        Z2RON();
+        lcd.locate(0,1);
+        lcd.printf("Fire Zn2 ");
+                if((fval1>=0.003) && (fval1 < 0.09)  && (z1iflag != 1) && (z1tflag != 1)){
+                    lcd.locate(0,0);
+                    lcd.printf("         ");
+                    
+                }
+        Z2FON();
+        if((SilFlag == 0)){
+                    //if(z1iflag != 1){
+          HooterON();
+          BuzzerON();
+          //} 
+        }   
+        CFIREON();
+    }
+    else{
+        //lcd.locate(0,1);
+        //lcd.printf("         ");
+        //HooterOFF();
+        //BuzzerOFF();
+        //CFIREOFF();
+        //Z2FOFF();
+        Z2ROFF();
+    }
+}
+
+void Autofirez2_test(){
+    avg();
+    //if ((fval2>=sense) && (fval2<3.0)){
+        if ((fval2>=0.11) && (fval2 < 3.0)){
+        //lcd.locate(0,1);
+        //lcd.printf("Fire Zn2 ");
+                if((fval1>=0.003) && (fval1 < 0.09) && (z1iflag != 1) && (z1tflag != 1)){
+                    lcd.locate(0,0);
+                    lcd.printf("         ");
+                    
+                }
+            
+        Z2FON();
+        CFIREON();
+        Z2RON();                
+        if((SilFlag == 0)){
+                    HooterTest(6);                  
+        } 
+                
+        z2drv =0;
+        wait(1);
+        z2drv =1;
+                
+            
+        //HooterTest(6);
+
+        //BuzzerON();
+    }
+    else{
+        //lcd.locate(0,1);
+        //lcd.printf("         ");
+        //HooterOFF();
+        //BuzzerOFF();
+        //CFIREOFF();
+        //Z2FOFF();
+        Z2ROFF();
+    }
+}
+
+void IsolateZ2(void){
+    Z2FOFF();
+    Z2ROFF();
+}   
+void firepanel(void){
+    
+        if ((z1iflag != 1) && (z2iflag != 1) && (z1tflag != 1) && (z2tflag != 1)){
+        avg();  
+    if (((fval1>=0.001) && (fval1<0.09)) && ((fval2>=0.001) && (fval2<0.09))){ 
+        wait_ms(10); 
+                avg();
+        if (((fval1>=0.001) && (fval1<0.09)) && ((fval2>=0.001) && (fval2<0.09))){ 
+        
+            lcd.locate(0,0);
+            lcd.printf("Normal   ");
+            //lcd.locate(0,1);
+            //lcd.printf("         ");
+                    
+                    
+        }
+    }
+        
+        //else if((fval1>=0.003) && (fval1<0.15) && (fval2<0.001)){
+        //  lcd.locate(0,0);
+     // lcd.printf("         ");
+        
+        //} 
+    }
+        
+}
+
+void Shortz1 (void) {
+    avg();
+    if (fval1>=3.20){
+        lcd.locate(0,0);
+        lcd.printf("Short Zn1");
+        Z1FTON();
+        //HooterON();
+        //BuzzerON();
+        FRON();
+                
+                if((SouFlag != 1)  && (fval2 >= 0.003) && (fval2 < 0.09)){
+                        HooterOFF();
+                        CFIREOFF();
+                }   
+                if((SilFlag == 0)){
+                    BuzzerON();
+                }   
+    }
+    else {
+        //lcd.locate(9,0);
+                //lcd.printf(" ");
+            
+        //Z1FTOFF();
+        //FROFF();
+    }
+}
+
+void Shortz2(void){
+     avg();
+     if(fval2 >= 3.20) {
+        lcd.locate(0,1);
+        lcd.printf("Short Zn2");
+        Z2FTON();
+                if((SouFlag != 1)  && (fval1 >= 0.003) && (fval1 < 0.09)){
+                        HooterOFF();
+                        CFIREOFF();
+                }   
+             
+                if((SilFlag == 0)){
+                    BuzzerON();
+                }
+        //HooterON();
+        //BuzzerON();
+        FRON();
+                
+    }
+    else{
+        //Z2FTOFF();
+        //FROFF();
+        //lcd.locate(9,1);
+        //lcd.printf(" ");
+            
+    }
+}  
+
+void battery(void){
+        avg();
+     if (fval3<1.8){
+         lcd.locate(10,0);
+         lcd.printf("BatLow");
+                    if((SilFlag == 0)){
+                        BuzzerON();
+                    }
+                    FRON();
+         //BuzzerON();
+    }
+    else {
+        lcd.locate(10,0);
+        lcd.printf("      "); 
+        //BuzzerOFF();
+        
+    }
+}
+
 
-int main() {
-    lcd.printf("Hello World!\n");
+void opencircuitz1(void){
+     avg();
+     if (fval1<0.00009){
+                    OCflag = 1;
+         lcd.locate(0,0);
+         lcd.printf("Open Zn1 ");
+         Z1FTON();
+         FRON();
+                
+             if((SilFlag == 0)){
+                BuzzerON();
+             }
+                if((SouFlag != 1)  && (fval2 >= 0.003) && (fval2 < 0.09)){
+                        HooterOFF();
+                        CFIREOFF();
+                }   
+             
+         //BuzzerON();
+         //HooterON();
+    }
+    else
+            if((fval1>0.003) && (fval1<0.09)){
+                OCflag = 0;
+         lcd.locate(0,0);
+         //lcd.printf("         ");
+            
+         //BuzzerOFF();
+         //HooterOFF();
+         //Z1FTOFF();
+         //FROFF();
+    }    
+}
+
+void opencircuitz2(void){
+     avg();    
+     if (fval2<0.00009) {
+         lcd.locate(0,1);
+         lcd.printf("Open Zn2 ");
+         Z2FTON();
+         //BuzzerON();
+         //HooterON();
+         FRON();
+                
+             if((SilFlag == 0)){
+                BuzzerON();
+             }
+                if((SouFlag != 1) && (fval1 >= 0.003) && (fval1 < 0.09)){
+                        HooterOFF();
+                        CFIREOFF();
+                }   
+             
+    }
+    else
+            if((fval2>=0.003) && (fval2<0.09)){
+                if(z2tflag !=1){
+         lcd.locate(0,1);
+         lcd.printf("         ");
+                }       
+                
+         //BuzzerOFF();
+         //HooterOFF();
+         //Z2FTOFF();   
+         //lcd.locate(9,1);
+         //lcd.printf(" ");
+            
+    }
+        if((fval2<0.00009) && (fval1>0.003) && (fval1<0.09))    {//C
+            if((z1tflag != 1) && (z1iflag !=1)){
+         lcd.locate(0,0);
+         lcd.printf("         ");       
+            }
+        }   
+}
+
+void ACFail(void){
+     avg();  
+     if (fval4<2.4){
+         //lcd.locate(0,0);
+         //lcd.printf("AC FAIL");
+       //  Z1FT();
+         //BuzzerON();
+         lcd.locate(10,1);
+         lcd.printf("ACFAIL");
+                    if((SilFlag == 0)){
+                        BuzzerON();
+                    }
+                    FRON();
+         //Z1FT();
+         //BuzzerON();
+    }
+    else {
+        lcd.locate(10,1);
+        lcd.printf("      "); 
+        //BuzzerOFF();
+        
+    }
+}
+    
+
+
+
+void isolation(void){
+    if (z1iflag == 1){
+        Z1ION();         
+    }
+    else{
+        Z1IOFF();
+    }
+    if (z2iflag == 1){
+        Z2ION();
+    }
+    else{
+        Z2IOFF();
+    }
+}
+
+void TEST(void){
+    if(z1tflag == 1){
+        Z1TESTON();
+    }        
+    else{
+        Z1TESTOFF();
+    }        
+    if(z2tflag == 1){
+        Z2TESTON();
+    }        
+    else{
+        Z2TESTOFF();
+    }        
+
+
+
+}    
+
+
+void itkey1(void){
+    if(itz1k == 0){       
+       a++; 
+             w++;
+       if ((a >= 1) &&(a < 2)){
+            z1iflag=1;
+       }
+       if(a > 2){
+            z1iflag=0;
+       }
+       if(w>=10 && w<20){
+            z1tflag=1;
+       }
+       if (w>=20){
+            z1tflag=0;
+       }
+       if(a > 21) a = 0;
+             if(w > 21) w = 0;
+    }   
+}
+void itkey2(void){
+    if(itz2k == 0){
+        j++; 
+                x++;
+        if ((j >= 1) && (j < 2)){
+            z2iflag=1;
+        }
+        if(j > 2){
+            z2iflag=0;
+        }
+        if(x>=10 && x<20){
+            z2tflag=1;
+        }
+        if (x>=20){
+            z2tflag=0;
+        }
+        if(j >21) j = 0;
+                if(x >21) x = 0;
+    }        
+}
+/*
+void Reset_in(void){
+     if (Reset ==0){
+         NVIC_SystemReset();
+         }
+}
+*/    
+
+void sound (void){
+    if (sbutton == 0){
+         SouFlag = 1;
+    }         
+    if(SouFlag == 1){
+        SilFlag = 0;
+        SOUNDON();
+      
+        avg();
+        if((fval1>=0.00) || (fval2>=0.00)){
+          HooterON();
+          BuzzerON();
+        }
+        //else{
+          //HooterOFF();
+          //BuzzerOFF();
+          //SOUNDOFF();   
+       //}
+     } 
+    else SOUNDOFF();
+        
+         
 }
+
+void silence (void){
+    if (silbutton==0){
+         SilFlag = 1;
+    }         
+    if(SilFlag == 1){
+            SouFlag = 0;
+            HooterOFF();
+            BuzzerOFF();
+            SILENCEON();
+        }
+        else{
+            SILENCEOFF();
+        }    
+    
+}    
+
+void HBOFF(void){
+    avg();
+    if((SouFlag != 1) && (fval1 >= 0.003) && (fval1 < 0.09) && (fval2 >= 0.003) && (fval2 < 0.09) && (fval3 >= 1.9) && (fval4 >= 2.5)){
+        HooterOFF();
+        BuzzerOFF();
+        CFIREOFF();
+    }
+        avg();
+    if((SouFlag != 1) && ((fval1 >= 3.2) || (fval1 < 0.00009)) && ((fval2 >= 3.2) || (fval2 < 0.00009))){//C
+                HooterOFF();
+        CFIREOFF();     
+        }
+}    
+
+void FaultOFF(){
+    avg();
+    if((fval1 >= 0.003) && (fval1 < 3.00) && (fval2 >= 0.003) && (fval2 < 3.00) && (fval3 >= 1.9) && (fval4 >= 2.5)){
+            wait_ms(10);
+      if((fval1 >= 0.003) && (fval1 < 3.00) && (fval2 >= 0.003) && (fval2 < 3.00) && (fval3 >= 1.9) && (fval4 >= 2.5)){
+                FROFF();
+      }
+    }
+    if((fval1 >= 0.003) && (fval1 < 3.00)) {
+            wait_ms(10);
+      if((fval1 > 0.003) && (fval1 < 3.00)) {
+                Z1FTOFF();
+        //lcd.locate(9,0);
+        //lcd.printf(" ");
+                
+      }
+    }
+    if((fval2 >= 0.003) && (fval2 < 3.00)) {
+            wait_ms(10);
+      if((fval2 >= 0.003) && (fval2 < 3.00)) {
+                Z2FTOFF();
+        //lcd.locate(9,1);
+        //lcd.printf(" ");
+                
+      }
+    }        
+}    
+
+
+void FireOFF(void){
+    avg();
+    if(fval1 < 0.17)Z1FOFF();
+    if(fval2 < 0.17)Z2FOFF();
+}    
+
+void HBIOFF(void){
+
+    if((z1iflag == 0) && (z2iflag == 1)){
+                avg();
+        if((fval1 >= 0.003) && (fval1 < 0.09)){
+                    
+                    if(SouFlag != 1){
+            //HooterOFF();
+            //BuzzerOFF();
+            //CFIREOFF();
+                    }
+        }
+    }
+    if((z1iflag == 1) && (z2iflag == 0)){
+                avg();
+        if((fval2 >= 0.003) && (fval2 < 1.5)){
+                    
+                    if(SouFlag != 1){
+            //HooterOFF();
+            //BuzzerOFF();
+            //CFIREOFF();
+                    }
+        }
+    }
+
+    if((z1iflag == 1) && (z2iflag == 1)){
+            
+            if(SouFlag != 1){
+        HooterOFF();
+        BuzzerOFF();
+        CFIREOFF();
+            }   
+    }
+    
+        
+/*      
+    if((z1iflag != 0) || (z2iflag != 0)){
+        //avg();
+        //if((fval1 > 0.10) || (fval2 > 0.10)){
+            if(((z1iflag == 1) || (z1iflag == 0))&& ((z2iflag == 1) || (z2iflag == 0))){
+                HooterOFF();
+                BuzzerOFF();
+                CFIREOFF();
+            }
+        //}
+    }   
+*/  
+}   
+
+int main(){
+    /*
+    while(1){
+        myled = !myled;
+        wait_ms(100);
+    }        
+
+unsigned int i;
+
+    while(1){
+        Z1FOFF(); 
+
+        lcd.locate(0,0);
+            lcd.printf("%u",i); 
+            wait_ms(100);
+            i++;
+    Z1FON(); 
+
+    }
+*/
+
+
+
+
+    Z1FOFF(); 
+  Z2FOFF(); 
+  Z1FTOFF(); 
+  Z2FTOFF(); 
+  Z1IOFF(); 
+  Z2IOFF(); 
+  Z1TESTOFF(); 
+  Z2TESTOFF(); 
+  CFIREOFF();
+  SOUNDOFF(); 
+  SILENCEOFF();
+  itz1k.mode(PullUp); 
+  itz2k.mode(PullUp); 
+  sbutton.mode(PullUp);  
+  silbutton.mode(PullUp);
+  z1iflag = 0;
+  z2iflag = 0;
+  z1tflag = 0;
+  z2tflag = 0;
+  z1drv = 1;
+  z2drv = 1;
+    HBTest = 0;
+        OCflag = 0;
+  //pc.printf("FIRE DETECTOR");
+    
+  Test.attach(&TestISR,1.0);
+/*  
+    while(1){
+            avg();
+            //pc.print("Z1: %4u  Z2:  %4u\n", val1, val2);
+            lcd.locate(0,0);
+            lcd.printf("%2.4f %2.4f",fval1, fval3);
+            lcd.locate(0,1);
+            lcd.printf("%2.5f %2.4f",fval2, fval4);
+            wait(1);
+        
+    }
+*/  
+  // Reset();
+  while(1){
+        //myled=!myled;
+    //pc.printf("z1: %d\n",z1fled.read());
+    itkey1(); 
+    itkey2();
+    firepanel();
+    //pc.printf("%4.2f %4.2f %4.2f \n",fval1,fval2,fval3);
+    //wait(0.1);
+    isolation();
+    TEST();
+    HBIOFF();
+        if(z1tflag != 1){
+            if (z1iflag==0){
+                Autofirez1();
+        //Manualfirez1();
+        opencircuitz1();
+        //Manualz1();
+        Shortz1();
+        HBOFF();
+        FaultOFF();
+        ACFail();
+        battery();
+        sound();
+        silence();
+        FireOFF();
+      }
+        }
+        if(z1iflag == 1)
+        {
+            lcd.locate(0,0);
+            lcd.printf("Isolate 1");    
+            IsolateZ1();
+            if((fval1 >= 0.003) && (fval1 < 3.00)) {
+                wait_ms(10);
+                if((fval1 >= 0.003) && (fval1 < 3.00)) {
+                    Z1FTOFF();
+                }
+                        }            
+                        ACFail();
+                        battery();
+                        sound();
+                        silence();
+                }
+                
+            
+        if(z2tflag != 1){
+            if (z2iflag==0){
+                Autofirez2();
+        // Manualfirez2();
+        opencircuitz2();
+        //Manualz2();
+        Shortz2();
+        ACFail();
+        HBOFF();
+        FaultOFF();
+        battery();
+        sound();
+        silence();
+        FireOFF();
+      }
+        }
+        if(z2iflag == 1)
+        {
+            lcd.locate(0,1);
+            lcd.printf("Isolate 2");
+                        avg();
+                        if((z1iflag == 0) && (z1tflag == 0) && ((fval1>=0.003) && (fval1<0.09))){
+                            lcd.locate(0,0);
+                            lcd.printf("         ");
+                        
+                        }
+            IsolateZ2();
+            if((fval2 >= 0.03) && (fval2 < 3.00)) {
+                wait_ms(10);
+                if((fval2 >= 0.003) && (fval2 < 3.00)) {
+                    Z2FTOFF();
+                }
+            }        
+                    ACFail();
+                    battery();
+                    sound();
+                    silence();
+                        
+                    
+        }   
+    avg();
+        //if((fval1 >= 0.003) && (fval1 < 0.15)){
+    if(z1tflag==1){
+            if((fval1 >= 0.003) && (fval1 < 0.09)){
+      lcd.locate(0,0);
+      lcd.printf("Test Zn1 ");    
+            }
+      Autofirez1_test();
+      //Manualz1_test();
+      opencircuitz1();
+      battery();
+      silence();
+      sound();
+      Shortz1();
+      ACFail();
+      //HBOFF();
+      FaultOFF();
+      FireOFF();
+      itkey1();
+      itkey2();
+            HBOFF();
+            
+            
+    //}
+    }
+/*
+        if(z1iflag!=1){
+        if(z1tflag!=1)
+        {
+            lcd.locate(0,0);
+            lcd.printf("         ");
+                    
+        }
+            }
+*/  
+        //if((fval2 >= 0.003) && (fval2 < 0.15)){
+    if(z2tflag==1){
+            if((fval2 >= 0.002) && (fval2 < 0.09)){
+      lcd.locate(0,1);
+      lcd.printf("Test Zn2 ");    
+            }
+            Autofirez2_test();
+      //Manualz2_test();
+      opencircuitz2();
+      battery();
+      silence();
+      sound();
+      Shortz2();
+      ACFail();
+      FaultOFF();                   
+      FireOFF();
+      itkey1();
+      itkey2();
+            HBOFF();
+    }
+    //}
+            if(z2iflag!=1){
+        if(z2tflag!=1)
+        {
+                    avg();
+                    if((fval2>=0.003) && (fval2 < 0.09)){
+                        lcd.locate(0,1);
+                        lcd.printf("         ");
+                    }
+                    
+        } 
+            }
+      if((z2tflag == 1) && (z1tflag != 1) && (z1iflag != 1) && (fval1 < 0.17)){
+                if(OCflag == 0){
+            lcd.locate(0,0);
+            lcd.printf("         ");
+                }
+            
+            }
+    wait_ms(10);
+  }    
+} 
+
diff -r ad0b044d0a10 -r d23f3885fa07 mbed.bld
--- a/mbed.bld	Sat Dec 04 11:31:07 2010 +0000
+++ b/mbed.bld	Tue Mar 10 11:13:43 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file