attempt to fix posible power issues with the sharp
Dependencies: ADS1115 BME280 CronoDot SDFileSystem mbed
Fork of Outdoor_UPAS_v1_2_Tboard by
Diff: main.cpp
- Revision:
- 50:5f1b378e4f64
- Parent:
- 49:055231b09a7e
- Child:
- 51:feba3e2aa1a0
--- a/main.cpp Thu May 05 22:00:03 2016 +0000 +++ b/main.cpp Sun May 08 00:50:41 2016 +0000 @@ -679,6 +679,54 @@ vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0 omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3 + /* + omronReading = ads.readADC_SingleEnded(0, 0xC383); // read channel 0 PGA = 2 : Full Scale Range = 2.048V + omronVolt = (omronReading*4.096)/(32768*1); + vBlowerReading = ads.readADC_SingleEnded(2, 0xE783); // read channel 0 + omronDiff = ads.readADC_Differential(0x8583); // differential channel 2-3 + + if(omronVolt<=calibrations.omronVMin) { + massflow = calibrations.omronMFMin; + } else if(omronVolt>=calibrations.omronVMax) { + massflow = calibrations.omronMFMax; + } else { + massflow = calibrations.MF4*pow(omronVolt,(float)4)+calibrations.MF3*pow(omronVolt,(float)3)+calibrations.MF2*pow(omronVolt,(float)2)+calibrations.MF1*omronVolt+calibrations.MF0; + } + + atmoRho = ((press-((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)))*100)/(287.0531*(temp+273.15))+((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)*100)/(461.4964*(temp+273.15)); + volflow = massflow/atmoRho; + sampledVol = sampledVol + ((((float)logInerval)/60.0)*volflow); + deltaVflow = volflow-volflowSet; + massflowSet = volflowSet*atmoRho; + deltaMflow = massflow-massflowSet; + + if(abs(deltaMflow)>.025) { + digital_pot_change = (int)(gainFlow*deltaMflow); + + + if(abs(digital_pot_change)>=10) { + digital_pot_set = (int)(digital_pot_set+ (int)(1*deltaMflow)); + //RGB_LED.set_led(1,0,0); + } else { + digital_pot_set = (digital_pot_set+ digital_pot_change); + //RGB_LED.set_led(1,1,0); + } + + if(digital_pot_set>=digitalpotMax) { + digital_pot_set = digitalpotMax; + //RGB_LED.set_led(1,0,0); + } else if(digital_pot_set<=digitalpotMin) { + digital_pot_set = digitalpotMin; + //RGB_LED.set_led(1,0,0); + } + + DigPot.writeRegister(digital_pot_set); + + } else { + //RGB_LED.set_led(0,1,0); + } + */ + } @@ -711,8 +759,8 @@ ////////////////////////////////////////////////////////////// void flowControl() { - - //RGB_LED.set_led(0,1,0); + if(pumps == 1){ + //RGB_LED.set_led(1,1,1); omronReading = ads.readADC_SingleEnded(0, 0xC383); // read channel 0 PGA = 2 : Full Scale Range = 2.048V omronVolt = (omronReading*4.096)/(32768*1); @@ -736,7 +784,7 @@ if(abs(digital_pot_change)>=10) { - digital_pot_set = (int)(digital_pot_set+ (int)(1*deltaMflow)); + digital_pot_set = (int)(digital_pot_set+ (int)((2/volflowSet)*deltaMflow)); //RGB_LED.set_led(1,0,0); } else { digital_pot_set = (digital_pot_set+ digital_pot_change); @@ -756,7 +804,7 @@ } else { //RGB_LED.set_led(0,1,0); } - + } } //////////////////////////////////////////////////////////////