summaryrefslogtreecommitdiff
path: root/Arduino
diff options
context:
space:
mode:
authorJoshua Drake <joshua.ellis.drake@gmail.com>2024-03-05 17:07:53 -0600
committerJoshua Drake <joshua.ellis.drake@gmail.com>2024-03-05 17:07:53 -0600
commitef97092cd93ce28fb72980e7594a80577545016f (patch)
tree7e0243547641003c338399432f3b3ad8423b86be /Arduino
parent4f975a707e8fe5c6d7dd01babd275b9c1d270251 (diff)
Added simple arduino code to communicate with the controller board.
Diffstat (limited to 'Arduino')
-rw-r--r--Arduino/main.c/main.c.ino46
1 files changed, 46 insertions, 0 deletions
diff --git a/Arduino/main.c/main.c.ino b/Arduino/main.c/main.c.ino
new file mode 100644
index 0000000..2efa972
--- /dev/null
+++ b/Arduino/main.c/main.c.ino
@@ -0,0 +1,46 @@
+#include <Wire.h>
+double VOLTAGE;
+double P150;
+double P100;
+double load;
+int Q150;
+int Q100;
+void setup()
+{
+ Wire.begin(0x00);
+ Serial.begin(9600);
+ Serial.println("Enter Nominal System Voltage:");
+ VOLTAGE = Serial.read();
+ Serial.print("System Voltage: ");
+ Serial.println(VOLTAGE, DEC);
+ P150 = VOLTAGE/150;
+ P100 = VOLTAGE/100;
+ Serial.println("Enter Load in kW:");
+}
+
+void loop()
+{
+ load = Serial.read();
+ 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.println("kW unaccounted for.");
+ Wire.beginTransmission(0x01); //Controller Board Has Address 0x01
+ Wire.write((Q150 << 3) & Q150);
+ Wire.endTransmission();
+}