Supplied application programs

Two application programmes are supplied with the launch kit (or can be downloaded from the SpaceLogger web site). One is a general purpose data logging application called DEMO_APP and the other called WIND_APP logs data from a WindSonic ultrasonic wind speed and direction sensor.

In the launch kit the SpaceLogger is supplied with the DEMO_APP application already loaded into the processor's flash memory.

DEMO_APP

The DEMO_APP program is controlled by a text file DEMO_INI.TXT in the SYSTEM folder on the compact flash card. An example of the contents of this file is as follows:

Log scheme=0
Store rate=1
Log rate=100
ADC chans=15
DIG chans=15
ETX char=3
STX char=2
Baud rate=9600
Protocol=RS232

The order of the lines should not be changed. The parameters can be set as follows

Log scheme: set to 0 if sampling is to be initiated by the real time clock (RTC)
set to 1 if sampling is to be initiated by receipt of a message on the serial input

 

Store rate: If the Log scheme is 1 then this parameter controls how often data is sampled and stored. Set to 1 for every message, 2 for every other message, 3 for every third message etc.

 

Log rate: If Log scheme is 0 then this parameter determines the time between samples. This is in units of 5ms and must be a multiple of 20 or 100ms intervals. So when set to the minimum 20 the sampling rate will be ten times a second, when set to 200 once a second, when set to 2000 every 10 seconds etc.

 

ADC chans: Sets which analogue channels are to be sampled and stored according to the following table

 

ADC chans value A-In0 A-In1 A-In2 A-In3
0        
1 x      
2   x    
3 x x    
4     x  
5 x   x  
6   x x  
7 x x x  
8       x
9 x     x
10   x   x
11 x x   x
12     x x
13 x   x x
14   x x x
15 x x x x

 

DIG chans: Sets which digital channels are to be sampled and stored according to the following table

 

DIG chans value D-I/O 0 D-I/O 1 D-I/O 2 D-I/O 3
0        
1 x      
2   x    
3 x x    
4     x  
5 x   x  
6   x x  
7 x x x  
8       x
9 x     x
10   x   x
11 x x   x
12     x x
13 x   x x
14   x x x
15 x x x x

 

ETX char: Set to the decimal value of the ASCII character that is used for the end of transmission character on the serial input.

 

STX char: Set to the decimal value of the ASCII character that is used for the start of transmission character on the serial input.

 

Baud rate: Sets the baud rate (bits per second) of the serial input. The range is 1200 to 38400baud

 

Protocol: Equals RS232 or RS485 depending on the required serial interface standard

Data is stored in a file  LOGFILE1.CSV in the DATA folder on the compact flash card.  Data is stored as follows:

If the Log scheme=0

D,d0,d1,d2,d3,A,a0,a1,a2,a3,t,s

If the Log scheme=1

t,s,D,d0,d1,d2,d3,A,a0,a1,a2,a3

where

d0, d1, d2 and d3 are 0 or 1 depending on the state of the digital channel
a0, a1, a2 and a3 are the  values of the analogue inputs -5.000 to 5.000
t is the time of day in seconds.
s is a text string received on the serial port.
If a analogue or digital channel is not enabled then the data field for that channel is omitted.

WIND_APP

The WIND_APP program is controlled by a text file INI.TXT in the SYSTEM folder on the compact flash card. It contains two lines as follows:

COMMS=RS232
STORAGE_RATE=1

The order of the lines should not be changed. The parameters can be set as follows

COMMS: Equals RS232 or RS485 depending on the required serial interface standard
STORAGE_RATE: This parameter controls how often data stored. Set to 1 for every message, 2 for every other message, 3 for every third message etc.

The WindSonic sensor should be set to output in the continuous polar default format at 9600 baud with 8 data bits and no parity.

<STX>Q,DDD,SSS.SS,U,AA,<ETX>CC<CR><LF>

Where
Q is the anemometer identifier. Can be set to any character Q to Z
DDD wind direction in degrees relative to sensor axis
SSS.SS wind speed U Units M m/s, N knots, P mph, K km per hour, F ft per min.
AA status 00 ok, 01 axis 1 failed, 02 axis 2 failed, 04 axis 1 & 2 failed, 08 NVM error, 09 ROM error
CC checksum Exclusive OR of all characters between <STX> and <ETX> as a two character hexadecimal value.
<STX> is the ASCII character with a value of 2
<ETX> is the ASCII character with a value of 3
<CR> is the ASCII carriage return character with a value of 13
<LF> is the ASCII line feed character with a value of 10

The logged data is stored in a new file each day in the DATA folder. The file names are made from the date as follows

YYYYMMDD.CSV

Data is stored as follows

t,DDD,SSS.SS,U,AA

where t is the time of day in seconds. If you are opening the file in Excel and wish to use the time format to display this time in hours minutes and seconds then divide t by the number of seconds in a day 86400

 

Loading an application program

1 The application program HEX file (for example WIND_APP.HEX or DEMO_APP.HEX) must be put in the UPDATE folder on the compact flash card. The hex file name must be 8 or less upper case characters with a .HEX extension.

2 Create a text file containing the following line

SOFTWARE=application.HEX

where application is replaced by your application's file name

Save the text file as AUTO.TXT in the UPDATE folder on the compact flash card.

3 With the power off insert the compact flash card into the SpaceLogger.

4 Switch on the SpaceLogger and the led should flash every half a second to indicate the program is loading. In the case of DEMO_APP.HEX this takes about 20 seconds. After the program has loaded it will start running.

5 To check that the program was loaded correctly you should look at the AUTOLOG.TXT file in the UPDATE folder which should contain: 

nnnnnn DD/MM/YYYY hh:mm:ss TIME= 
nnnnnn DD/MM/YYYY hh:mm:ss DATE= 
nnnnnn DD/MM/YYYY hh:mm:ss SOFTWARE=application.HEX

where
nnnnnn is the serial number of the SpaceLogger
DD/MM/YYYY hh:mm:ss is the date and time the log file was written to.

If there was an error loading the program the file name after SOFTWARE= will be replaced  with an error message. The contents of the AUTO.TXT file is deleted to avoid unintentionally repeating the software load next time the SpaceLogger is switched on,

Using the DEMO_APP Application

The DEMO_APP application logs data according to the following default values

Log scheme=0
Store rate=1
Log rate=100
ADC chans=15
DIG chans=15
ETX char=3
STX char=2
Baud rate=9600
Protocol=RS232

or according to the settings in the a configuration file DEMO_INI.TXT in the SYSTEM folder if present on the CompactFlash card when inserted. Data is then logged to a file named LOGFILE1.csv, which may be directly read using Microsoft Excel. This file will be created in the DATA directory, which itself may be created by the user, or if not present the SpaceLogger will create this directory. If there exists a file of this name in the DATA directory the data will be appended to the data in the file. As the CompactFlash card may be removed at any time during logging, it is possible for the logger itself to be caught midway through a read or write from the card, this may result in the latest data being missing from the log file, up to the last whole sector (512 bytes).

NEXT -->

START