blob: 94570bcb25c8bc77b4b25830a7ccd3506dc3c8cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <Wire.h>
double VOLTAGE;
double P150;
double P100;
double load = 0;
int Q150;
int Q100;
void setup()
{
Wire.begin(0x00);
Serial.begin(9600);
Serial.println("Enter Nominal System Voltage:");
while (Serial.available() == 0){;}
VOLTAGE = Serial.parseFloat(SKIP_ALL);
Serial.print("System Voltage: ");
Serial.println(VOLTAGE, DEC);
P150 = (VOLTAGE*VOLTAGE)/150;
P100 = (VOLTAGE*VOLTAGE)/100;
Serial.println("Enter Load in kW:");
}
void loop()
{
Serial.flush();
//while (!Serial.available()){;}
double temp = Serial.parseFloat(SKIP_ALL)*1000;
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.
{
Q100 = load/P100;
if(Q100 > 5) Q100=5;
Q150 = (load - (Q100*P100))/P150;
}
else
{
Q150 = load/P150;
Q100 = 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 activated. ");
//Serial.print(load - ((P150*Q150)+(P100*Q100)),DEC);
Serial.print(((P150*Q150)+(P100*Q100)),DEC);
Serial.println("W Accounted for.");
}
Wire.beginTransmission(0x01); //Controller Board Has Address 0x01
Wire.write((Q150 << 3) & Q150);
Wire.endTransmission();
}
|