-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffbridge.ino
195 lines (164 loc) · 5.26 KB
/
ffbridge.ino
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#include "SoulissFramework.h"
#include "bconf/StandardArduino.h"
#include "conf/ethW5100.h"
#include "conf/usart.h"
#include "conf/SuperNode.h"
#define USARTDRIVER_INSKETCH
#define USARTBAUDRATE_INSKETCH
#define USART_BAUD9k6 1
#define USART_TXENABLE 1
#define USART_TXENPIN 2
#define USARTDRIVER Serial1
/*#define SERIALPORT_INSKETCH
#define LOG Serial
#define VNET_DEBUG_INSKETCH
#define VNET_DEBUG 1*/
#include <SPI.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
//define IP network config
uint8_t ip_address[4] = {192, 168, 1, 78};
uint8_t subnet_mask[4] = {255, 255, 255, 0};
uint8_t ip_gateway[4] = {192, 168, 1, 1};
#define myvNet_address ip_address[3]
#define gw_address 77
// Define the RS485 network configuration
#define myvNet_subnet 0xFF00
#define Gateway_RS485 0xDE01
#define GLent 0xDE02
#define GFent 0xDE03
#define Tekla 0xDE04
#define Halo 0xDE05
#define Vendeg 0xDE06
#define Furdo 0xDE07
// Local light slots
#define SL_MUTEREM 0
#define SL_TEKLA 1
#define SL_HALO 2
#define SL_VENDEG 3
#define SL_FURDO 4
// Local blind slots
#define SB_TEKLA 5
#define SB_HALO 6
#define SB_RTEKLA 7
#define SB_RHALO 8
#define SB_RSTUDIO1 9
#define SB_RSTUDIO2 10
#define SB_RSTUDIO3 11
#define SB_RVENDEG 12
#define BL_TIMEOUT 0xAD
#define BL_RTIMEOUT 0xC4
// Local light output PINs
#define MUTEREM 22
#define TEKLA 23
#define HALO 24
#define VENDEG 25
#define FURDO 26
// Local blind output PINs
#define TEKLAF 28
#define TEKLAL 29
#define HALOF 30
#define HALOL 31
#define RTEKLAF 44
#define RTEKLAL 45
#define RHALOF 34
#define RHALOL 35
#define RSTUDIO1F 36
#define RSTUDIO1L 37
#define RSTUDIO2F 38
#define RSTUDIO2L 39
#define RSTUDIO3F 40
#define RSTUDIO3L 41
#define RVENDEGF 46
#define RVENDEGL 47
void setup() {
Initialize();
Souliss_SetIPAddress(ip_address, subnet_mask, ip_gateway);
SetAddress(Gateway_RS485, myvNet_subnet, 0); // Set the address on the RS485 bus
SetAddress(myvNet_address, myvNet_subnet, gw_address);
//Serial.begin(9600); //needed for debug only
// Define PINs as output
for (int thisPin = 22; thisPin < 44; thisPin++) {
pinMode(thisPin, OUTPUT);
}
// Drive lights low by default
for (int thisPin = 22; thisPin < 44; thisPin++) {
digitalWrite(thisPin, LOW);
}
// Define light logic
Set_T11(SL_MUTEREM);
Set_T11(SL_TEKLA);
Set_T11(SL_HALO);
Set_T11(SL_VENDEG);
Set_T11(SL_FURDO);
// Define T22 logic for all motors
Set_T22(SB_TEKLA);
Set_T22(SB_HALO);
Set_T22(SB_RTEKLA);
Set_T22(SB_RHALO);
Set_T22(SB_RSTUDIO1);
Set_T22(SB_RSTUDIO2);
Set_T22(SB_RSTUDIO3);
Set_T22(SB_RVENDEG);
}
void loop() {
EXECUTEFAST() {
UPDATEFAST();
FAST_110ms() {
// This starts the lights logic
Logic_T11(SL_MUTEREM);
Logic_T11(SL_TEKLA);
Logic_T11(SL_HALO);
Logic_T11(SL_VENDEG);
Logic_T11(SL_FURDO);
// This starts the blind logic
Souliss_Logic_T22(memory_map, SB_TEKLA, &data_changed, BL_TIMEOUT);
Souliss_Logic_T22(memory_map, SB_HALO, &data_changed, BL_TIMEOUT);
Souliss_Logic_T22(memory_map, SB_RTEKLA, &data_changed, BL_RTIMEOUT);
Souliss_Logic_T22(memory_map, SB_RHALO, &data_changed, BL_RTIMEOUT);
Souliss_Logic_T22(memory_map, SB_RSTUDIO1, &data_changed, BL_RTIMEOUT);
Souliss_Logic_T22(memory_map, SB_RSTUDIO2, &data_changed, BL_RTIMEOUT);
Souliss_Logic_T22(memory_map, SB_RSTUDIO3, &data_changed, BL_RTIMEOUT);
Souliss_Logic_T22(memory_map, SB_RVENDEG, &data_changed, BL_RTIMEOUT);
//This pulls the PINs High for light control
DigOut(MUTEREM, Souliss_T1n_Coil, SL_MUTEREM);
DigOut(TEKLA, Souliss_T1n_Coil, SL_TEKLA);
DigOut(HALO, Souliss_T1n_Coil, SL_HALO);
DigOut(VENDEG, Souliss_T1n_Coil, SL_VENDEG);
DigOut(FURDO, Souliss_T1n_Coil, SL_FURDO);
// This pulls the PINs Low for blind control
DigOut(TEKLAF, Souliss_T2n_Coil_Open, SB_TEKLA);
DigOut(TEKLAL, Souliss_T2n_Coil_Close, SB_TEKLA);
DigOut(HALOF, Souliss_T2n_Coil_Open, SB_HALO);
DigOut(HALOL, Souliss_T2n_Coil_Close, SB_HALO);
DigOut(RTEKLAF, Souliss_T2n_Coil_Open, SB_RTEKLA);
DigOut(RTEKLAL, Souliss_T2n_Coil_Close, SB_RTEKLA);
DigOut(RHALOF, Souliss_T2n_Coil_Open, SB_RHALO);
DigOut(RHALOL, Souliss_T2n_Coil_Close, SB_RHALO);
DigOut(RSTUDIO1F, Souliss_T2n_Coil_Open, SB_RSTUDIO1);
DigOut(RSTUDIO1L, Souliss_T2n_Coil_Close, SB_RSTUDIO1);
DigOut(RSTUDIO2F, Souliss_T2n_Coil_Open, SB_RSTUDIO2);
DigOut(RSTUDIO2L, Souliss_T2n_Coil_Close, SB_RSTUDIO2);
DigOut(RSTUDIO3F, Souliss_T2n_Coil_Open, SB_RSTUDIO3);
DigOut(RSTUDIO3L, Souliss_T2n_Coil_Close, SB_RSTUDIO3);
DigOut(RVENDEGF, Souliss_T2n_Coil_Open, SB_RVENDEG);
DigOut(RVENDEGL, Souliss_T2n_Coil_Close, SB_RVENDEG);
}
FAST_1110ms() {
Timer_Windows(SB_TEKLA);
Timer_Windows(SB_HALO);
Timer_Windows(SB_RTEKLA);
Timer_Windows(SB_RHALO);
Timer_Windows(SB_RSTUDIO1);
Timer_Windows(SB_RSTUDIO2);
Timer_Windows(SB_RSTUDIO3);
Timer_Windows(SB_RVENDEG);
}
FAST_BridgeComms();
}
EXECUTESLOW() {
UPDATESLOW();
SLOW_10s() {
}
}
}