User Tools

Site Tools


en:monitoring_and_warning:software

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:monitoring_and_warning:software [2023/01/24 10:16] m-gamperlen:monitoring_and_warning:software [2023/01/24 12:05] (current) m-gamperl
Line 64: Line 64:
 | extra_functions.h       | Some additional functions which keep the code more readable | | extra_functions.h       | Some additional functions which keep the code more readable |
  
-{{tabs-2.png|Detail view of the seven files/tabs shown in figure above.}}+
  
 When the libraries are installed correctly, the code should compile without problems. There are When the libraries are installed correctly, the code should compile without problems. There are
Line 77: Line 77:
 ==== general_config.h ==== ==== general_config.h ====
  
-In this file, the basic settings can be changed by the user during installation. The general\textunderscore config.h file is structured as follows:   +In this file, the basic settings can be changed by the user during installation. The general_config.h file is structured as follows:   
   * Timing setup   * Timing setup
   * Definitions of sleep mode   * Definitions of sleep mode
Line 90: Line 90:
 In this section of the general_config.h file, the sensor states are defined. This is used to turn on/off the different sensors which are connected on the board or can be attached to it. To turn a sensor on, simply write “**= true**” after the corresponding variable. This is the main section which needs to be changed when setting up a sensor either in the field or when preparing it beforehand. Please note that for the current PCB version (V 0.2), no IMU is attached on the board, so this is always false. The list of parameters can be seen in the next figure. In this section of the general_config.h file, the sensor states are defined. This is used to turn on/off the different sensors which are connected on the board or can be attached to it. To turn a sensor on, simply write “**= true**” after the corresponding variable. This is the main section which needs to be changed when setting up a sensor either in the field or when preparing it beforehand. Please note that for the current PCB version (V 0.2), no IMU is attached on the board, so this is always false. The list of parameters can be seen in the next figure.
  
-These settings can be seen as general toggles for the different sensors. If they are not turned on, all subsequent settings (for the ADC e.g. in the “*ADC_Config.h*” file) are disregarded. If, for example, the SMN is attached, but with settings different from the default (explained in the SMN section), the SMN must be turned on here and the specific settings have to be changed in the *SMN\textunderscore Config.h* file.+These settings can be seen as general toggles for the different sensors. If they are not turned on, all subsequent settings (for the ADC e.g. in the “**ADC_Config.h**” file) are disregarded. If, for example, the SMN is attached, but with settings different from the default (explained in the SMN section), the SMN must be turned on here and the specific settings have to be changed in the **SMN\textunderscore Config.h** file.
  
 === Definition of Active Power Ports === === Definition of Active Power Ports ===
Line 104: Line 104:
 {{lora.png|LoRa Connection Settings in general_Config.h file}} {{lora.png|LoRa Connection Settings in general_Config.h file}}
  
-  * The (*# define LORA_BAND*) defines the LoRa Band Connection. This is different for different countries. Please refer to the file for other options. +  * The (**# define LORA_BAND**) defines the LoRa Band Connection. This is different for different countries. Please refer to the file for other options. 
-  * The (*# define LORA_ADR*) defines the Automatic Data transfer Rate, where true allows the LoRa server to control the data rate, while false sets it to a fixed data transfer rate. +  * The (**# define LORA_ADR**) defines the Automatic Data transfer Rate, where true allows the LoRa server to control the data rate, while false sets it to a fixed data transfer rate. 
-  * *# define LORA_DR* also defines the data transfer rate according to the LoRa Band that is choosen. It varies according to different regions. +  **# define LORA_DR** also defines the data transfer rate according to the LoRa Band that is choosen. It varies according to different regions. 
-  * *# define LORA_CH_DEF* defines the Channel Plan. True uses the default channels for the Band specified and false allows to use the channel specified in *# define LORA_CH_ACT*. See LoRaWAN Regional Parameters for Details. +  **# define LORA_CH_DEF** defines the Channel Plan. True uses the default channels for the Band specified and false allows to use the channel specified in **# define LORA_CH_ACT**. See LoRaWAN Regional Parameters for Details. 
-  * *# define LORA_TIMEOUT* defines the LoRa Connection timeout in seconds.+  **# define LORA_TIMEOUT** defines the LoRa Connection timeout in seconds.
   * The appEui and appKey are secret keys specified in the arduino_secrets_config.h file (described in detail in the corresponding section).   * The appEui and appKey are secret keys specified in the arduino_secrets_config.h file (described in detail in the corresponding section).
  
Line 115: Line 115:
 This subsection of the general_config.h file defines the timing parameters for loop intervals during measurement cycles. The parameters can be seen in the next figure. This subsection of the general_config.h file defines the timing parameters for loop intervals during measurement cycles. The parameters can be seen in the next figure.
  
-*loopintv* controls the interval of one cycle, including initialization, measurement, data transmission, powerdown, sleeping and powerup. This means that the sleeptime itself is calculated each cycle by subtracting *measlength*, *sensorstarttime* and the rest of the calculation time from the total *loopintv*. *extrafreq* is not used for now (from V 1.0). The sleeptime is calculated as follows:+**loopintv** controls the interval of one cycle, including initialization, measurement, data transmission, powerdown, sleeping and powerup. This means that the sleeptime itself is calculated each cycle by subtracting **measlength**, **sensorstarttime** and the rest of the calculation time from the total **loopintv**. **extrafreq** is not used for now (from V 1.0). The sleeptime is calculated as follows:
  
 sleeptime = loopintv - (measlength + sensorstarttime)  sleeptime = loopintv - (measlength + sensorstarttime) 
Line 121: Line 121:
 === Sleep Mode === === Sleep Mode ===
  
-This setting helps the sensors to go into sleep when the program is out of the measurement cycle. When *#define SleepMode "deepsleep"* is specified, most hardware is disabled (lowest power consumption). This setting is recommended for deployment of the LoRa nodes. When*#define SleepMode "sleep"* is specified, most of the hardware is disabled, but the COM is still active. *#define SleepMode "nil"* specifies all hardware to stay active.+This setting helps the sensors to go into sleep when the program is out of the measurement cycle. When **#define SleepMode "deepsleep"** is specified, most hardware is disabled (lowest power consumption). This setting is recommended for deployment of the LoRa nodes. When **#define SleepMode "sleep"** is specified, most of the hardware is disabled, but the COM is still active. **#define SleepMode "nil"** specifies all hardware to stay active.
  
 === Data Packet Designator ===  === Data Packet Designator === 
Line 135: Line 135:
 === AD12_config.h === === AD12_config.h ===
  
-The 12-bit Analog to Digital Converter is embedded in the Ardunio MRKWAN 1310 board. The *AD12_config.h* file contains the settings for this sensor. The section under "MEASUREMENT SETTINGS" (refer to following figure) are the parameters that can be modified according to the sensor configuration.+The 12-bit Analog to Digital Converter is embedded in the Ardunio MRKWAN 1310 board. The **AD12_config.h** file contains the settings for this sensor. The section under "MEASUREMENT SETTINGS" (refer to following figure) are the parameters that can be modified according to the sensor configuration.
  
-  * The *# define AD12_AIN0* and *int AD12_AIN1* define which AD12 channels are active, and in which mode they operate. The *AIN0* and *AIN1* are the two channels available. Setting either of the channels to 0 means the channel is off and setting it to 1 means the channel is set to a single ended voltage measurement with 3.3V reference. +  * The **# define AD12_AIN0** and **int AD12_AIN1** define which AD12 channels are active, and in which mode they operate. The **AIN0** and **AIN1** are the two channels available. Setting either of the channels to 0 means the channel is off and setting it to 1 means the channel is set to a single ended voltage measurement with 3.3V reference. 
-  * The *int AD12_MINT* defines the time interval (in ms) at which the AD24 measurement is read. It is advised to keep this setting above 50 ms per active channel. +  * The **int AD12_MINT** defines the time interval (in ms) at which the AD24 measurement is read. It is advised to keep this setting above 50 ms per active channel. 
-  * The *#define AD12_TRANS_AIN0* and *int AD12_TRANS_AIN1* defines whether the ADC data is transmitted via the LoRa network. O stands for no and 1 stands for yes.+  * The **#define AD12_TRANS_AIN0** and **int AD12_TRANS_AIN1** defines whether the ADC data is transmitted via the LoRa network. O stands for no and 1 stands for yes.
  
 The rest of the file contains Global variables and functions that must not be modified/edited. The rest of the file contains Global variables and functions that must not be modified/edited.
Line 147: Line 147:
 === AD24_config.h === === AD24_config.h ===
  
-The 24-bit analog to digital converter is the ADS1220 (Texas Instruments). Hence the ADS1220 library must be added to the file. The *AD24_config.h* is quite similar to the *AD12_config.h*. The 24-bit ADC has 4 channels that can be set up. Each channel can also be set up in 5 different modes. Each mode has a detail explanation in the configuration file. It also has extra functionalities like calibration settings and debug message settings.+The 24-bit analog to digital converter is the ADS1220 (Texas Instruments). Hence the ADS1220 library must be added to the file. The **AD24_config.h** is quite similar to the **AD12_config.h**. The 24-bit ADC has 4 channels that can be set up. Each channel can also be set up in 5 different modes. Each mode has a detail explanation in the configuration file. It also has extra functionalities like calibration settings and debug message settings.
  
-  * The *#define AD24_AIN0, AD24_AIN1, AD24_AIN2, AD24_AIN3* define which AD24 channels are active, and in which mode they operate. Setting any of the channels to 0 means the channel is off. Setting the channels to 1 means the channel is set to a single ended voltage measurement with 3.3V reference. Setting the channels to 2 means the channel has a single ended current measurement. Setting the channels to 3 means Differential Voltage Measurement between this channel and +1 channel (e.g. if set on channel 0, then diff. measurement is performed between channels 0 and 1. It is advised to set +1 Channel to 0 (OFF) to avoid Errors). Setting the channels to 4 means the channel is in Custom Mode (Not implemented yet) +  * The **#define AD24_AIN0, AD24_AIN1, AD24_AIN2, AD24_AIN3** define which AD24 channels are active, and in which mode they operate. Setting any of the channels to 0 means the channel is off. Setting the channels to 1 means the channel is set to a single ended voltage measurement with 3.3V reference. Setting the channels to 2 means the channel has a single ended current measurement. Setting the channels to 3 means Differential Voltage Measurement between this channel and +1 channel (e.g. if set on channel 0, then diff. measurement is performed between channels 0 and 1. It is advised to set +1 Channel to 0 (OFF) to avoid Errors). Setting the channels to 4 means the channel is in Custom Mode (Not implemented yet) 
-  * The *int AD24_MINT* defines the time interval (in ms) at which the AD24 measurement is read. It is advised to keep this setting above 150 ms per active channel. +  * The **int AD24_MINT** defines the time interval (in ms) at which the AD24 measurement is read. It is advised to keep this setting above 150 ms per active channel. 
-  * The *#define AD24_DEBUG* is used to activate debug messages. Setting it to 0 turns off the debug messages and setting it to 1 turns on the debug messages. +  * The **#define AD24_DEBUG** is used to activate debug messages. Setting it to 0 turns off the debug messages and setting it to 1 turns on the debug messages. 
-  * The *#define AD24_CALIB* is used to activate auto calibration during initialization. Setting it to 0 turns off the calibration and setting it to 1 turns on the calibration. +  * The **#define AD24_CALIB** is used to activate auto calibration during initialization. Setting it to 0 turns off the calibration and setting it to 1 turns on the calibration. 
-  * The *#define AD24_TRANS_AIN0, AD24_TRANS_AIN1, AD24_TRANS_AIN2, AD24_TRANS_AIN3* defines whether the ADC transmit data via the LoRa network. O stands for no and 1 stands for yes.+  * The **#define AD24_TRANS_AIN0, AD24_TRANS_AIN1, AD24_TRANS_AIN2, AD24_TRANS_AIN3** defines whether the ADC transmit data via the LoRa network. O stands for no and 1 stands for yes.
  
 {{ad24.png|Measurement Settings from the AD24\textunderscore config.h file}} {{ad24.png|Measurement Settings from the AD24\textunderscore config.h file}}
Line 162: Line 162:
  
   * The AD24 must be activated and one of the channels must be set to "mode 1" (single channel voltage). The wire for signal out of water pressure sensor (orsnge wire) to the appropriate port.   * The AD24 must be activated and one of the channels must be set to "mode 1" (single channel voltage). The wire for signal out of water pressure sensor (orsnge wire) to the appropriate port.
-  * Connect the power source (red wire) to the SW3V3 port, and ground it by connecting the black wire to the the GND port. Also change the SW3V3 parameter in the *general_config.h* to "true"+  * Connect the power source (red wire) to the SW3V3 port, and ground it by connecting the black wire to the the GND port. Also change the SW3V3 parameter in the **general_config.h** to "true"
-  * If the I2A or I2B sensor is used, set it to either the AIN0_12 OR AIN1_12 port in general_config.h (which is the correct port?). Set SW3V3A to false in the *general_config.h*, if it is not needed for any other measurements. Connect the brown wire to the appropriate port of the AD12 (4 pin output, not the AD24 8 pin output).+  * If the I2A or I2B sensor is used, set it to either the AIN0_12 OR AIN1_12 port in general_config.h (which is the correct port?). Set SW3V3A to false in the **general_config.h**, if it is not needed for any other measurements. Connect the brown wire to the appropriate port of the AD12 (4 pin output, not the AD24 8 pin output).
   * Connect the green and yellow wire to the SDA and SCL of the I2C port respectively.   * Connect the green and yellow wire to the SDA and SCL of the I2C port respectively.
  
-After follwing this procedure, the Subsurface Measurement Probe or Low Cost Inclinometer is set up. The following are the various parameters listed in the *SMN_config.h* that can be adjusted accordingly.+After follwing this procedure, the Subsurface Measurement Probe or Low Cost Inclinometer is set up. The following are the various parameters listed in the **SMN_config.h** that can be adjusted accordingly.
  
 +{{smn1.png|SMN Variables and Definition of Inclination sensors from the SMN_config.h file}}
  
 +{{smn2.png|Data retrieval Rate and Transmission Settings from the SMN_config.h file}}
  
 +==== LCI Settings and Measurement ==== 
  
 +These are the settings that need to be changed by the user when installing a sensor. The subsequent tabs with configurations for the individual sensors on the other hand contain more detailed sensors that should only be changed when detail settings need to change. Each of these parameters is described in the code shortly on the right side as comments. 
  
 +==== BATV_config.h ====
  
-HIER WEITERMACHEN!+This file stores the configuration for the battery voltage measurement. The hardware is designed in such a way that it is possible to measure the battery voltage using the analog input of the Arduino. The settings do normally not have to be changed by the user.
  
 +==== BARO_config.h ====
  
 +In this section, the settings for the barometer **BMP388** are defined. Usually, the settings don't need to be changed. The settings that could be changed by the user are, for example, **BARO_MODE** or **BARO_TIMING**. For more information on this, please check the [[https://www.arduino.cc/reference/en/libraries/bmp388_dev/|BMP388 Library]].
  
 +==== IMU_config.h ====
  
 +The IMU (short for 'inertial measurement unit') on the PCB is an ICM20948 by [[https://invensense.tdk.com/products/motion-tracking/9-axis/icm-20948/|Invensense]]. Unfortunately, for the first version of the PCB for the Inform@Risk project, the sensor was not available, so the section is in the code, but it hasn't been tested yet. So, by default, the sensor is turned off in the current version of the code. In this file, various parameters as the hardware adress (**#define ICM20948_ADDR**), the data transmission (**#define IMU_TRANS_ACC 1, #define IMU_TRANS_GYR 1, #define IMU_TRANS_MAG 1**) and the measurement interval (**IMU_MINT**) can be changed. The rest are global variables which should not be changed by the user.
  
 +==== INCL_config.h ====
  
 +The INCL_config.h deals with the external [[https://www.murata.com/en-us/products/sensor/inclinometer/overview/lineup/scl3300|SCL3300 inclinometer]] by muRata electronics which can be attached onto the PCB using a 3D printed file. This sensor is optional if the previously mentioned ICM is used, as it offers higher precision in its measurements, but is also more expensive. The parameters of the SCL that can be changed in the 'INCL_config.h' file are the inclination mode (**INCL_MODE**, four modes which vary in sensitivity), the temperature measurement (**INCL_TEMP**, can be turned on and off), fast read mode (**INCL_FASTREAD**, can be turned on and off; off by default), and transmit data for tilt and temperature (**INCL_TRANS_TILT**, **INCL_TRANS_TEMP**, on by default). The rest are variables and the measurement functions which should not be changed.
  
 +==== arduino_secrets.h ====
  
 +The arduino_secrets.h file holds the respective **SECRET_APP_EUI** and **SECRET_APP_KEY** which are set for the sensor on the gateway. For more on this, please also refer to the [[gateway|LoRa Gateway]] section.
  
 +==== extra_functions.h ====
  
-In this tab, the general settings are performedThe Uni_Config file is structured as follows: +In the **extra_functions.h** file, various additional and extraneous functions are compiled. For examplethe **DeepSleepMode()** function performs the sleep functionality of the nodedepending on what is set in the **setup.h** file. Also, functions on the ports setup (void PortsActivate(), void PortsDeactivate()) and various functions dealing with the data packets (void Payload_U32(), void Payload_I32(), void Packet10_B0_Prepare() and so on) can be found here.
-  Include libraries and necessary files +
-  Universal Configurations: Variable and Timing definitionssensor states +
-  Hardware Configuration +
-  Include extra configuration files for SCLSMN and ADCas well as functions+
  
-Of these parts, only the timing definitions and the sensor states need to and should be changed by the user (see picture below).  
  
-{{config.png|Timing and sensor configuration in the Uni_Config file}} 
  
-Each of these parameters is described shortly on the right side as comments.  
  
-==== Serial Output ==== 
  
-The first command **# define SP Serial** defines which serial port is used. This is important for debugging: Because the Serial monitor of the Arduino via USB shuts down once the processor goes into deepsleep-mode (described in detail in the section on deepsleep), it is possible to change the serial output to the serial ports on the PCB (RX, TX). This way, subsequent cycles after the first deepsleep command can also be read out from the serial port. If the serial ports on the PCB are used, the command needs to be changed to **SP Serial1**. 
  
-==== Loopintv ==== 
  
-Loopintv controls the interval of one cycle, including initialization, measurement, data transmission, powerdown, sleeping and powerup. This means that the sleeptime itself is calculated each cycle by subtracting **measlength** , **sensorstarttime** and the rest of the calculation time from the total **loopintv**. **extrafreq** is not used for now (v 1.0). 
  
-The sleeptime is calculated as follows: 
  
-sleeptime = loopintv - (measlength + sensorstarttime) 
  
-==== Sensor State ==== 
- 
-The Sensor State section is used to turn on/off the different sensors which are connected on the board or can be attached to it. To turn a sensor on, simply write “**= true**” after the corresponding variable. This is the main section which needs to be changed when setting up a sensor either in the field or when preparing it beforehand. Please note that for the current PCB version (V 0.2), no IMU is attached on the board, so this is always false. **Desig** and **settings\textunderscore desig** change dynamically in the loop and don’t have to be adapted. 
- 
-These settings can be seen as general toggles for the different sensors. If they are not turned on, all subsequent settings (for the ADC e.g. in the “**ADC\textunderscore Config.h**” file) are disregarded. If, for example, the SMN is attached, but with settings different from the default (explained in the SMN section), the SMN must be turned on here and the specific settings have to be changed in the **SMN\textunderscore Config.h** file. 
- 
-==== ADC Settings and Measurement ==== 
- 
-==== SMN Settings and Measurement ==== 
  
-==== LCI Settings and Measurement ==== 
  
-==== Active and DeepSleep Mode ==== 
en/monitoring_and_warning/software.1674555405.txt.gz · Last modified: 2023/01/24 10:16 by m-gamperl