1. Algorithm description
NeuraSafe (Man Down) library allows to track man down alert events within different activities performed by the user. NeuraSafe is an IMU-based solution that exploits only angular velocity and/or linear accelerations readings, measured in dps and mg respectively, and sampled @50Hz. NeuraSafe requires a single inertial sensor, that can be installed on the user chest. Other placements such as user belt, upper arm and shoulder have been tested with good results but chest positioning is suggested to maximize algorithm perfromances. A dedicated library version suitable for wrist positioning has also been developed. Chest solution can be run using both accelerometer and gyroscope (6DOF
solution) or using only accelerometer. Wrist solution is available only in the 6DOF version.
Library configuration can be done with the following operations:
-
MAD_ResetParameters has to be called during initialization of the library to reset all the alogrithm parameters
at pre-defined and documented values; -
MAD_SetParameters can be called in order to modify algorithm parameters: run this command at user’s own
risk; - MAD_GetParameters can be called in order to get parameter values.
-
MAD_Set_Device_Position can be called in order to set device orientation axis.
- Option 1: if MAD_Set_Device_Position is called, approximative device axis direction can be set, following
AxisDirection. Man down logic will be armed by the first sample. - Option 2: if MAD_Set_Device_Position is not called, the first 15 seconds are spent to detect device
orientation: therefore it is mandatory wear the device before running the library and suggested to adopt
an upright position, varying the inclination of the body as little as possible. If wrist version is used, keep
you arm at your side for a correct usage. In this case, during this period the whole man down logic is
disabled.
- Option 1: if MAD_Set_Device_Position is called, approximative device axis direction can be set, following
NeuraSafe integration requires only 4 lines of code, which implement the following functionalities:
-
MAD_Init. It must be invoked before running the logic. It allows to set all the configuration parameters and
internal variables. The only argument of this function allows to manage the 3DOF or 6DOF MAD solution for
chest library only, the first exploits only accelerometer data while the second takes into accunt also gyroscope
data. For wrist solution, 6DOF flag must be activated. This funtion has to be called also at higher level, when a man down event has been detected and the detection has to start again. In fact, when a man down event is detected by the algorithm, the algorithm is stuck at the MAD_ALERT_CHARLIE alert condition untill a MAD_Init is called. -
MAD_Update. It runs the core functions of the logic, as depicted in the AlgorithmFlowchart, necessary to
track a man down event. - MAD_Get_Arming_Status. It returns the current man down arming status.
- MAD_Get_Alert_Level. It returns the current man down alarm value.
-
MAD_Lying_Down. It returns if the current user position is standing or lying. This status is not related to the
detection of MAD event. -
MAD_Immobility_Trigger. It returns if the user is motionless or not. This status is not related to the detection
of MAD event.
2. Flowchart
The following block diagram describes the flow of operations that implement the NeuraSafe logic.
Figure 2.1 Block diagram showing the algorithm functioning.
3. References
The following lines contain general information about the library, such as version and date of publication, together with the contact details of the 221e internal staff responsible for maintaining and managing the library.
-
Authors and Referents
Giorgio Barzon
Luigi Mattiello
Roberto Bortoletto -
Library Version
v1.0.8 -
Date
April 2026 -
Copyright
Copyright (c) 2020 All Rights Reserved by 221e srl. [email protected]
4. Requirements
The following lines contain information about the library size occupation, time execution and power consumption estimation. Tests and measurements have been perfomed with a STM32WB55 MCU, clocked @16MHz, and including within a STM32CubeIDE firmware project the NeuraSafe static library compiled for ARM Cortex-M4. No optimization (i.e., -O0) has been applied during library compilation. Results are reported
in the following tables.The test runs were conducted over a duration of 1 minute, which is a worst-case scenario,
given that in real-world conditions the activation of the innermost and most computationally intensive branches of
the logic only occurs during impacts.
| FLASH Occupation [kB] | RAM Occupation [kB] | |
|---|---|---|
| Chest Library | 16.67 | 3.64 |
| Wrist Library | 33.51 | 22.28 |
TABLE 4.1 NEURASAFE MEMORY OCCUPATION
| Timing [clock hits] | Timing @64MHz [ms] | Power Consumption @50Hz [uA] | |
|---|---|---|---|
| Average Value MAD 6DOF |
17,229 | 1.077 | 86 |
| Maximum Value MAD 6DOF | 17,952 | 1.122 | 90 |
| Average Value MAD 3DOF |
8,002 | 0.500 | 40 |
| Maximum Value MAD 3DOF | 8,581 | 0.536 | 43 |
TABLE 4.2 NEURASAFE CHEST, EXECUTION TIMINGS AND POWER CONSUMPTIONS
| Timing [clock hits] | Timing @64MHz [ms] | Power Consumption @50Hz [uA] | |
|---|---|---|---|
| Average |
37,855 | 2.366 | 189 |
| Maximum | 222,188 | 13.887 | 1,111 |
TABLE 4.3 NEURASAFE WRIST, EXECUTION TIMINGS AND POWER CONSUMPTIONS
5. Example Documentation
MAD_Example.c
This is an example of library usage for NeuraSafe logic with accelerometer and gyroscope data. The data were acquired with the 221e Muse device, installed on the user’s chest, at heart height. The test was performed wearing the sensor all day while the following activities have been done: walking, running, sitting and standing. Within the acquisition different man down events were simulated on a mattress. Results of the logic was saved to file. In the following ExampleFigure one of detected MAD_ALERT_CHARLIE event is depicted. The following lines show how the library was executed on the collected data.
FIGURE 8.1 OUTPUT EXAMPLE
#include<stdio.h> // Include C standard libraries
#include <math.h>
#include "MAD_Tracker.h" // Include MAD_Tracker.h library
#define inputDataLength 6 // Define input data length
float inputData[inputDataLength] = {0,0,0,0,0,0}; // Initialize input data array
MAD_ALERT_LEVEL MAD_LEVEL_output; // Define output
bool user_is_down = false; // Initialize user down boolean variable
bool set_device_orientation = true; // boolean to manage automatic device orientaton detection
AxisDirection DeviceAxis[3]; // Define Device Axis array
bool enable_6DOF = false; // Use 3DOF solution
int main(void) {
uint8_t i; // Support variable
FILE *fIn = fopen("input_file.txt", "r"); // Open input file
FILE *fOut = fopen("output_file.txt", "w"); // Open output file
MAD_ResetParameters(); // Initialize algorithm parameters
MAD_Init(enable_6DOF); // MAD_Init call
if (set_device_orientation){
DeviceAxis[0] = Down; // X axis direction
DeviceAxis[1] = Lateral; // Y axis direction
DeviceAxis[2] = Forward; // Z axis direction
MAD_Set_Device_Position(DeviceAxis); // Set device axis orientation
}
// Main loop
while (feof(fIn) == 0) {
// Read current data
for (i = 0; i < inputDataLength; i++)
fscanf(fIn, "%f", &inputData[i]);
// Read data: Gyr.X Gyr.Y Gyr.Z Acc.X Acc.Y Acc.Z
float inGyr[3] = { inputData[0], inputData[1], inputData[2] };
float inAxl[3] = { inputData[3], inputData[4], inputData[5] };
MAD_Update(inGyr,inAxl); // MAD_Update call
bool MAD_is_Armed = MAD_Get_Arming_Status(); // Get MAD arming status
MAD_LEVEL_output = MAD_Get_Alert_Level(); // MAD_Get_Alert_Level call
bool MAD_user_is_down = MAD_Lying_Down(); // MAD_Lying_Down call
bool MAD_immobility = MAD_Immobility_Trigger(); // MAD_Immobility_Trigger call
fprintf(fOut,"%d\t%d\t%d\t%d\n", MAD_is_Armed, MAD_LEVEL_output,MAD_user_is_down,MAD_immobility); // Print output on
file
}
// Close I/O files
fclose(fIn);
fclose(fOut);
return 0;
}