Firenet

Check-in [4a9ce4e2f6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update with DOC fixes
Timelines: family | ancestors | descendants | both | NEWNET
Files: files | file ages | folders
SHA1:4a9ce4e2f6252d201621e3d8ac0425bac5098e2b
User & Date: jim 2013-02-17 12:25:50
Context
2013-02-18
10:50
Getting ready for movie check-in: 4c4d2dad94 user: jim tags: NEWNET
2013-02-17
12:25
Update with DOC fixes check-in: 4a9ce4e2f6 user: jim tags: NEWNET
2013-02-10
15:35
Update for images check-in: 56558fd966 user: jim tags: NEWNET
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Arduino/diag/fireDiag/Firediag.pde.

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
....
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
....
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
....
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
....
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
....
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
....
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
static void test_mode_action(PACKET *pkt );
static void backoff_time_action( PACKET *pkt );

static void getdata_action( PACKET *pkt );

// EEPROM  functions

static void check_eerom();
static int get_address();
static int set_address( int addr );
static int get_fire_time();
static int set_fire_time( int addr );
static bool get_test_mode();
static void set_test_mode( bool addr );
static int get_backoff_time();
................................................................................
*  16-May-2010  Add in ADDRESS setup
*
**********************************************************************/

void setup() 
{
    int i;
    unsigned char addr,caddr;
    
  // Open the serial port at 38400 bps:
  
  Serial.begin(38400);
  DEBUG_PRINT("\r\nFiring Test PGM V[ ");
  DEBUG_PRINT(__DATE__);
  DEBUG_PRINT(" ");
  DEBUG_PRINT(__TIME__);
  DEBUG_PRINTLN("]");

  
  // Check EEPROM
  
  check_eeprom();
  
  // Build the channel list
  
................................................................................
*
*	OUTPUT:	NONE
*
**********************************************************************/

void loop()
{
    int i,n;
    int buf_psn = 0;
    long now;
    char val;
    int len;
    char ch;
    int fired = 0;
    bool fire_check = false;	// [83c43c7cd5]

#if 0
	#pragma mark -
	#pragma mark LOOP PKT PROCESS
#endif
................................................................................

static void channel_action( PACKET *pkt )
{
	int ch;
	int ad;
	char *buffer;
	int psn;
	int val;
	char *bufp;
	
	// Build response
	
	buffer = (char *)&buf[0];
	
	buffer[0] = 'R';
................................................................................
*				== 1	=> test mode on
*
**********************************************************************/

static void test_mode_action( PACKET *pkt )
{
   	bool tmode = false;
   	bool tmode_value;
    char *buffer;
    int psn;
    char *bufp;

        
	DEBUG_PRINT("Test Mode Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*	OUTPUT:	Change board return backoff time
*
**********************************************************************/

static void backoff_time_action( PACKET *pkt )
{
   	int bt = 0;
   	int i;
    char *buffer;
    int psn;
    char *bufp;

        
	DEBUG_PRINT("Backoff Time Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*
*	OUTPUT:	Returns response with data
*
**********************************************************************/

static void getdata_action( PACKET *pkt )
{
   	int bt = 0;
   	int i,n;
    char *buffer;
    int psn;
    char *buft;

        
	DEBUG_PRINT("Get Data Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*	OUTPUT:	Returns backoff time (if none returns default)
*
**********************************************************************/

static int get_backoff_time()
{
	unsigned int bt,cbt;
	unsigned val;
	
	// (1) Read the address and the compliment value
	// from EERPROM
	
	bt = EEPROM.read( BACKOFF_TIME_LCN );	
	cbt = EEPROM.read( BACKOFF_TIME_LCNC );
	cbt = 0xff & ~cbt;
................................................................................
*
**********************************************************************/

		
static int set_backoff_time( int backt )
{
	unsigned int bt,cbt;
	unsigned char part;
	
	// (1) Build the address and compliment
	
	bt = backt;
	cbt = 0xff & ~backt;
	
	// (2) Now write them to eerom
................................................................................
	return( rtn );
}

#define CR	0x0D
#define LF	0x0A
#define BS	0x08
#define DEL	0x7f
#define SP	0x20
#define BEL	0x07

/***********************************************************************
*
*  int get_input( int len,char *buffer )
*
*	INPUT:  len    - # Characters in buffer	







|







 







|









>







 







|




|







 







|







 







|







 







|







 







|
|







 







|







 







|







 







|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
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
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
...
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
....
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
....
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
....
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
....
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
....
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
....
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
static void test_mode_action(PACKET *pkt );
static void backoff_time_action( PACKET *pkt );

static void getdata_action( PACKET *pkt );

// EEPROM  functions

//static void check_eerom();
static int get_address();
static int set_address( int addr );
static int get_fire_time();
static int set_fire_time( int addr );
static bool get_test_mode();
static void set_test_mode( bool addr );
static int get_backoff_time();
................................................................................
*  16-May-2010  Add in ADDRESS setup
*
**********************************************************************/

void setup() 
{
    int i;
    //unsigned char addr,caddr;
    
  // Open the serial port at 38400 bps:
  
  Serial.begin(38400);
  DEBUG_PRINT("\r\nFiring Test PGM V[ ");
  DEBUG_PRINT(__DATE__);
  DEBUG_PRINT(" ");
  DEBUG_PRINT(__TIME__);
  DEBUG_PRINTLN("]");
  //DEBUG_PRINTLN("-- USE FIRNET PACKET --");
  
  // Check EEPROM
  
  check_eeprom();
  
  // Build the channel list
  
................................................................................
*
*	OUTPUT:	NONE
*
**********************************************************************/

void loop()
{
    int n;
    int buf_psn = 0;
    long now;
    char val;
    int len;
    //char ch;
    int fired = 0;
    bool fire_check = false;	// [83c43c7cd5]

#if 0
	#pragma mark -
	#pragma mark LOOP PKT PROCESS
#endif
................................................................................

static void channel_action( PACKET *pkt )
{
	int ch;
	int ad;
	char *buffer;
	int psn;
	//int val;
	char *bufp;
	
	// Build response
	
	buffer = (char *)&buf[0];
	
	buffer[0] = 'R';
................................................................................
*				== 1	=> test mode on
*
**********************************************************************/

static void test_mode_action( PACKET *pkt )
{
   	bool tmode = false;
   	bool tmode_value = 0;
    char *buffer;
    int psn;
    char *bufp;

        
	DEBUG_PRINT("Test Mode Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*	OUTPUT:	Change board return backoff time
*
**********************************************************************/

static void backoff_time_action( PACKET *pkt )
{
   	int bt = 0;
   	int i = 0;
    char *buffer;
    int psn;
    char *bufp;

        
	DEBUG_PRINT("Backoff Time Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*
*	OUTPUT:	Returns response with data
*
**********************************************************************/

static void getdata_action( PACKET *pkt )
{
   	//int bt = 0;
   	int i;
    char *buffer;
    int psn;
    char *buft;

        
	DEBUG_PRINT("Get Data Action ");
	DEBUG_PRINTLN(pkt->data);
................................................................................
*	OUTPUT:	Returns backoff time (if none returns default)
*
**********************************************************************/

static int get_backoff_time()
{
	unsigned int bt,cbt;
	//unsigned val;
	
	// (1) Read the address and the compliment value
	// from EERPROM
	
	bt = EEPROM.read( BACKOFF_TIME_LCN );	
	cbt = EEPROM.read( BACKOFF_TIME_LCNC );
	cbt = 0xff & ~cbt;
................................................................................
*
**********************************************************************/

		
static int set_backoff_time( int backt )
{
	unsigned int bt,cbt;
	//unsigned char part;
	
	// (1) Build the address and compliment
	
	bt = backt;
	cbt = 0xff & ~backt;
	
	// (2) Now write them to eerom
................................................................................
	return( rtn );
}

#define CR	0x0D
#define LF	0x0A
#define BS	0x08
#define DEL	0x7f
//#define SP	0x20
#define BEL	0x07

/***********************************************************************
*
*  int get_input( int len,char *buffer )
*
*	INPUT:  len    - # Characters in buffer	

Changes to Arduino/diag/fireDiag/eerom.h.

44
45
46
47
48
49
50
51
#define TEST_MODE_LCN		8
#define CTEST_MODE_LCN		9

// Backoff time data
#define BACKOFF_TIME_LCN	10
#define BACKOFF_TIME_LCNC	11

#endif EERPOM_H







|
44
45
46
47
48
49
50
51
#define TEST_MODE_LCN		8
#define CTEST_MODE_LCN		9

// Backoff time data
#define BACKOFF_TIME_LCN	10
#define BACKOFF_TIME_LCNC	11

#endif

Changes to Arduino/diag/fireDiag/newnet.h.

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define LED      9

#define TX_CNTL  13

#define DEVICE_PRESENT		0x80	// Above this device connected
#define FIRE_CHANNELS		6
#define DEF_FIRE_TIME		3000	// # ms to fire channel
#define  FIRE_CHECK_TIME	100		// Check fired every 100 ms
#define  FIRE_CHECK_WAIT	1		// Wait 1 ms for before pres measure

#define MSG_HDR		':'
#define MSG_TRLR	';'
#define DATA_SEP	','
#define PHY_DATA_SIZE	32		// Max size of data xfered
#define CKSUM_MODULO	100		// For address calc







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#define LED      9

#define TX_CNTL  13

#define DEVICE_PRESENT		0x80	// Above this device connected
#define FIRE_CHANNELS		6
#define DEF_FIRE_TIME		3000	// # ms to fire channel
#define  FIRE_CHECK_TIME	300		// Check fired every 100 ms
#define  FIRE_CHECK_WAIT	1		// Wait 1 ms for before pres measure

#define MSG_HDR		':'
#define MSG_TRLR	';'
#define DATA_SEP	','
#define PHY_DATA_SIZE	32		// Max size of data xfered
#define CKSUM_MODULO	100		// For address calc

Changes to Docs/firenet.lyx.

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
....
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622






































1623
1624
1625
1626
1627
1628
1629
....
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
....
1782
1783
1784
1785
1786
1787
1788


1789
1790
1791
1792
1793
1794
1795
....
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
....
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
....
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
....
2589
2590
2591
2592
2593
2594
2595
2596





2597
2598
2599
2600
2601
2602
2603
2604
2605
....
4021
4022
4023
4024
4025
4026
4027









4028
4029
4030
4031
4032
4033
4034
....
4124
4125
4126
4127
4128
4129
4130


4131
4132
4133
4134
4135
4136
4137
....
4144
4145
4146
4147
4148
4149
4150
4151








4152
4153
4154
4155
4156
4157
4158
....
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255

4256
4257
4258
4259
4260
4261
4262
....
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
....
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
....
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
....
5838
5839
5840
5841
5842
5843
5844
5845




5846
5847
5848
5849
5850
5851
5852



5853
5854
5855
5856
5857
5858
5859
5860
....
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
....
6260
6261
6262
6263
6264
6265
6266
6267

6268
6269
6270
6271
6272
6273
6274
....
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
....
8537
8538
8539
8540
8541
8542
8543
8544

8545
8546
8547
8548
8549
8550
8551
....
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
.....
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
.....
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
.....
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
.....
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
.....
11610
11611
11612
11613
11614
11615
11616

11617
11618
11619
11620
11621
11622
11623
.....
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
.....
11772
11773
11774
11775
11776
11777
11778
11779

11780
11781
11782
11783
11784
11785
11786
.....
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
.....
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
.....
13038
13039
13040
13041
13042
13043
13044

13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
.....
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
.....
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
.....
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
.....
13416
13417
13418
13419
13420
13421
13422

















































13423
13424
13425
13426
13427
13428
13429
.....
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
.....
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579

\begin_layout Plain Layout


\backslash
renewcommand{
\backslash
revisionNumber}{3.1}
\end_layout

\end_inset


\end_layout

................................................................................
\end_layout

\begin_layout Author
Jim Schimpf
\end_layout

\begin_layout Date
6 April 2012
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout
................................................................................

\backslash
copyright
\end_layout

\end_inset

2009-2012 Pandora Products.
 All rights reserved.
 Pandora product and company names, as well as their respective logos are
 trademarks or registered trademarks of Pandora Products.
 All other product names mentioned herein are trademarks or registered trademark
s of their respective owners.
 
\end_layout
................................................................................
\shape default
.
\end_layout

\begin_layout Standard
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="33" columns="4">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0.5in">
<column alignment="center" valignment="top" width="0.5in">
<column alignment="block" valignment="top" width="3in">
<column alignment="center" valignment="top" width="1in">
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
................................................................................
31-Dec-2011
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3.1
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
js
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Minor editing
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6-Apr-2012
\end_layout







































\end_inset
</cell>
</row>
</lyxtabular>

\end_inset

................................................................................
\end_layout

\begin_layout Subsection
Introduction
\end_layout

\begin_layout Standard
The FIRENET system is shown in 
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:FIRENET-System"

\end_inset

.
................................................................................
LatexCommand cite
key "libmicrohttpd"

\end_inset

.
 This latter acts as a Web Server and transports the REST protocol commands.


 Finally an HTML and Javascript application that runs on the browser in
 the Interface Computer, this is used supply an OS agnostic user interface
 to the system.
\end_layout

\begin_layout Subsection
User Interface
................................................................................

\begin_layout Standard
The web server running on the Control Computer actually has two functions,
 it can just serve up web pages and second under control of Lua scripting
 it can interact in a RESTful manner.
 Serving up web pages allows the system when contacted by the interface
 computer to serve up Login pages or the Javascript application.
 On the application is running the interface computer browser it then interacts
 with the web browser in a RESTful manner.
\end_layout

\begin_layout Subsubsection
REST use
\end_layout

\begin_layout Standard
In the system used here we restrict ourselves to just two commands GET and
 POST.
 The HTTP GET command is used to query the system for information and the
 POST command is used to cause the system to do some action.
 There is a wide latitude in how RESTful commands are done, you can either
 put command parameters (in a POST) in a JSON
\begin_inset CommandInset citation
LatexCommand cite
key "JSON"
................................................................................

) we then have commands to do the administrative or FIRENET functions.
 Doing GETs will return data from a node and doing a POST will cause some
 action.
\end_layout

\begin_layout Standard
For the following examples we will assume the web server (Control computer)
 is at http://192.168.1.100:8080 and that the base of the RESTful tree is at
 REST.
\end_layout

\begin_layout Standard
So a full FIRENET system status is done with an HTTP GET to:
\end_layout
................................................................................
\begin_layout Subsubsection
Startup
\end_layout

\begin_layout Standard
The REST operation is controlled by both HTTP pages (html & javascript)
 and a set of Lua scripts.
 When started the Firenet main program reads both of these sets of files
 to produce the desired actions.
 The command line options are:
\end_layout

\begin_layout Description
Command Line Options
\end_layout

................................................................................
\begin_layout LyX-Code

\size footnotesize
./Firenet -p 1 -c Site/Rest/main.lua -http Site/Site_J -show Shows -log log.txt
\end_layout

\begin_layout Standard
Here the Firenet is started using device 1 as the Firenet network connection.





 The Lua file main.lua is run as the initial script, the HTML is stored in
 Site/Site_J and the show files are stored in the directory Shows.
 The initial connection to the server would be:
\end_layout

\begin_layout LyX-Code
http://<server IP>:8081/Site_J/index.html
\end_layout

................................................................................
\end_inset


\end_layout

\begin_layout Standard
The ARMED or DISARMED state will be reflected in the node status.









\end_layout

\begin_layout Paragraph
FIRENET/FIRE
\begin_inset Index idx
status open

................................................................................

\end_layout

\begin_layout Standard
After a ignitor is fired the status will be changed for that channel.
 The FIRED value will go to 1 and the UNFIRED will go to 0 if the firing
 was successful.


\end_layout

\begin_layout Paragraph
FIRENET/SYNC
\begin_inset Index idx
status open

................................................................................

\end_layout

\begin_layout Standard
This message is sent to all FIRENET nodes and synchronizes their millisecond
 clocks.
 This will be needed to support delayed firing commands.
 The optional P node on the end will start the program 








\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
\end_layout

\begin_layout Standard
This is similar to the DELAY command but in this case the delay command
 will be stored.
 All FIRENET nodes have a 32 bit millisecond timer.
 The SYNC command zeros the timers on all nodes.
 Sending a PROGRAM command will store up a FIRE command to occur at a specific
 32 bit millisecond time.
 Thus a number of nodes can fire pieces as precisely the same time.
 When the Sync is set with a P node then the sequence of stored commands
 will be started

\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
...firenet/pgm/<node #>/<Channel #>/<MS time>
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

................................................................................
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
...firenet/delay/<node #>/<Channel #>/<MS time>
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

................................................................................
\end_layout

\begin_layout LyX-Code
{ "STATUS" : "XMIT", "FROM" : "1", "DATA" : "RVMar 6 2011 16-23-19" } 
\end_layout

\begin_layout Subsubsection
PROGRAM
\end_layout

\begin_layout Paragraph
Introduction
\end_layout

\begin_layout Standard
................................................................................
\size footnotesize
}
\end_layout

\begin_layout Section
Lua Extension Classes
\end_layout





\begin_layout Standard
Firenet the firing system is controlled by Lua scripts run by the 
\series bold
FIRENET
\series default
 program.
 There are a number of extension classes written to support these scripts.



 First there are extensions allowing FIRENET communication with the nodes.
 There is a class layered over the libmicrohttpd Web server library to allow
 Lua access to web data for the RESTful operation.
 In addition there are support extension classes added for timers, JSON
 parsing and keyboard control.
 
\end_layout

................................................................................

\begin_layout Standard
The Web server/RESTful class has three major parts.
 The first is used to stop and start the server.
 The start command requires parameters to tell it the TCP/IP port to use
 for the HTTP transfer, data where standard web pages are located and a
 location base for the RESTful request URIs.
 The system can be used as a normal web server serving up pages.
\end_layout

\begin_layout Standard
The second part is a simple open/close set of calls to accept a request
 and return a response.
 Each request is an opaque Lua user object that is generated on receipt
 of a request and is automatically destroyed when the response is returned.
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This code can be used at any time after the http.start() command is given
 and you can then restart the server without shutting down the program.

\end_layout

\begin_layout Paragraph
\begin_inset CommandInset label
LatexCommand label
name "par:http.lock()"

................................................................................
\end_layout

\begin_layout Standard
This method is used to get the URI of the request.
\end_layout

\begin_layout LyX-Code
http.url(h) or h:url()
\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="4" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
\begin_layout Standard
Packets transmitted or received on the Firenet interface are in the form
 of Lua lists.
 There are three elements, the TO field where the destination address is
 specified, the FROM field where the source is specified and the DATA field
 for the packet data.
 All of these fields are present for a received packet, while the transmit
 packet does not need a FROM field.

\end_layout

\begin_layout Subsubsection
Creators/Destructors
\end_layout

\begin_layout Paragraph
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This returns the next message from the network.
 
\end_layout

\begin_layout LyX-Code
msg = handle:read()
\end_layout

\begin_layout Standard
................................................................................
\end_layout

\begin_layout Section
FIRENET Node Design
\end_layout

\begin_layout Standard
This is a networked Fireworks controller system that uses a RS-485 two wire
 network.
 Each firing box or node in the network has 6 firing circuits and up to
 30 of these boxes can be networked together.
 Each box has fixed network address.
 The node address is programmed into the EEPROM of the processor and each
 node box has the address marked on the outside in 
\series bold
large
................................................................................
The physical layer of the network uses the RS-485 standard interface with
 a two wire circuit.
 RS-485 uses a balanced circuit where the signal is one wire and the inverse
 is on the other wire.
 This gives greater noise immunity and a range of about 300 meters for the
 wiring.
 Since only two wires are used we both transmit and receive on the same
 pair.
 This means that a sender must enable the transmitter outputs then send
 the data, and when done disable the transmitter outputs.
 This is very similar (but much slower) that the original ethernet where
 all the signals were on a single coaxial cable.
 
\end_layout

\begin_layout Standard
\begin_inset Float figure
................................................................................
\end_layout

\begin_layout Subsubsection
Packet Format
\end_layout

\begin_layout Standard
This layer handles the carrier sense multiple access and addressing of the
 data packets exchanged.
 The data packet on the network looks like this:
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement H
................................................................................

\end_inset


\end_layout

\begin_layout Standard
The data is sent as ASCII strings and multiple commands can be sent in the
 same data packet by using , separators between commands.
 The entire packet is a printable ASCII string.
\end_layout

\begin_layout Subsubsection
Addressing
\begin_inset CommandInset label
LatexCommand label
name "sub:Addressing"
................................................................................

\end_layout

\begin_layout Standard
This command is issued to enable/disable the firing circuits.
 If node is not armed then all firing commands are ignored.
 The node light will blink when box is armed.

\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

\series bold
AD
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This is similar to the DELAY FIRE but stores the command into a 6 element
 queue.
 All nodes keep a 32 bit millisecond counter.
 The ZP command (see 
\begin_inset CommandInset ref
LatexCommand vref
reference "par:SYNC"

\end_inset

) will sync the time for all the nodes, also it will start the node cycling
 through the queue firing the events in time order.
 The available firing channels are numbered from 0-5.
 The command takes a single byte firing circuit value and 32 bit  time value.
\end_layout

\begin_layout Description
P316543 Store firing command for circuit 3 at 16,543 milliseconds.
\end_layout
................................................................................

\begin_layout Standard
This command is ignored if sent to the broadcast address.
 There is no response immediately
\end_layout

\begin_layout Standard
When the node fires it returns RP<ch #> allowing tracking of the auto firing.

 
\end_layout

\begin_layout Paragraph
STATUS
\begin_inset Index idx
status open
................................................................................

\begin_layout Standard
Is used to set or read the address of a node.
 If the command is sent with a parameter the node's address will be changed.
 If no value is sent, the node's address is not changed.
 In either case the response will contain the current node address.
 A new address will not be accepted if sent to the broadcast address.
 It will also not be accepted is sent to the control node address (32).
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

\series bold
W04
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This command is used to set the firing time, by default it is 100 ms.
 This is the firing pulse time for any channel.
 This can be changed with this command and will be set in the device till
 changed again.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

................................................................................
\begin_layout Standard

\series bold
RF
\series default
 The response will be the firing times of all 6 channels as decimal numbers
 separated by a space.

\end_layout

\begin_layout Section
Firenet Hardware
\end_layout

\begin_layout Subsection
Introduction
\end_layout

\begin_layout Standard
The Firenet system has two main parts, the controller a standard computer
 running the Firenet program and a number of Firenet nodes which actually
 fire the pieces.
 The Firenet node is a small computer system with 6 firing circuits and
 a network connection.
 The system will look like this.
\end_layout

................................................................................

\end_inset


\end_layout

\begin_layout Standard
The Firenet Interface is a USB <-> RS485 interface that allows the Notebook
 onto the Firenet network.
 
\end_layout

\begin_layout Standard
This shows the nodes connected in a daisy-chained network with the laptop.
 Each node is connected to up to 6 firework pieces and can fire them.
 They are also connected to a large 12V battery that supplies the firing
................................................................................

\begin_layout Standard
The power supply uses two regulators.
 One supplies 5V for the logic and processor circuits and the second is
 a 1 Amp constant current supply (IC5) to supply the firing current.
 In front of the regulators is a full wave bridge, a fuse and a 15 V Zener
 diode.
 These are a protection circuit, to make the wiring of the system simple
 and inexpensive we are using standard 120 outlet strips and 120 V plugs
 to distribute the 12 V battery power.
 These connectors are very inexpensive and readily available.
 Also we can use standard 16 Gauge lamp cord for the power leads to the
 nodes.
 But with standard plugs on the ends of these wires there are two problems:
\end_layout
................................................................................
 between the control computer and nodes (like programming a show).
 
\end_layout

\begin_layout Standard
The solution was to put control of the TRANSMIT ON/OFF in the network interface.
 The board used in the interface is a modified node board so instead of
 just the interface chip the Atmel processor was added also.
 With software that detects the start and end of transmitted packets it
 can exactly control the TRANSMIT line like this:
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
................................................................................
 On the other hand testing too often at say 10 ms intervals would not let
 the ignitor heat up as we would be turning off the firing FET at very frequent
 intervals.
 So testing was done to try to determine some reasonable values, testing
 at 100 ms intervals seems to be a good balance between ending early and
 not heating the ignitor enough.
\end_layout


















































\begin_layout Subsubsection
Processor
\end_layout

\begin_layout Standard
The processor circuit is largely copied from the Arduino board.
................................................................................

\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
	filename Images/node_outside.gif
	display false
	scale 25

\end_inset


\end_layout

\begin_layout Plain Layout
................................................................................

\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
	filename Images/node_inside.gif
	display false
	scale 25

\end_inset


\end_layout

\begin_layout Plain Layout







|







 







|







 







|







 







|







 







|








|








|








|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>
>







 







|
|







|
<







 







|







 







|
|







 







|
>
>
>
>
>
|
|







 







>
>
>
>
>
>
>
>
>







 







>
>







 







|
>
>
>
>
>
>
>
>







 







|



|
>







 







|







 







|







 







|







 








>
>
>
>

<
<
<
<
|
|
>
>
>
|







 







|







 







|
>







 







|







 







|
>







 







|







 







|
|







 







|
|
|







 







|







 







|
<
<







 







>







 







|









|







 







|
>







 







|







 







|







 







>











|







 







|
|







 







|







 







|
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







|







203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
...
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
....
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
....
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
....
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
....
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473

2474
2475
2476
2477
2478
2479
2480
....
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
....
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
....
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
....
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
....
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
....
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
....
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
....
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
....
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
....
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
....
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914




5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
....
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
....
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
....
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
....
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
....
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
.....
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
.....
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
.....
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
.....
10894
10895
10896
10897
10898
10899
10900
10901


10902
10903
10904
10905
10906
10907
10908
.....
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
.....
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
.....
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
.....
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
.....
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
.....
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
.....
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
.....
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
.....
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
.....
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
.....
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
.....
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698

\begin_layout Plain Layout


\backslash
renewcommand{
\backslash
revisionNumber}{3.2}
\end_layout

\end_inset


\end_layout

................................................................................
\end_layout

\begin_layout Author
Jim Schimpf
\end_layout

\begin_layout Date
17 February 2013
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout
................................................................................

\backslash
copyright
\end_layout

\end_inset

2009-2013 Pandora Products.
 All rights reserved.
 Pandora product and company names, as well as their respective logos are
 trademarks or registered trademarks of Pandora Products.
 All other product names mentioned herein are trademarks or registered trademark
s of their respective owners.
 
\end_layout
................................................................................
\shape default
.
\end_layout

\begin_layout Standard
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="34" columns="4">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0.5in">
<column alignment="center" valignment="top" width="0.5in">
<column alignment="block" valignment="top" width="3in">
<column alignment="center" valignment="top" width="1in">
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
................................................................................
31-Dec-2011
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3.1
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
js
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Minor editing
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
6-Apr-2012
\end_layout

\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
3.2 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
js 
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
Text corrections
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
17-Feb-2013
\end_layout

\end_inset
</cell>
</row>
</lyxtabular>

\end_inset

................................................................................
\end_layout

\begin_layout Subsection
Introduction
\end_layout

\begin_layout Standard
The FIRENET system is shown in Figure 
\begin_inset CommandInset ref
LatexCommand ref
reference "fig:FIRENET-System"

\end_inset

.
................................................................................
LatexCommand cite
key "libmicrohttpd"

\end_inset

.
 This latter acts as a Web Server and transports the REST protocol commands.
 Above that we have Lua scripts on the server that interpert the REST commands
 and create messages to send on the RS-485 network.
 Finally an HTML and Javascript application that runs on the browser in
 the Interface Computer, this is used supply an OS agnostic user interface
 to the system.
\end_layout

\begin_layout Subsection
User Interface
................................................................................

\begin_layout Standard
The web server running on the Control Computer actually has two functions,
 it can just serve up web pages and second under control of Lua scripting
 it can interact in a RESTful manner.
 Serving up web pages allows the system when contacted by the interface
 computer to serve up Login pages or the Javascript application.
 Once the application is running in the interface computer browser it then
 interacts with the Control Computer in a RESTful manner.
\end_layout

\begin_layout Subsubsection
REST use
\end_layout

\begin_layout Standard
In Firenet we restrict ourselves to just two commands GET and POST.

 The HTTP GET command is used to query the system for information and the
 POST command is used to cause the system to do some action.
 There is a wide latitude in how RESTful commands are done, you can either
 put command parameters (in a POST) in a JSON
\begin_inset CommandInset citation
LatexCommand cite
key "JSON"
................................................................................

) we then have commands to do the administrative or FIRENET functions.
 Doing GETs will return data from a node and doing a POST will cause some
 action.
\end_layout

\begin_layout Standard
For the following examples we will assume the web server (Control Computer)
 is at http://192.168.1.100:8080 and that the base of the RESTful tree is at
 REST.
\end_layout

\begin_layout Standard
So a full FIRENET system status is done with an HTTP GET to:
\end_layout
................................................................................
\begin_layout Subsubsection
Startup
\end_layout

\begin_layout Standard
The REST operation is controlled by both HTTP pages (html & javascript)
 and a set of Lua scripts.
 When started the Firenet Control Computer main program reads both of these
 sets of files to produce the desired actions.
 The command line options are:
\end_layout

\begin_layout Description
Command Line Options
\end_layout

................................................................................
\begin_layout LyX-Code

\size footnotesize
./Firenet -p 1 -c Site/Rest/main.lua -http Site/Site_J -show Shows -log log.txt
\end_layout

\begin_layout Standard
Here the Firenet is started using device 1 (a USB serial port) as the Firenet
 network connection.
 The Lua file 
\series bold
main.lua
\series default
 is run as the initial script, the HTML is stored in Site/Site_J and the
 show files are stored in the directory Shows.
 The initial connection to the server would be:
\end_layout

\begin_layout LyX-Code
http://<server IP>:8081/Site_J/index.html
\end_layout

................................................................................
\end_inset


\end_layout

\begin_layout Standard
The ARMED or DISARMED state will be reflected in the node status.
 NOTE: You can send an ARM command to address Node 0 which is the broadcast
 address (see 
\begin_inset CommandInset ref
LatexCommand vref
reference "par:ARM"

\end_inset

) and arm all the nodes simultaneously.
\end_layout

\begin_layout Paragraph
FIRENET/FIRE
\begin_inset Index idx
status open

................................................................................

\end_layout

\begin_layout Standard
After a ignitor is fired the status will be changed for that channel.
 The FIRED value will go to 1 and the UNFIRED will go to 0 if the firing
 was successful.
 This command cannot be sent to the broadcast address, it must be to an
 individual node.
\end_layout

\begin_layout Paragraph
FIRENET/SYNC
\begin_inset Index idx
status open

................................................................................

\end_layout

\begin_layout Standard
This message is sent to all FIRENET nodes and synchronizes their millisecond
 clocks.
 This will be needed to support delayed firing commands.
 The optional P node on the end will start the program the stored program
 (see 
\begin_inset CommandInset ref
LatexCommand vref
reference "par:PGM"

\end_inset

)
\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
\end_layout

\begin_layout Standard
This is similar to the DELAY command but in this case the delay command
 will be stored.
 All FIRENET nodes have a 32 bit millisecond timer.
 The SYNC command zeros the timers on all nodes.
 Sending a PROGRAM command will store a FIRE command to occur at a specific
 32 bit millisecond time.
 Thus a number of nodes can fire pieces as precisely the same time.
 When the Sync is set with a P node then the sequence of stored commands
 will be started.
 
\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="2" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
http://<server>/<rest>/firenet/pgm/<node #>/<Channel #>/<MS time>
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

................................................................................
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

\begin_layout Plain Layout
http://<server>/<rest>/firenet/delay/<node #>/<Channel #>/<MS time>
\end_layout

\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text

................................................................................
\end_layout

\begin_layout LyX-Code
{ "STATUS" : "XMIT", "FROM" : "1", "DATA" : "RVMar 6 2011 16-23-19" } 
\end_layout

\begin_layout Subsubsection
PROGRAM Automated Show Commands
\end_layout

\begin_layout Paragraph
Introduction
\end_layout

\begin_layout Standard
................................................................................
\size footnotesize
}
\end_layout

\begin_layout Section
Lua Extension Classes
\end_layout

\begin_layout Subsection
Introduction
\end_layout

\begin_layout Standard




The Control Computer program is actually a modified Lua interperter.
 Run without any parameters and it give a prompt and allows you to type
 in Lua language commands.
 The firing system starts the program with a Lua script written to use the
 extensions added to this version of Lua.
 There are extensions allowing FIRENET communication with the nodes.
 There is a class layered over the libmicrohttpd Web server library to allow
 Lua access to web data for the RESTful operation.
 In addition there are support extension classes added for timers, JSON
 parsing and keyboard control.
 
\end_layout

................................................................................

\begin_layout Standard
The Web server/RESTful class has three major parts.
 The first is used to stop and start the server.
 The start command requires parameters to tell it the TCP/IP port to use
 for the HTTP transfer, data where standard web pages are located and a
 location base for the RESTful request URIs.
 This extension can be used as a normal web server serving up pages.
\end_layout

\begin_layout Standard
The second part is a simple open/close set of calls to accept a request
 and return a response.
 Each request is an opaque Lua user object that is generated on receipt
 of a request and is automatically destroyed when the response is returned.
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This code can be used at any time after the http.start() command is given
 and you can then restart the server (say with new parameters) without shutting
 down the program.
\end_layout

\begin_layout Paragraph
\begin_inset CommandInset label
LatexCommand label
name "par:http.lock()"

................................................................................
\end_layout

\begin_layout Standard
This method is used to get the URI of the request.
\end_layout

\begin_layout LyX-Code
url,htty_type = http.url(h) or h:url()
\end_layout

\begin_layout Standard
\begin_inset Tabular
<lyxtabular version="3" rows="4" columns="3">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0">
................................................................................
\begin_layout Standard
Packets transmitted or received on the Firenet interface are in the form
 of Lua lists.
 There are three elements, the TO field where the destination address is
 specified, the FROM field where the source is specified and the DATA field
 for the packet data.
 All of these fields are present for a received packet, while the transmit
 packet does not need a FROM field, it automatically uses the master node
 address.
\end_layout

\begin_layout Subsubsection
Creators/Destructors
\end_layout

\begin_layout Paragraph
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This returns the next message from the network.
 It is a non-blocking call.
\end_layout

\begin_layout LyX-Code
msg = handle:read()
\end_layout

\begin_layout Standard
................................................................................
\end_layout

\begin_layout Section
FIRENET Node Design
\end_layout

\begin_layout Standard
The Firenet system uses a RS-485 two wire network to connect the control
 computer to the nodes.
 Each firing box or node in the network has 6 firing circuits and up to
 30 of these boxes can be networked together.
 Each box has fixed network address.
 The node address is programmed into the EEPROM of the processor and each
 node box has the address marked on the outside in 
\series bold
large
................................................................................
The physical layer of the network uses the RS-485 standard interface with
 a two wire circuit.
 RS-485 uses a balanced circuit where the signal is one wire and the inverse
 is on the other wire.
 This gives greater noise immunity and a range of about 300 meters for the
 wiring.
 Since only two wires are used we both transmit and receive on the same
 pair (i.e.
 half-duplex) This means that a sender must enable the transmitter outputs,
 send the data, and when done disable the transmitter outputs.
 This is very similar (but much slower) that the original ethernet where
 all the signals were on a single coaxial cable.
 
\end_layout

\begin_layout Standard
\begin_inset Float figure
................................................................................
\end_layout

\begin_layout Subsubsection
Packet Format
\end_layout

\begin_layout Standard
This layer handles the transmit/receive switching and addressing of the
 data packets exchanged.
 The data packet on the network looks like this:
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement H
................................................................................

\end_inset


\end_layout

\begin_layout Standard
The data is sent as ASCII strings.


\end_layout

\begin_layout Subsubsection
Addressing
\begin_inset CommandInset label
LatexCommand label
name "sub:Addressing"
................................................................................

\end_layout

\begin_layout Standard
This command is issued to enable/disable the firing circuits.
 If node is not armed then all firing commands are ignored.
 The node light will blink when box is armed.
 It can be sent to the broadcast address to arm all nodes at once.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

\series bold
AD
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This is similar to the DELAY FIRE but stores the command into a 6 element
 memory.
 All nodes keep a 32 bit millisecond counter.
 The ZP command (see 
\begin_inset CommandInset ref
LatexCommand vref
reference "par:SYNC"

\end_inset

) will sync the time for all the nodes, also it will start the node cycling
 through the memory firing the events in time order.
 The available firing channels are numbered from 0-5.
 The command takes a single byte firing circuit value and 32 bit  time value.
\end_layout

\begin_layout Description
P316543 Store firing command for circuit 3 at 16,543 milliseconds.
\end_layout
................................................................................

\begin_layout Standard
This command is ignored if sent to the broadcast address.
 There is no response immediately
\end_layout

\begin_layout Standard
When the node fires a memory location it returns RP<ch #> allowing tracking
 of the auto firing.
 
\end_layout

\begin_layout Paragraph
STATUS
\begin_inset Index idx
status open
................................................................................

\begin_layout Standard
Is used to set or read the address of a node.
 If the command is sent with a parameter the node's address will be changed.
 If no value is sent, the node's address is not changed.
 In either case the response will contain the current node address.
 A new address will not be accepted if sent to the broadcast address.
 It will also not be accepted is sent to the control node address.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

\series bold
W04
................................................................................
\end_inset


\end_layout

\begin_layout Standard
This command is used to set the firing time, by default it is 100 ms.
 This is the firing pulse time for all channels.
 This can be changed with this command and will be set in the device till
 changed again.
\end_layout

\begin_layout Labeling
\labelwidthstring 00.00.0000

................................................................................
\begin_layout Standard

\series bold
RF
\series default
 The response will be the firing times of all 6 channels as decimal numbers
 separated by a space.
 This is the time it actually took to fire a particular ignitor on a channel.
\end_layout

\begin_layout Section
Firenet Hardware
\end_layout

\begin_layout Subsection
Introduction
\end_layout

\begin_layout Standard
The Firenet system has two main parts, the controller, a standard computer
 running the Firenet program and a number of Firenet nodes which actually
 fire the pieces.
 The Firenet node is a small computer system with 6 firing circuits and
 a network connection.
 The system will look like this.
\end_layout

................................................................................

\end_inset


\end_layout

\begin_layout Standard
The Firenet Interface is a USB <-> RS485 interface that allows the Control
 Computer onto the Firenet network.
 
\end_layout

\begin_layout Standard
This shows the nodes connected in a daisy-chained network with the laptop.
 Each node is connected to up to 6 firework pieces and can fire them.
 They are also connected to a large 12V battery that supplies the firing
................................................................................

\begin_layout Standard
The power supply uses two regulators.
 One supplies 5V for the logic and processor circuits and the second is
 a 1 Amp constant current supply (IC5) to supply the firing current.
 In front of the regulators is a full wave bridge, a fuse and a 15 V Zener
 diode.
 These are a protection circuit/ To make the wiring of the system simple
 and inexpensive we are using standard 120 outlet strips and 120 V plugs
 to distribute the 12 V battery power.
 These connectors are very inexpensive and readily available.
 Also we can use standard 16 Gauge lamp cord for the power leads to the
 nodes.
 But with standard plugs on the ends of these wires there are two problems:
\end_layout
................................................................................
 between the control computer and nodes (like programming a show).
 
\end_layout

\begin_layout Standard
The solution was to put control of the TRANSMIT ON/OFF in the network interface.
 The board used in the interface is a modified node board so instead of
 just the interface chip the Atmel/Arduino processor was added also.
 It is loaded with special HeadEnd software that detects the start and end
 of transmitted packets it can exactly control the TRANSMIT line like this:
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement H
wide false
sideways false
................................................................................
 On the other hand testing too often at say 10 ms intervals would not let
 the ignitor heat up as we would be turning off the firing FET at very frequent
 intervals.
 So testing was done to try to determine some reasonable values, testing
 at 100 ms intervals seems to be a good balance between ending early and
 not heating the ignitor enough.
\end_layout

\begin_layout Standard
\begin_inset Float figure
placement h
wide false
sideways false
status open

\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
	filename Images/TEK00010.PNG
	scale 50

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption

\begin_layout Plain Layout
Firing Action
\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
The above figure shows the firing action on a test resistor (that never
 opens) and shows the firing pulse (purple) and the resulting current in
 the ignitor circuit.
 You can also see the tests where the current is switched off and a continuity
 check is made.
 The checks are made at 100 ms intervals during the 3,000 ms firing time.
\end_layout

\begin_layout Subsubsection
Processor
\end_layout

\begin_layout Standard
The processor circuit is largely copied from the Arduino board.
................................................................................

\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
	filename Images/node_outside.gif
	display false
	scale 15

\end_inset


\end_layout

\begin_layout Plain Layout
................................................................................

\begin_layout Plain Layout
\noindent
\align center
\begin_inset Graphics
	filename Images/node_inside.gif
	display false
	scale 15

\end_inset


\end_layout

\begin_layout Plain Layout

Changes to Docs/firenet.pdf.

cannot compute difference between binary files