diff options
Diffstat (limited to 'Arduino/main.c/main.c.ino')
-rw-r--r-- | Arduino/main.c/main.c.ino | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Arduino/main.c/main.c.ino b/Arduino/main.c/main.c.ino index cf6ea90..c527c33 100644 --- a/Arduino/main.c/main.c.ino +++ b/Arduino/main.c/main.c.ino @@ -1,8 +1,8 @@ #include <Wire.h> -double VOLTAGE, P100, P150; +double VOLTAGE, P68, P150; double temp, load = 0; -uint8_t Q100, Q150; +uint8_t Q68, Q150; bool new_message = false; void setup() @@ -15,7 +15,7 @@ void setup() Serial.print("System Voltage: "); Serial.println(VOLTAGE, DEC); P150 = (VOLTAGE * VOLTAGE) / 150; - P100 = (VOLTAGE * VOLTAGE) / 100; + P68 = (VOLTAGE * VOLTAGE) / 68; Serial.println("Enter Load in kW:"); } @@ -28,32 +28,32 @@ void loop() if ((temp != load) && (temp > 0)) { load = temp; - if (VOLTAGE <= 500) //We don't want to use the 100ohm resistors if the voltage is higher than 500 as they would draw excessive power. + if (VOLTAGE <= 420) //We don't want to use the 68ohm resistors if the voltage is higher than 420 as they would draw excessive power. { - Q100 = load / P100; - if (Q100 > 5) Q100 = 5; - Q150 = (load - (Q100 * P100)) / P150; + Q68 = load / P68; + if (Q68 > 5) Q68 = 5; + Q150 = (load - (Q68 * P68)) / P150; } else { Q150 = load / P150; - Q100 = 0; + Q68 = 0; } if (Q150 > 15) Q150 = 15; Serial.print("A combination of "); Serial.print(Q150, DEC); Serial.print(" 150ohm and "); - Serial.print(Q100, DEC); - Serial.print(" 100ohm resistors will be requested. "); + Serial.print(Q68, DEC); + Serial.print(" 68ohm resistors will be requested. "); //Serial.print(load - ((P150*Q150)+(P100*Q100)),DEC); - Serial.print(((P150 * Q150) + (P100 * Q100)), DEC); + Serial.print(((P150 * Q150) + (P68 * Q68)), DEC); Serial.println("W Accounted for."); new_message = true; } delay(50); Wire.beginTransmission(0x30); //Controller Board Has Address 0x07 Wire.write(0x01); //First "EEPROM Address" stores resistor data. - Wire.write((Q100 << 4) | Q150); + Wire.write((Q68 << 4) | Q150); Wire.endTransmission(); @@ -64,7 +64,7 @@ void loop() int c = Wire.read(); Serial.print("Quantity of 150Ohm: "); Serial.print(c & 0b00001111); //Print Q150 - Serial.print(" Quantity of 100Ohm: "); + Serial.print(" Quantity of 68Ohm: "); Serial.print((c & 0b01110000)>>4); Serial.println(" was recieved."); } |