Skip to content

Commit

Permalink
Merge pull request #9 from adamgarbo/release-candidate
Browse files Browse the repository at this point in the history
Minor update
  • Loading branch information
adamgarbo authored Jun 27, 2022
2 parents 329ee86 + e794f01 commit 4c66136
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 92 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ The Cryologger GVT is constructed using off-the-shelf components, and is intende
#### 2.1.2 Carrier board
A carrier board was designed to simplify assembly and deployment of the Cryologger GVT. It provides 5 mm, 2-pin screw terminals for wiring the battery connection, and an optional resistor divider to measure battery voltage.

<p align="center"><img width="720" src="https://user-images.githubusercontent.com/22924092/114622089-874fda80-9c7b-11eb-9545-e24993ba051d.png"></p>
<p align="center"><img width="720" alt="image" src="https://user-images.githubusercontent.com/22924092/162819459-2b7ba31f-023a-456d-93b4-c77dd59353f6.png">
</p>
<p align="center"><b>Figure 5.</b> Open-source carrier board design.</p>


Expand Down
23 changes: 14 additions & 9 deletions Software/INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cryologger - Glacier Velocity Measurement System Configuration
# Cryologger - Glacier Velocity Tracker Configuration

## Step 1: Download Arduino IDE
https://www.arduino.cc/en/software
Expand All @@ -22,14 +22,19 @@ The glacier velocity measurement system requires two external libraries. These c
* Search for and install the following libraries:

### 1) SparkFun u-blox Arduino GNSS Library
- Version: 2.0.9
- Version: 2.2.7
- GitHub: https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library
<img src="https://user-images.githubusercontent.com/22924092/125138969-a4ab0e00-e0dd-11eb-9df3-e183d7cd2e73.png" width="640">
<img src="https://user-images.githubusercontent.com/22924092/166262645-62a74d75-e5e4-46d5-9339-b7fdb450908d.png" width="640">

### 2) SdFat
- Version: 2.0.7
- Version: 2.1.2
- Github URL: https://github.com/greiman/SdFat
<img src="https://user-images.githubusercontent.com/22924092/125138913-83e2b880-e0dd-11eb-9d29-7a32b79902ea.png" width="640">
<img src="https://user-images.githubusercontent.com/22924092/166266664-f8baef8f-f3eb-4878-bb9f-8899a40303b9.png" width="640">

### 3) SparkFun Qwiic OLED Arduino Library
- Version: 1.0.5
- Github URL: https://github.com/sparkfun/SparkFun_Qwiic_OLED_Arduino_Library
<img src="https://user-images.githubusercontent.com/22924092/166266756-e3f9c71a-680d-405d-96a7-9ae7c2d7c7e5.png" width="640">

## Step 5: Select Harware & Configure Port Settings
* Navigate to Tools > Board > SparkFun Apollo 3
Expand All @@ -45,13 +50,13 @@ The glacier velocity measurement system requires two external libraries. These c

## Step 6: Download Glacier Velocity Measurement System Program
Code for the Cryologger GVMS is made available on the following GitHubrepository:
* https://github.com/adamgarbo/Cryologger_Glacier_Velocity_Measurement_System
* Click on "Releases" and download the v2.0.3 .zip file:
* https://github.com/adamgarbo/Cryologger_Glacier_Velocity_Tracker
* Click on "Releases" and download the v2.0.x .zip file:
![image](https://user-images.githubusercontent.com/22924092/125166162-5858e000-e168-11eb-8b9d-ef07eb5580bc.png)

## Step 7: Test Program Compiliation
* Navigate to the /Software/cryologger_gvms folder of the downloaded repository
* Double click on the `cryologger_gvms.ino` file
* Navigate to the /Software/cryologger_gvt folder of the downloaded repository
* Double click on the `cryologger_gvt.ino` file
* Click on the checkmark in the upper left corner of the Arduino IDE program window
* Watch debugging window for compilation errors
<img src="https://user-images.githubusercontent.com/22924092/125166214-8dfdc900-e168-11eb-8a87-1f88e15ff32b.png" width="640">
Expand Down
31 changes: 18 additions & 13 deletions Software/cryologger_gvt/01_rtc.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ void setInitialAlarm()
// 7: Alarm match hundredths (every second)

// Manually set the RTC date and time
//rtc.setTime(23, 58, 50, 0, 29, 3, 22); // hour, minutes, seconds, hundredths, day, month, year
//rtc.setTime(14, 58, 50, 0, 24, 6, 22); // hour, minutes, seconds, hundredths, day, month, year

// Set initial alarm
rtc.setAlarm(loggingStartTime, 0, 0, 0, 0, 0);

// Set the alarm mode
rtc.setAlarmMode(initialAlarmMode);
//rtc.setAlarmMode(initialAlarmMode);
rtc.setAlarmMode(4); // Alarm match hundredths, seconds, minutes

// Attach alarm interrupt
rtc.attachInterrupt();
Expand Down Expand Up @@ -60,37 +61,39 @@ void setSleepAlarm()
am_hal_rtc_int_clear(AM_HAL_RTC_INT_ALM);

// Check for logging mode
if (loggingMode == 1)
if (loggingMode == 1) // Daily mode
{
DEBUG_PRINTLN(F("Info: Setting daily RTC alarm"));

// Set daily alarm
rtc.setAlarm(loggingStartTime, 0, 0, 0, 0, 0);

// Set RTC alarm mode
rtc.setAlarmMode(sleepAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
//rtc.setAlarmMode(sleepAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
rtc.setAlarmMode(4); // Alarm match on hundredths, seconds, minutes, hours

// Clear alarm flag
alarmFlag = false;
}
else if (loggingMode == 2)
else if (loggingMode == 2) // Rolling mode
{
DEBUG_PRINTLN(F("Info: Setting rolling RTC alarm"));
// Set rolling RTC alarm
rtc.setAlarm((rtc.hour + sleepAlarmHours) % 24, (rtc.minute + sleepAlarmMinutes) % 60, 0, 0, rtc.dayOfMonth, rtc.month);

// Set RTC alarm mode
rtc.setAlarmMode(sleepAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
//rtc.setAlarmMode(sleepAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
rtc.setAlarmMode(5); // Alarm match on hundredths, seconds, minutes

// Clear alarm flag
alarmFlag = false;
}
else if (loggingMode == 3)
else if (loggingMode == 3) // Continuous mode
{
DEBUG_PRINTLN(F("Info: Continuous logging enabled"));
return; // Skip setting alarm
}
else
else
{
alarmFlag = true; // Default if no logging mode set
return; // Skip setting alarm
Expand All @@ -108,23 +111,25 @@ void setLoggingAlarm()
am_hal_rtc_int_clear(AM_HAL_RTC_INT_ALM); // Apollo3 Core v1.x

// Check for logging mode
if (loggingMode == 1)
if (loggingMode == 1) // Daily mode
{
// Set daily RTC alarm
rtc.setAlarm(loggingStopTime, 0, 0, 0, 0, 0);

// Set RTC alarm mode
rtc.setAlarmMode(loggingAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
//rtc.setAlarmMode(loggingAlarmMode); // Alarm match on hundredths, seconds, minutes, hours
rtc.setAlarmMode(4); // Alarm match on hundredths, seconds, minutes, hours
}
else if (loggingMode == 2)
else if (loggingMode == 2) // Rolling mode
{
// Set rolling RTC alarm
rtc.setAlarm((rtc.hour + loggingAlarmHours) % 24, (rtc.minute + loggingAlarmMinutes) % 60, 0, 0, rtc.dayOfMonth, rtc.month);

// Set RTC alarm mode
rtc.setAlarmMode(loggingAlarmMode);
//rtc.setAlarmMode(loggingAlarmMode);
rtc.setAlarmMode(5); // Alarm match on hundredths, seconds, minutes
}
else if (loggingMode == 3)
else if (loggingMode == 3) // Continuous mode
{
// Set continuous RTC alarm
rtc.setAlarm(0, 0, 0, 0, 0, 0); // hours, minutes, seconds, microseconds, day, month
Expand Down
4 changes: 2 additions & 2 deletions Software/cryologger_gvt/02_wdt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ void configureWdt()
WDT_1_16HZ = 1/16th Hz LFRC clock
*/
// Set the WDT interrupt and reset periods
wdt.configure(WDT_16HZ, 128, 240); // 16 Hz clock, 10-second interrupt period, 15-second reset period
//wdt.configure(WDT_1HZ, 64, 128); // 1 Hz clock, 64-second interrupt period, 128-second reset period
//wdt.configure(WDT_16HZ, 128, 240); // 16 Hz clock, 10-second interrupt period, 15-second reset period
wdt.configure(WDT_1HZ, 64, 128); // 1 Hz clock, 64-second interrupt period, 128-second reset period

// Start the WDT
wdt.start();
Expand Down
8 changes: 7 additions & 1 deletion Software/cryologger_gvt/03_power.ino
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ void disablePullups()
void goToSleep()
{
// Skip deep sleep if logging 24 hours/day
if (loggingMode == 3)
if (loggingMode == 3 && !sleepFlag)
{
return;
}
else
{
alarmFlag = false; // Clear flag
//DEBUG_PRINTLN("Info: Entering deep sleep.");
//DEBUG_PRINT("Info: Sleeping until "); printAlarm();
}

// Display OLED message(s)
displayDeepSleep();
Expand Down
19 changes: 10 additions & 9 deletions Software/cryologger_gvt/05_gnss.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ void configureGnss()
// Configure communication interfaces and satellite signals only if program is running for the first time
if (gnssConfigFlag)
{

/*
// Configure communciation interfaces
bool setValueSuccess = true;
setValueSuccess &= gnss.newCfgValset8(UBLOX_CFG_I2C_ENABLED, 1); // Enable I2C
setValueSuccess &= gnss.addCfgValset8(UBLOX_CFG_SPI_ENABLED, 0); // Disable SPI
setValueSuccess &= gnss.addCfgValset8(UBLOX_CFG_UART1_ENABLED, 0); // Disable UART1
setValueSuccess &= gnss.addCfgValset8(UBLOX_CFG_UART2_ENABLED, 0); // Disable UART2
setValueSuccess &= gnss.sendCfgValset8(UBLOX_CFG_USB_ENABLED, 0); // Disable USB
setValueSuccess &= gnss.sendCfgValset8(UBLOX_CFG_USB_ENABLED, 1); // Disable USB
if (!setValueSuccess)
{
DEBUG_PRINTLN("Warning: Communication interfaces not configured!");
}

*/
// Configure satellite signals
setValueSuccess = true;
bool setValueSuccess = true;
setValueSuccess &= gnss.newCfgValset8(UBLOX_CFG_SIGNAL_GPS_ENA, 1); // Enable GPS
setValueSuccess &= gnss.addCfgValset8(UBLOX_CFG_SIGNAL_GLO_ENA, 1); // Enable GLONASS
setValueSuccess &= gnss.addCfgValset8(UBLOX_CFG_SIGNAL_GAL_ENA, 0); // Disable Galileo
Expand Down Expand Up @@ -171,7 +171,8 @@ void syncRtc()
#endif

// Check if date and time are valid and synchronize RTC with GNSS
if (fixType == 3 && dateValidFlag && timeValidFlag)
//if (fixType >= 2) // Debugging
if (fixType >= 2 && dateValidFlag && timeValidFlag)
{
unsigned long rtcEpoch = rtc.getEpoch(); // Get RTC epoch time
unsigned long gnssEpoch = gnss.getUnixEpoch(); // Get GNSS epoch time
Expand Down Expand Up @@ -218,8 +219,8 @@ void syncRtc()
// Create timestamped log file name
void getLogFileName()
{
sprintf(logFileName, "GVT_0_20%02d%02d%02d_%02d%02d%02d.ubx",
rtc.year, rtc.month, rtc.dayOfMonth,
sprintf(logFileName, "GVT_%d_20%02d%02d%02d_%02d%02d%02d.ubx",
CRYOLOGGER_ID, rtc.year, rtc.month, rtc.dayOfMonth,
rtc.hour, rtc.minute, rtc.seconds);
}

Expand Down Expand Up @@ -335,8 +336,8 @@ void logGnss()
DEBUG_PRINTLN("Warning: File buffer >80 % full. Data loss may have occurrred.");
}

// Display logging information to OLED display
if (displayDebug)
// Display logging information to OLED display
if (online.oled && displayDebug)
{
// After a specified number of cycles put OLED to sleep (1.2 uA)
if (displayCounter <= 10)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Create debugging log file
void createDebugFile()
{
// Debug log file name
sprintf(debugFileName, "gvt_%d_debug.csv", CRYOLOGGER_ID);

// Create debug log file
// O_CREAT - Create the file if it does not exist
// O_APPEND - Seek to the end of the file prior to each write
Expand All @@ -16,10 +19,10 @@ void createDebugFile()
}

// Write header to file
debugFile.println("datetime,battery,online_microSd,online_gnss,online_logGnss,online_logDebug,"
"timer_battery,timer_microsd,timer_gnss,timer_syncRtc,timer_logGnss,timer_logDebug,"
"rtcSyncFlag,rtcDrift,bytesWritten,maxBufferBytes,wdtCounterMax,"
"writeFailCounter,syncFailCounter,closeFailCounter,debugCounter");
debugFile.println("datetime,battery,online_microsd,online_gnss,online_log_gnss,online_log_debug,"
"timer_battery,timer_microsd,timer_gnss,timer_sync_rtc,timer_log_gnss,timer_log_debug,"
"rtc_sync_flag,rtc_drift,bytes_written,max_buffer_bytes,wdt_counter_max,"
"write_fail_counter,sync_fail_counter,close_fail_counter,debug_counter");

// Sync the debug file
if (!debugFile.sync())
Expand Down Expand Up @@ -104,13 +107,6 @@ void logDebug()
DEBUG_PRINTLN("Warning: Failed to close debug file.");
closeFailCounter++; // Count number of failed file closes
}

/*
DEBUG_PRINTLN("datetime,battery,online_microSd,online_gnss,online_logGnss,online_logDebug,"
"timer_battery,timer_microsd,timer_gnss,timer_syncRtc,timer_logGnss,timer_logDebug,"
"rtcSyncFlag,rtcDrift,bytesWritten,maxBufferBytes,wdtCounterMax,"
"writeFailCounter,syncFailCounter,closeFailCounter,debugCounter");
*/

// Print debugging information
DEBUG_PRINT(dateTime); DEBUG_PRINT(",");
Expand Down
6 changes: 4 additions & 2 deletions Software/cryologger_gvt/07_display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ void configureOled()
// Reset OLED display after sleep/power cycle
void resetOled()
{
#if OLED
online.oled = true;
enablePullups();
oled.reset();
oled.reset(1);
#endif
}

void displayWelcome()
Expand All @@ -34,7 +36,7 @@ void displayWelcome()
{
enablePullups(); // Enable internal I2C pull-ups
oled.erase();
oled.text(0, 0, "Cryologger GVT");
oled.text(0, 0, "Cryologger GVT #1");
oled.text(0, 10, dateTimeBuffer);
oled.setCursor(0, 20);
oled.print("Voltage:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,26 @@ void printLoggingSettings()
DEBUG_PRINTLN("Logging Configuration");
printLine();

DEBUG_PRINT("Logging mode: "); printTab(3); DEBUG_PRINTLN(loggingMode);
DEBUG_PRINT("Logging start: "); printTab(3); DEBUG_PRINTLN(loggingStartTime);
DEBUG_PRINT("Logging stop: "); printTab(3); DEBUG_PRINTLN(loggingStopTime);
DEBUG_PRINT("Rolling logging alarm: "); printTab(2); DEBUG_PRINT(loggingAlarmHours); DEBUG_PRINT(" hours "); DEBUG_PRINT(loggingAlarmMinutes); DEBUG_PRINTLN(" minutes ");
DEBUG_PRINT("Rolling sleep alarm: "); printTab(2); DEBUG_PRINT(sleepAlarmHours); DEBUG_PRINT(" hours "); DEBUG_PRINT(sleepAlarmMinutes); DEBUG_PRINTLN(" minutes ");
DEBUG_PRINT("Logging alarm mode: "); printTab(2); DEBUG_PRINTLN(loggingAlarmMode);
DEBUG_PRINT("Sleep alarm mode: "); printTab(2); DEBUG_PRINTLN(sleepAlarmMode);
DEBUG_PRINT("Initial alarm mode: "); printTab(2); DEBUG_PRINTLN(initialAlarmMode);
DEBUG_PRINT("Logging mode: "); printTab(3);
if (loggingMode == 1)
{
DEBUG_PRINTLN("Daily");
DEBUG_PRINT("Start: "); printTab(4); DEBUG_PRINTLN(loggingStartTime);
DEBUG_PRINT("Stop: "); printTab(4); DEBUG_PRINTLN(loggingStopTime);
}
if (loggingMode == 2)
{
DEBUG_PRINTLN("Rolling");
DEBUG_PRINT("Logging duration: "); printTab(2); DEBUG_PRINT(loggingAlarmHours); DEBUG_PRINT(" hours "); DEBUG_PRINT(loggingAlarmMinutes); DEBUG_PRINTLN(" minutes ");
DEBUG_PRINT("Sleep duration: "); printTab(2); DEBUG_PRINT(sleepAlarmHours); DEBUG_PRINT(" hours "); DEBUG_PRINT(sleepAlarmMinutes); DEBUG_PRINTLN(" minutes ");
}
if (loggingMode == 3)
{
DEBUG_PRINTLN("Continuous");
}
DEBUG_PRINT("Logging alarm mode: "); printTab(2); DEBUG_PRINTLN(loggingAlarmMode);
DEBUG_PRINT("Sleep alarm mode: "); printTab(2); DEBUG_PRINTLN(sleepAlarmMode);
DEBUG_PRINT("Initial alarm mode: "); printTab(2); DEBUG_PRINTLN(initialAlarmMode);
}

// Print values of u-blox registers
Expand All @@ -41,7 +53,7 @@ void printGnssSettings()
DEBUG_PRINT("UBLOX_CFG_RATE_MEAS: "); printTab(2); DEBUG_PRINTLN(gnss.getVal16(UBLOX_CFG_RATE_MEAS));
DEBUG_PRINT("UBLOX_CFG_RATE_NAV: "); printTab(2); DEBUG_PRINTLN(gnss.getVal16(UBLOX_CFG_RATE_NAV));
DEBUG_PRINT("UBLOX_CFG_UART1_BAUDRATE: "); printTab(1); DEBUG_PRINTLN(gnss.getVal32(UBLOX_CFG_UART1_BAUDRATE));
//DEBUG_PRINT("UBLOX_CFG_UART2_BAUDRATE: "); printTab(1); DEBUG_PRINTLN(gnss.getVal32(UBLOX_CFG_UART2_BAUDRATE));
DEBUG_PRINT("UBLOX_CFG_UART2_BAUDRATE: "); printTab(1); DEBUG_PRINTLN(gnss.getVal32(UBLOX_CFG_UART2_BAUDRATE));
DEBUG_PRINT("UBLOX_CFG_I2COUTPROT_UBX: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_I2COUTPROT_UBX));
DEBUG_PRINT("UBLOX_CFG_I2COUTPROT_NMEA: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_I2COUTPROT_NMEA));
DEBUG_PRINT("UBLOX_CFG_I2COUTPROT_RTCM3X: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_I2COUTPROT_RTCM3X));
Expand All @@ -55,17 +67,17 @@ void printGnssSettings()
DEBUG_PRINT("UBLOX_CFG_SIGNAL_QZSS_ENA: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_SIGNAL_QZSS_ENA));
DEBUG_PRINT("UBLOX_CFG_SIGNAL_SBAS_ENA: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_SIGNAL_SBAS_ENA));
DEBUG_PRINT("UBLOX_CFG_I2C_ENABLED: "); printTab(2); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_I2C_ENABLED));
//DEBUG_PRINT("UBLOX_CFG_SPI_ENABLED: "); printTab(2); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_SPI_ENABLED));
DEBUG_PRINT("UBLOX_CFG_SPI_ENABLED: "); printTab(2); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_SPI_ENABLED));
DEBUG_PRINT("UBLOX_CFG_UART1_ENABLED: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_UART1_ENABLED));
//DEBUG_PRINT("UBLOX_CFG_UART2_ENABLED: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_UART2_ENABLED));
DEBUG_PRINT("UBLOX_CFG_UART2_ENABLED: "); printTab(1); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_UART2_ENABLED));
DEBUG_PRINT("UBLOX_CFG_USB_ENABLED: "); printTab(2); DEBUG_PRINTLN(gnss.getVal8(UBLOX_CFG_USB_ENABLED));

printLine();
}

void printTimers()
{
//printLine();
printLine();
DEBUG_PRINTLN("Function Execution Timers");
printLine();
DEBUG_PRINT("readWdt: "); printTab(1); DEBUG_PRINTLN(timer.wdt);
Expand Down
Loading

0 comments on commit 4c66136

Please sign in to comment.