J L / Mbed 2 deprecated Neptune_170620

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Controls.cpp Source File

Controls.cpp

00001 #include <string> 
00002 #include "main.h"
00003 #include "Functions.h"
00004 #include "Definitions.h"
00005 #include "Boolean.h"
00006 #include "NextionLCD.h"
00007 #include "mbed_debug.h"
00008 #include "mbed.h"
00009 #include "Languages.h"
00010 #include "Ser25lcxxx.h"
00011 #include "NVM.h"
00012 #include "Watchdog.h"
00013 #include "NextionPages.h"
00014 #include "Controls.h"
00015 #include "ISR.h"
00016 #include "FastPWM.h"
00017 
00018 /*
00019     CONTROLS
00020 
00021     Start Button
00022     Stop Button
00023     Analogue Input
00024     Analogue Output
00025     Motor Control
00026 */
00027 
00028 ///////////////////////////////////////////////////////////////////////////////
00029 // MBED OBJECTS
00030 ///////////////////////////////////////////////////////////////////////////////
00031 extern NextionLCD lcd;//Tx, Rx, Nextion Port
00032 
00033 //ADC/DAC
00034 AnalogIn ain(ANA_IN_A0);
00035 AnalogOut aout(ANA_OUT_DAC1);
00036 
00037 //Button Membrane 
00038 DigitalOut startLED(START_LED);
00039 DigitalOut stopLED(STOP_LED);
00040 DigitalIn startButton(START_BTN);
00041 DigitalIn stopButton(STOP_BTN);
00042 
00043 //4-20mA Control Inputs
00044 DigitalIn rmtRunStop(RUN_STOP);// Run / Stop Input
00045 DigitalIn rmtExtCont(EXT_CONT);//External Contact Input
00046 DigitalIn rmtFldRec(RMT_FLD_REC);//Remote Fluid Recovery Input
00047 
00048 //Leak detection
00049 DigitalIn leakIn(LEAK_DETECT_INPUT);//Pump head leak detection
00050 
00051 //4-20mA Control Outputs
00052 DigitalOut alarmOut1(ALARM_OUT1);
00053 DigitalOut alarmOut2(ALARM_OUT2);
00054 
00055 //Nucleo Debug LEDs
00056 DigitalOut led1(LED1);
00057 DigitalOut led2(LED2);
00058 DigitalOut led3(LED3); 
00059 
00060 //DVR8603 BLDC Motor Controller
00061 DigitalOut motEnable(MOT_EN);
00062 DigitalOut motDir(MOT_DIR);
00063 DigitalOut nBrake(N_BRK);
00064 DigitalIn nFault(N_FAULT);
00065 
00066 //Netxion Power Control
00067 DigitalOut nexPwrCont(NEX_PWR);
00068 
00069 //3V3 Power Good signal from power supply
00070 DigitalIn pwrGood(PWR_GOOD);
00071 
00072 FastPWM pwm(PWM, PWM_PRESCALER);//leave prescaler at 1 so that that the smallest speed inc/dec results in a measureable PWM change, resolution is ~20ns/bit
00073 
00074 float motorSpeed = ZERO;
00075 float motSpeedSetPoint = ZERO;
00076 float flowPercent = ZERO;
00077 float lastMaxScale = maxScale;
00078 
00079 bool leakDetect(bool leakInput){
00080     bool leak = false;    
00081 
00082     if(leakInput == true){
00083         leak = true;
00084     }   
00085 
00086     return(leak);    
00087 }
00088 
00089 bool outputFluidLevMon(void){
00090 
00091     return(0);
00092 }
00093 
00094 bool outputContactMode(void){
00095 
00096     /*
00097     
00098      need debouce routine 
00099      measure pulse time, 40 - 1000ms
00100 
00101      if valid do stuff, if pulse not valid ignore
00102 
00103      count the pulses also
00104     
00105      */
00106     return(0);
00107 }
00108 
00109 bool startBtn(bool byPassPress){//Interrupt pin
00110 /*
00111     byPassPress if true allows the fucntion to be used for LED indicators without pressing the start button
00112 */
00113     bool state = OFF;
00114 
00115     if((startButton == _ON)||(byPassPress == true)){    
00116         startLED = ON;//Keypad LEDs OFF ta power up
00117         stopLED = OFF;          
00118         state = ON;
00119     }
00120     return(state);
00121 }
00122 
00123 bool stopBtn(bool byPassPress){//Interrupt pin
00124 /*
00125     byPassPress if true allows the fucntion to be used  for LED indicators without pressing the stop button
00126 */
00127     bool state = OFF;
00128 
00129     if((stopButton == _ON)||(byPassPress  == true)){
00130         startLED = OFF;//Keypad LEDs OFF ta power up
00131         stopLED = ON;             
00132         state = ON;
00133     }
00134     return(state);
00135 }
00136 
00137 void reset(void){
00138     ml=ZERO;
00139     arrowFlag = false;
00140     motorSpeed = ZERO;
00141     motSpeedSetPoint = ZERO;
00142     ConfInputSw();
00143     confBtn();
00144     confMotor();//turn motor off    
00145     confPWM();//Reset      
00146 }
00147 
00148 void confBtn(void){
00149     startLED = OFF;//Keypad LEDs OFF ta power up
00150     stopLED = OFF;
00151     startButton.mode(PullUp);//Enable pull up resistors to 3V3
00152     stopButton.mode(PullUp);
00153 }
00154 
00155 void ConfInputSw(void){
00156     rmtFldRec.mode(PullDown);
00157     rmtExtCont.mode(PullDown);
00158     rmtRunStop.mode(PullDown);
00159 }
00160 
00161 void confMotor(void){
00162     motEnable = OFF;
00163     motDir = CCW;//Default motor direction
00164     nBrake = _OFF;
00165     tachoIn.mode(PullUp);//Speed feedback, OD Output from motor controller
00166     nFault.mode(PullUp);
00167 }
00168 
00169 uint8_t fluidRecMode(void){
00170     
00171  return(0);     
00172 }
00173 
00174 uint8_t flowCalMode(void){
00175 
00176  return(0); 
00177 }
00178 
00179 uint8_t contactMode(void){
00180 
00181  return(0); 
00182 }
00183 
00184 void anaOutScale(float mA_FullScale, float mA_MatchScale){
00185     
00186     if(nvm._4_20mAoutPut == _4_20MA_OUT_FULL_SCALE)
00187         anaOut_mA(mA_FullScale);    
00188     else
00189         if(nvm._4_20mAoutPut == _4_20MA_OUT_MATCH_INPUT_SCALE)
00190             anaOut_mA(mA_MatchScale);
00191 }
00192 
00193 void anaOut_mA(float mA){
00194 /*
00195     Current to DAC Voltage converter
00196     aout.write() has range 0.0 - 1.0
00197 */    
00198 
00199     float rawDAC_V = ZERO;
00200     float lpfDAC_V = ZERO;
00201    
00202     rawDAC_V = mapF(mA, I_3MA, I_20MA, DAC_V_LOW, DAC_V_HIGH);        
00203     aout.write(rawDAC_V);         
00204 }
00205 
00206 float anaIn_mA(void){
00207 /*
00208     Low Pass Filtered analogue signal
00209 */
00210     float rawADC_V = ZERO;//Raw ADC voltage
00211     float lpfADC_V = ZERO;//Low Pass Filtered ADC Voltage    
00212     float ana_mA = ZERO; //ADC Voltage convered to mA 
00213 
00214     rawADC_V = (ain.read() * VDD);//Output in V  
00215     lpfADC_V = low_pass_filterF(rawADC_V);
00216     ana_mA = mapF(lpfADC_V, ADC_MIN_V, ADC_MAX_V, I_0MA, I_22_4MA);
00217 
00218     return(ana_mA);    
00219 }
00220  
00221 uint8_t anaIn(void){
00222 /*
00223     Convert analogue signal to mA output and control motor speed
00224     Measured Hyteresis band is approx 50uA on QDOS 30
00225 */
00226 
00227     float lpfADC_V = ZERO;//ADC variable from Low Pass Filter 
00228     float ana_mA = ZERO;
00229     static float flowPercent;//flow rate percentage, used for map calculations
00230     static float hyst_mA = ZERO;//
00231     static bool pumpMotor =  OFF;//make sure the motor is off by default
00232  
00233     uint8_t task = RUNNING;//next normal task
00234 
00235     ana_mA = anaIn_mA();//get the analogue current from external equipment 
00236 
00237     //lcd.nexSendFloat("p1left",ana_mA,2);//update
00238          
00239     if(ana_mA >= (nvm.mA_low - hyst_mA)){//hysteresis to stop noise triggering motor control    
00240         hyst_mA = HYST_MA;
00241         pumpMotor = ON;       
00242         startBtn(ON);              
00243     }          
00244     else{
00245         hyst_mA = ZERO;  
00246         pumpMotor = OFF; 
00247         stopBtn(ON);              
00248     }
00249                 
00250       if((runStopSignal(rmtRunStop, &nvm) == false)&&(pumpMotor == ON)){//Pump is ON
00251         lcd.nexRotArrow(ON);
00252         lcd.nexSetFontCol("p1mid",BLACK);       
00253         lcd.nexSendTxt("p1mid","4-20mA Input Mode");//page 1 middle text box   
00254  
00255         flowPercent = mapF(ana_mA, nvm.mA_low, nvm.mA_high, nvm.flow_low, nvm.flow_high);//this outputs flow rate % used in map calculations     
00256 
00257         nvm.flowUnitVal = mapF(flowPercent, 0.0, 100.0, minScale, maxScale);
00258 
00259         lcd.nexSendFloat("meter", nvm.flowUnitVal, precision);//display the flow units                                           
00260 
00261         motor(flowPercent, CCW, BRAKE_OFF, MOTOR_ENABLE, 1);
00262 
00263         anaOutScale((mapF(nvm.flowUnitVal, minScale, maxScale, I_4MA, I_20MA)), (mapF(nvm.flowUnitVal, minScale, nvm.flow_high, I_4MA, I_20MA)));
00264  
00265     }
00266     else
00267     {//Pump is OFF     
00268         //lcd.nexDispSymbol("stop", OFF);          
00269         lcd.nexRotArrow(OFF);
00270         lcd.nexSetFontCol("p1mid",RED);     
00271         lcd.nexSendTxt("p1mid","4-20mA Input Mode");//page 1 middle text box    
00272         lcd.nexSendFloat("meter", METER_ZERO, precision);//bug warning: writting 0.00 result in blank writted to meter, writing 0.00001 to the meter then displays 0.0        
00273         motor(ZERO, CCW, BRAKE_OFF, MOTOR_DISABLE, 1);   
00274         anaOut_mA(I_3MA);//analogue output forced to 3mA 
00275     }      
00276     return(task);           
00277 }
00278 
00279 uint8_t manual(void){
00280 
00281     float ana_mA = 0;    
00282     static float lastFlowUnitVal = nvm.flowUnitVal;
00283     uint8_t task = RUNNING;
00284 
00285     if(runStopSignal(rmtRunStop, &nvm) == false){//Run/Stop signal logic                   
00286 
00287         flowPercent = incDecControl(&nvm.flowUnitVal, precision, minScale, maxScale, nvm.speedLimit);
00288 
00289             if((tPop.read() > 1.0)&&(lastFlowUnitVal == nvm.flowUnitVal)){//x seconds has expired save the updated  flowUnitVal to NVM memory and reload NVM
00290                 tPop.stop();
00291                 tPop.reset();
00292                 stopLED = ON;
00293                 wait(0.01);
00294                 stopLED = OFF;  
00295                 writeNVMfloat(NVM_FLOWU_VAL,nvm.flowUnitVal);        
00296             }
00297 
00298             lcd.nexRotArrow(ON);
00299             lcd.nexSetFontCol("p1mid",BLACK);                                                                                           
00300             lcd.nexSendTxt("p1mid","Manual Mode");//page 1 middle text box       
00301 
00302             nvm.flowUnitVal = ((flowPercent/100)*maxScale);
00303             lcd.nexSendFloat("meter", nvm.flowUnitVal, precision);//display the flow units   
00304                 
00305             motor(flowPercent, CCW, BRAKE_OFF, MOTOR_ENABLE, 1);    
00306 
00307             anaOut_mA(mapF(nvm.flowUnitVal, minScale, maxScale, I_4MA, I_20MA));//convert flow rate % to analogue output current    
00308 
00309             lastFlowUnitVal = nvm.flowUnitVal;//update
00310         //}
00311     }
00312     else{   
00313         //lcd.nexDispSymbol("stop", OFF);   
00314         lcd.nexRotArrow(OFF); 
00315         lcd.nexSetFontCol("p1mid",RED);                                                                                           
00316         lcd.nexSendTxt("p1mid","Manual Mode");//page 1 middle text box           
00317         motor(flowPercent, CCW, BRAKE_OFF, MOTOR_DISABLE, 1);    
00318     }
00319     
00320     return(task); 
00321 }
00322  
00323 uint8_t motor(float rpmSetPoint, bool dir, bool brake, bool enable, float rampTime){
00324 
00325     uint8_t task = RUNNING;//next normal task
00326 
00327     static float rpmRamp = ZERO;
00328     
00329     motEnable = enable;
00330     motDir = dir;
00331     nBrake = brake;
00332     
00333     if((motEnable == MOTOR_DISABLE)||(nBrake == BRAKE_ON))    
00334         rpmRamp = ZERO;
00335     else{
00336 
00337         if(rpmRamp > rpmSetPoint){    
00338 
00339             pwm.pulsewidth_us(rpmRamp);            
00340 
00341             if(rpmRamp > MOTOR_PWM_MIN)
00342                 rpmRamp-=0.1;
00343             else
00344                 rpmRamp = MOTOR_RPM_MIN;                                       
00345         }
00346 
00347         if(rpmRamp < rpmSetPoint){
00348         
00349             pwm.pulsewidth_us(rpmRamp);        
00350         
00351             if(rpmRamp < MOTOR_PWM_MAX)
00352                 rpmRamp+=0.1;
00353             else  
00354                 rpmRamp = MOTOR_PWM_MAX;                                 
00355         }                      
00356     }
00357 
00358     lcd.nexSetPrgBar("progBar",rpmRamp);  
00359 
00360     return(task);
00361 }
00362 
00363 void confPWM(void){    
00364     pwm.period_us(PWM_PERIOD);
00365     pwm.pulsewidth_us(ZERO);      
00366 }
00367 
00368 void ledClr(void){
00369     led1=OFF; 
00370     led2=OFF; 
00371     led3=OFF; 
00372 }
00373 
00374 uint8_t startUpMode(uint8_t runMode){
00375     uint8_t task = START;         
00376     uint8_t setRunMode;    
00377 
00378     setRunMode = runModeNVM(runMode);//retreive the run mode stored in NVM    
00379 
00380     if(setRunMode == ANALOGUE_SET)//if set for analogue start 
00381         task = ANALOGUE_SET;                                                  
00382     else
00383     {  
00384         if((startBtn(BTN_AND_IND))&&(setRunMode == MANUAL_SET))//if set for manual bypass start button and start                                                                                                              
00385             task = MANUAL_SET;                                                                                                                                                                                                                                                     
00386     }                                                                                                                                                                            
00387     return(task);
00388 }
00389  
00390 bool runStopSignal(bool runStopSig, struct settingsNVM *nvm){    
00391 
00392     //#define DEBUG_LOCAL
00393 
00394     #ifdef DEBUG_LOCAL
00395         uint8_t selected=0;
00396     #endif
00397 
00398     bool pumpPause = false;
00399 
00400 
00401     if((nvm->rmtStopPump == RMT_STOP_PUMP_HIGH)&&(runStopSig == HI)){  
00402 
00403         #ifdef DEBUG_LOCAL
00404             selected=1;    
00405         #endif 
00406 
00407         lcd.nexDispSymbol("pause", ON);         
00408         nvm->pumpOnOff = PUMP_OFF;                  
00409         writeNVMByte(PUMP_ON_OFF,nvm->pumpOnOff);          
00410         pumpPause = true;        
00411     }
00412     else
00413     if((nvm->rmtStopPump == RMT_STOP_PUMP_HIGH)&&(runStopSig == LO)){  
00414 
00415         #ifdef DEBUG_LOCAL
00416             selected=2;                
00417         #endif
00418 
00419         lcd.nexDispSymbol("pause", OFF);      
00420         nvm->pumpOnOff = PUMP_ON;  
00421         writeNVMByte(PUMP_ON_OFF,nvm->pumpOnOff);                           
00422         pumpPause = false;                  
00423     }    
00424     else       
00425     if((nvm->rmtStopPump == RMT_STOP_PUMP_LOW)&&(runStopSig == HI)){        
00426 
00427         #ifdef DEBUG_LOCAL        
00428             selected=3;          
00429         #endif
00430 
00431         lcd.nexDispSymbol("pause", OFF);  
00432         nvm->pumpOnOff = PUMP_ON;                
00433         writeNVMByte(PUMP_ON_OFF,nvm->pumpOnOff);                     
00434         pumpPause = false;                
00435     }
00436     else
00437     if((nvm->rmtStopPump == RMT_STOP_PUMP_LOW)&&(runStopSig == LO)){    
00438 
00439         #ifdef DEBUG_LOCAL        
00440             selected=4;          
00441         #endif    
00442 
00443         lcd.nexDispSymbol("pause", ON);   
00444         nvm->pumpOnOff = PUMP_OFF;                     
00445         writeNVMByte(PUMP_ON_OFF,nvm->pumpOnOff);                 
00446         pumpPause = true;                         
00447     }        
00448  
00449     #ifdef DEBUG_LOCAL
00450         pc.printf("\r\n\nPump On/Off = 0x%02X, Selected = %d",nvm->pumpOnOff, selected); 
00451     #endif        
00452     
00453 
00454     return(pumpPause);
00455 }
00456  
00457 void outPuts(bool leakDetection, struct settingsNVM *nvm){
00458 
00459         if((nvm->outPut1 ==  OUT1_RUN_STATUS)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)&&(nvm->pumpOnOff == PUMP_ON)){
00460         // Run status ok for manual and analogue            
00461         
00462             alarmOut1 = OFF;
00463         }
00464         else   
00465         if((nvm->outPut1 ==  OUT1_RUN_STATUS)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)&&(nvm->pumpOnOff == PUMP_OFF)){
00466             alarmOut1 = ON;
00467         }   
00468         else
00469         if((nvm->outPut1 ==  OUT1_RUN_STATUS)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)&&(nvm->pumpOnOff == PUMP_ON)){
00470             alarmOut1 = ON;
00471         }
00472         else   
00473         if((nvm->outPut1 ==  OUT1_RUN_STATUS)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)&&(nvm->pumpOnOff == PUMP_OFF)){
00474             alarmOut1 = OFF;
00475         }         
00476         else
00477         if((nvm->outPut1 ==  OUT1_MANUAL_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)&&(nvm->runMode == MANUAL)){
00478             alarmOut1 = ON;
00479         }    
00480         else
00481         if((nvm->outPut1 ==  OUT1_MANUAL_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)&&(nvm->runMode == MANUAL)){
00482             alarmOut1 = OFF;
00483         }  
00484         else
00485         if((nvm->outPut1 ==  OUT1_ANALOGUE_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)&&(nvm->runMode == ANALOGUE)){
00486             alarmOut1 = ON;
00487         }    
00488         else
00489         if((nvm->outPut1 ==  OUT1_ANALOGUE_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)&&(nvm->runMode == ANALOGUE)){
00490             alarmOut1 = OFF;
00491         }     
00492         else
00493         if((nvm->outPut1 ==  OUT1_CONTACT_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)){
00494             alarmOut1 = ON;
00495         }    
00496         else
00497         if((nvm->outPut1 ==  OUT1_CONTACT_MODE)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)){
00498             alarmOut1 = OFF;
00499         }     
00500         else
00501         if((nvm->outPut1 ==  OUT1_FLUID_LEVEL)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)){
00502             alarmOut1 = ON;
00503         }    
00504         else
00505         if((nvm->outPut1 ==  OUT1_FLUID_LEVEL)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)){
00506             alarmOut1 = OFF;
00507         }          
00508         else
00509         if((nvm->outPut1 ==  OUT1_LEAK_DETECT)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)){            
00510             alarmOut1 = ~leakDetect(leakDetection);
00511         }    
00512         else
00513         if((nvm->outPut1 ==  OUT1_LEAK_DETECT)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)){
00514             alarmOut1 = leakDetect(leakDetection);
00515         }                
00516         else
00517         if((nvm->outPut1 ==  OUT1_GENERAL_ALARM)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)){
00518         /*  Not defined in QDOS documents, I know leak detect triggers this there will be 
00519             others faults tha trigger this but at this time they are not known.
00520             
00521         */
00522             alarmOut1 = ~leakDetect(leakDetection);
00523         }    
00524         else
00525         if((nvm->outPut1 ==  OUT1_GENERAL_ALARM)&&(nvm->outPut1Logic == OUT1_LOGIC_LO)){
00526             alarmOut1 = leakDetect(leakDetection);
00527         }                
00528 
00529 
00530 
00531         if((nvm->outPut2 ==  OUT2_RUN_STATUS)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)&&(nvm->pumpOnOff == PUMP_ON)){
00532             alarmOut2 = OFF;
00533         }
00534         else   
00535         if((nvm->outPut2 ==  OUT2_RUN_STATUS)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)&&(nvm->pumpOnOff == PUMP_OFF)){
00536             alarmOut2 = ON;
00537         }   
00538         else
00539         if((nvm->outPut2 ==  OUT2_RUN_STATUS)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)&&(nvm->pumpOnOff == PUMP_ON)){
00540             alarmOut2 = ON;
00541         }
00542         else   
00543         if((nvm->outPut2 ==  OUT2_RUN_STATUS)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)&&(nvm->pumpOnOff == PUMP_OFF)){
00544             alarmOut2 = OFF;
00545         }     
00546         else
00547         if((nvm->outPut2 ==  OUT2_MANUAL_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)&&(nvm->runMode == MANUAL)){
00548             alarmOut2 = ON;
00549         }    
00550         else
00551         if((nvm->outPut2 ==  OUT2_MANUAL_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)&&(nvm->runMode == MANUAL)){
00552             alarmOut2 = OFF;
00553         }    
00554         else
00555         if((nvm->outPut2 ==  OUT2_ANALOGUE_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)&&(nvm->runMode == ANALOGUE)){
00556             alarmOut2 = ON;
00557         }    
00558         else
00559         if((nvm->outPut2 ==  OUT2_ANALOGUE_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)&&(nvm->runMode == ANALOGUE)){
00560             alarmOut2 = OFF;
00561         }             
00562         else
00563         if((nvm->outPut2 ==  OUT2_CONTACT_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)){
00564             alarmOut2 = ON;
00565         }    
00566         else
00567         if((nvm->outPut2 ==  OUT2_CONTACT_MODE)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)){
00568             alarmOut2 = OFF;
00569         }             
00570         else
00571         if((nvm->outPut1 ==  OUT1_FLUID_LEVEL)&&(nvm->outPut1Logic == OUT1_LOGIC_HI)){
00572             alarmOut1 = ON;
00573         }    
00574         else
00575         if((nvm->outPut2 ==  OUT2_FLUID_LEVEL)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)){
00576             alarmOut2 = OFF;
00577         }          
00578         else
00579         if((nvm->outPut2 ==  OUT2_LEAK_DETECT)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)){            
00580             alarmOut2 = ~leakDetect(leakDetection);
00581         }    
00582         else
00583         if((nvm->outPut2 ==  OUT2_LEAK_DETECT)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)){
00584             alarmOut2 = leakDetect(leakDetection);
00585         }                
00586         else
00587         if((nvm->outPut2 ==  OUT2_GENERAL_ALARM)&&(nvm->outPut2Logic == OUT2_LOGIC_HI)){
00588         /*  Not defined in QDOS documents, I know leak detect triggers this there will be 
00589             others faults tha trigger this but at this time they are not known.
00590             
00591         */
00592             alarmOut2 = ~leakDetect(leakDetection);
00593         }    
00594         else
00595         if((nvm->outPut2 ==  OUT2_GENERAL_ALARM)&&(nvm->outPut2Logic == OUT2_LOGIC_LO)){
00596             alarmOut2 = leakDetect(leakDetection);
00597         }           
00598 }     
00599 
00600