-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsudocode.txt
129 lines (79 loc) · 2.74 KB
/
sudocode.txt
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Declare variables
#Master
#Gen
#Inverter
#GenTurnOnCheck (To disable generator automatic turn on, input should come from the mobile app)
startup-
disable all relays,
check voltages (display them)
if above 255 /<130 &>30 display triangle in front of faulty one and sound buzzer
if button pressed for 3 seconds bypass fault mode(disable buzzer and allow connection to that output)
check if in auto or manual mode
If auto mode==true{
check voltages
if master==normal && gen==on
Turn off gen relay
Send off command to gen
If master==off & gen =off & inv==off
Atmega 328 sends “gen on” over serial to the esp8266
The esp8266 connect to the prenamed wifi and,
Send “gen on” to client to turn on generator,
Wait for 30 seconds to repeat.
If more than 5 retries stop
If master==off & gen =off & inv==on
Use inverter
if master==normal
Turn on master relay
Turn off others
if master==normal && inv=on
Turn off inv rel turn on master
If inv==on }
Master - 0, gen - 0, inv - 0 (Turn on gen)
Master - 1, gen - 1, inv - 1 (Turn off gen, Switch to Master, Turn off Inv)
Master - 1, gen - 0, inv - 0 ( Switch to Master)
Master - 1, gen - 1, inv - 0 ( Switch to Master, Turn of gen)
Master - 0, gen - 1, inv - 0 (Turn off Master, Switch to Gen, Turn off Inv )
Master - 1, gen - 1, inv - 0 (Turn off gen, Switch to Master, Turn off Inv)
Master - 0, gen - 0, inv - 1 (Turn off gen, Turn off Master, Turn on Inv)
Master - 0, gen - 1, inv - 1 (Turn off gen, Turn off Master, Turn on Inv)
Manual mode
On master by default
Store current mode in eeprom
If relay toggle (changeover button) button ==low for 3 seconds,
Display current mode count to 10
If relay toggle button (changeover button) ==low
Display next mode reset count variable and count to 10
If relay toggle button (changeover button) == low
Display next mode , reset count variable count to 10
If count>10 choose current mode
Display (Current voltage source takes majority of the screen)
Display mode
Display current
Display the current voltage source
Display voltages of the 3 inputs
Display battery voltage
Generator board
Turns on checks the presence of ac
Connect to wifi
Fnxn gen startup
Make servo turn choke, turn on first stage relay,
Turn on the 2nd stage relay for 3 seconds.
Wait for 10 seconds
Turn off choke
Check for ac
If ac==false, turn off relay1 and repeat
If ac ==true, leave stage 1 relay on
Fnxn gen off
Turn off stage 1 relay
If manual button is pressed and held for 3 seconds
Check ac presence
If ac==false
Run gen startup protocol once
If ac==true
Turn off generator
If “gen on” received over wifi,
run genstartup fnxn with 5 retries
If fails send “failed” to changeover
If bat<2.8 turn on the power relay
Send “low battery over wifi
Else power relay==off