GPS Computer - Page 1
This is the SECOND computer on the MAIN board situated on RHS and was originally a Metro M0 board but later changed to be a Metro M4 board for more flexibility including a second DAC port.
The software listens to the NMEA text messages from the GPS sub board (Adafruit Ultimate) and extracts certain parts of each different message and compiles what is known as a "super message".
It also takes the 1PPS pulse signal and sends it to the FIRST main computer.
Pre-SETUP of GPS sub board
The GPS sub board must be initially setup using PMTK commands to
- change sampling interval of NMEA messages to 3 seconds rather than default of 1 second
- change baud rate to 57,600 rather than default of 9600 baud
- to output only RMC,GGA,GSA and GLL messages
this program is run as a separate initial program and is run on new boards after installation of backup battery or after battery has become flat. (Program name bz_serial_adafruit_init_GPS.ino)
Program has a variable called firstpass which must be set to TRUE for first run, then to FALSE on subsequent runs to monitor that changes were successful.
If not successful, then remove battery, wait 10 seconds, re-insert battery and run program again with firstpass set to TRUE.
GPS Computer - Page 2
The GPS listening serial port is called SerialNMEA on pins 16,17 at a baud rate of 57,600.
The main software for GPS Computer is bz_GPS_nmeabuf.ino
This software starts with the implementation of an interrupt timer of 1 msec for the SAMD51 hardware architecture.
The NMEA strings are received on Serial4 of the processor, Pins 16,17 at baud rate of 57,600.
A second serial port on pins 14,15 sends the "super message" to the MAIN computer at baud rate of 38,400.
The HP20C barometer is connected to the SCL, SDA pins of the Metro M4.
An interrupt is also attached to pin 2 of Metro M4 and the 1PPS pulse connected both to this pin and also to analog A10 on MAIN computer and digital pin 2 of main computer. The digital pins provide a counter for the number of pulses and the analog input is used as calibration of the semsic channels in post processing of the recorded data.
The main LOOP function is very simple calling two functions recvNMEA and process_NMEA_msg in continuous succession.
recvNMEA waits until an end marker in the character string is detected (\n), adds a null to the nmeabuf array and raises a flag called newData.
process_NMEA_msg checks if newData is true and if so then identifies which NMEA message has been received and extracts a subset of the message. e.g. the GLL message calls a routine makeGLL, the GSA message calls a routine makeGSA etc.
GPS Computer - Page 3
The GPS messages arrive as a burst of 4 messages every 3 seconds and it is important to identify which message is the last in this sequence as after the last message is received, then the serial port will have no more data arrive for some 3 seconds, hence computer is effectively idle.
In the case of the Adafruit Ultimate sub-board the last message is the RMC message and upon receiving and processing this message a routine called last_GPS_msg is called.
last_GPS_msg first reads the barometer values and in similar fashion to the NMEA messages makes a short message with routine makeHP20.
Then all of the sub messages are combined into a "super message" with routine make_super_msg.
The routine then sends the "super message" to the FIRST computer on the SerialMSG port which is on pins 14,15.
A routine called make_DAC0_output is called to setup values for outputting on DAC0.
make_DAC0_output sets up a packet start value of 1020 (being almost a 10 bit maximum value) then a staircase of values for the digits 0 -> 9, ranging from 100 for digit 0 to 820 for digit 9 (steps of 80).
Then the "super message" characters are each setup with a
value equivalent to the ASCII value of each character less a
value of 32. This value is a 2 digit number of 00 to 99.
e.g. ASCII value of A = 65, subtract 32 = 33 etc etc
The green trace in the figure opposite shows the resulting DAC0
values as received by the FIRST computer.
Hence the "super message" has been turned into an analog
signal as a sequence of digital values.
GPS Computer - Page 4
The last part of the make_DAC0_output routine sets a flag called DAC0_dataReady to TRUE and sets the DAC0_indx variable to zero.
The void_setup() has initially setup a 1 millisecond timer and this has been pointed to run the DAC_OUT_Function.
The DAC_OUT_Function checks if the DAC0_dataReady flag is set and if it is TRUE then it writes a single value from the DAC0_outputvalues array out to the DACO which is analog A0 on the Metro M4 board.
It then increments the DAC0_indx variable and checks if it has reached the end of the data array. If the value is at end of the array then the DAC0_dataready flag is set to FALSE.
As the number of values in this array is around about 1,600 in normal case which means it takes 1,600 milliseconds to complete and hence is completed before the next burst of messages starts to arrive at the SerialNMEA port.
The image shown here shows the 1PPS
pulse at start of each row and shows two
series of DAC0 values some 1.6 secs
apart within the 5 seconds of data.
Also note that the delay after the 1PPS pulse
until Serial NMEA messages is around 450
msec. This will vary depending on the
constellation of satellites the receiver
is suing to calculate it's position.
Decoding of the DAC0 values will result
in information related to the previous
1PPS pulse.
This is how the analog data stream will
be time-stamped.
Main Computer - Page 1
This is the FIRST computer on the MAIN board situated on LHS and is a Metro M4 board.
The MAIN computer has more functions than the GPS
Computer.
The software is designed to operate in 3 modes
- STANDBY – can accept instructions via a
Bluetooth connection to an Android tablet
- GPS MONITOR – monitor the status of the GPS
Computer to ensure that 1PPS is OK and the quality of position fix is good
- DATA ACQUIRE – this is the primary function of
the software, a datalogger for 8 seismic channels and 4 auxiliary channels. Data is written out in hourly data files to
SD card.
The MAIN Computer uses a timer setup to provide 1
millisecond interrupts to trigger data sampling and for other functions.
A Real Time Clock sub-board (Adafruit DS3231) is
synchronized to the GPS time on an hourly basis and is used to determine when
to change file names i.e. at the 59th minute of each hour. Hence during the 59th minute of
each hour no datalogging occurs hence energy source should not work at this
time.
The power for the MAIN computer is supplied by a 7.4V
(Nominal) LiIon battery and this is monitored in each different mode of
operation. Once battery reaches a
critical level, datalogging ceases, current file is closed and written to SD
and then a few seconds later a digital IO pin is set low to open a relay that
is normally closed and allows power to system.
e.g. a kill switch.
The battery must not be allowed to get excessively flat as
this decreases the life of the battery.
Main Computer - Page 2
When started the program runs in STANDBY mode and awaits
action via a Bluetooth module plugged into the Box. The attached module also has 3 push buttons
which when held for 2 seconds will switch the software to any of the 3
operating modes.
The Timer_ticks routine checks and counts how many
milliseconds any of the MODE Pins has been held and if this count exceeds 2000
then the operating MODE is changed to the user selected MODE.
If
the software is in STANDBY mode (the default at start up) then it monitors the
Bluetooth serial port. The software
sends simple status messages every 4 seconds in this mode.
It reads the battery
voltage and then sends a message showing this battery voltage and how many 1PPS
pulses have been received.
In the STANDBY mode the user can also give commands to the
Box (under development).
In the GPS MONITOR mode the software reads the “super
message” data being sent from the GPS Computer and sends this message out on
the Bluetooth serial port. The battery
voltage is also read each time a “super message” is received which is every 3
seconds and also the RTC reading is added to the Bluetooth message.
This allows a USER to monitor the Box on a
tablet to compare whether GPS time is very different to RTC time.
In the DATA ACQUIRE mode the program loops continuously
acquiring data on both seismic and auxiliary channels and writing this data at
a rate of 1 millisecond to a file on SD disc.
The filename is changed every hour to enable a reasonable file size for each data file and is considered a good book-keeping practice.
Main Computer - Page 3
The hourly data file name is setup using the RTC values and
has the following format
YYMMDDHH.BBV (standard 8.3 file name convention for SD files)
Where YY = year, MM = month, DD = day of month and HH =
hour.
BB = 2 hex digit code of the BOX identification number and V
is a file version, letters A to Z.
If a file is started several times within an hour due to
operator actions of changing modes then the file version increments through the
letters A -> Z (allows for 26 interruptions each hour).
The program also accesses the Flash Memory present on the
Adafruit Grand Central board to store information about the seismic survey,
such as Client, Survey parameters, Observer, Line Name etc etc.
This information is stored in the very first
2,048 bytes of each hourly data file making each data file self-defining in
terms of purpose and location.
DOUBLE BUFFERING
In order to acquire data continuously DOUBLE BUFFERING must
be used to ensure integrity. Basically one
buffer is filled whilst a second buffer is written out and then the first
buffer is written out whilst second buffer is filled and then swaps around.
The SD card write routines also only use BYTE-type
binary writes from an array. Hence in the continuous_ADC routine after each
channel analog read is done the 16bit ADC value must be split into a LOW and
HIGH byte before storing in the array.
Main Computer - Page 4
The continuous_ADC routine checks if a buffer is full and
then sets some ADC operational flags so that the check_write_SD_status routine
can actually do the write operation to SD and set some ADC operational flags. This is a continuous toggling type software
operation.
The void_loop routine calls the check_write_SD_status routine in DATA ACQUIRE mode and also closes the file each hour by monitoring
the RTC and then setting up an hourly file name and opening the file on SD card
ready for data buffers.
A routine write_initial_buffer takes data such as Area name, Client information, Line
name etc and adds this at the start of the hourly file. A flag ADC_inhibit stops ADC reads during
this setting up of a new file.
NOTE : Battery is checked after each SD write buffer as well
as a serial message prepared and sent out via Bluetooth so that a user can
monitor data acquisition on a tablet if needed.
Main Computer - Page 5
__not used yet__
Main Computer - Page 6
__not used yet__