DISCLAIMER: This application is used for demonstrative and illustrative purposes only and does not constitute an offering that has gone through regulatory review. It is not intended to serve as a medical application. There is no representation as to the accuracy of the output of this application and it is presented without warranty.
Project video!
Of course, below you have extensive documentation of the project, commented code and step by step instructions!
IntroductionNowadays, all electrical devices that we use, be it your cell phone charger to a washing machine, require to be connected to a 120-240 volt socket at 50-60 Hz. Even in the surgery rooms of hospitals the same thing happens. In the same way, every medical device is connected to a wall socket. However we have a very serious problem, if one of the devices is damaged and some of the current is transmitted to the human body it can be dangerous and even lethal.
This current that can reach the human body is known as a leakage current and depending on its intensity, it can injure or even kill the patient [1].
The most common case of these accidents is known as macro shock, which occurs when a current of more than 10mA passes through the human body.
Less common than the previous one, is a leakage current known as micro-shock. This occurs when a leakage current of at least 10uA reaches a person through a catheter to the heart.
I want to solve for the problem of early detection of these leakage currents before they can cause harm to patients.
[1]. https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/macroshock
SolutionHere I will build a system that is capable of monitoring the medical instruments or areas of contact with the patient to prevent the patient from receiving one of these shocks and, in the case of detecting these leakage currents, activate an alarm so that there is proper maintenance for the equipment or they can cancel their use.
Current Solutions:
Isolated Power System - Schneider: https://www.se.com/ca/en/product-range-presentation/7367-isolated-power-system/
Cons:
- It is to complex and expensive
- Has to be built inside the hospital’s infrastructure at the time of its construction
- Requires constant maintenance
Double insulation cables:
- These types of cables should be used in all medical equipment.
- You must follow the regulations not to use this cable for lengths greater than 36 meters.
- The cable must be placed in the entire electrical installation of the hospital from its construction.
The system that I made was plug and play. This, since it could be placed in any device that is going to be used with the patient before they come into contact with it in order to maintain the 10uA maximum current regulation leakage.
Building ProcessConnection Diagram:NOTE: The solution was made using the nRF5340 as a BT control to completely isolate the user from the system leakage current measurements since the measurements are so precise that the same static electricity from the body could affect the measurements.
This is the connection diagram of the system:
All the code will be in the folder "nRF Software"
To program the nRF5340, install Segger Embedded Studio from nRF Connect -> Toolchain Manager -> Segger Embedded Studio v1.5.1
In the case of CORE NETWORK, the example application "hci_rpmsg" was used without making any changes to it.
In CORE APPLICATION an application was made with the following characteristics.
Modules utilized:
- BLE.
- LCD 16x2 Screen (4bits mode).
- HW Buttons.
- Modules utilized:BLE.LCD 16x2 Screen (4bits mode).HW Buttons.
To use BLE, the "peripheral_hr" project was taken as an example, as it is very easy to send data to nRF Cloud and to send our commands.
In this case the command comes through the Heart Rate Measurement as a notification. You can see how it changes from 0 to 4 indicating which command is required.
For more details, the code inside the folder nRF Software/cpuapp/main.c has all the details commented.
LCD :This is the most complicated part of making an adaptation of the LCD libraries already created. As you need it to work on the pins of the board, an Arduino shield was used to connect it to the board, the connection diagram is as follows:
In the software the connections were defined in this way.
For more details on how the library works, the code inside the folder nRF Software/cpuapp/main.c.
Buttons :The buttons were used using the polling technique with a 10ms debounce.
while (gpio_pin_get(button1, SW0_GPIO_PIN) == 1)
{
k_msleep(10);
if (gpio_pin_get(button1, SW0_GPIO_PIN) == 1)
{
button = "1";
flag = true;
}
if (gpio_pin_get(button1, SW0_GPIO_PIN) == 0)
{
k_msleep(10);
if (gpio_pin_get(button1, SW0_GPIO_PIN) == 0)
{
break;
}
}
}
All the details can be found in the code at nRF Software/cpuapp/main.c
RPi Gateway Setup:To avoid having to have a cell phone constantly using the nRF Cloud Gateway, I decided to install an Android operating system on a RPi 4, in order to serve as a constant Gateway.
RPi Android OS: OmniROM https://omnirom.org/
To use the power profiler, I use a raspberry pi zero to perform the Serial control of the profiler and also be able to receive the commands through the MQTT API of nRF Cloud.
Setup MQTT API :To obtain the credentials to use the nRF MQTT API follow the steps in the following official documentation.
https://nrfcloud.com/#/docs/guides/mqtt
To obtain all the necessary credentials and certificates use the Postman software.
In order to receive messages through MQTT use the paho-mqtt library, all the code will be in the PPK rpi folder.
Important considerations:
- Save the 3 certificates in the Certs folder.
- Write your corresponding Endpoint in the main.py code
- Write your corresponding clientId in the main.py code
EndPoint = "XXXXXXXXXXXXXXX.iot.us-east-1.amazonaws.com"
Client = "account-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
sub_topic = 'prod/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/a/gateways'
Setup PPK Python API :Everything you need to use the API is in the PPK rpi folder.
It is necessary to install the following libraries on the RPi.
pip3 install paho-mqtt adafruit-circuitpython-neopixel
To run the gateway correctly it is necessary to run the program with "sudo".
sudo python3 main.py
Here is a video example of how the MQTT broker receives messages.
Test Methodology:For this project I decided to test the operation of the device in a controlled situation where the measured currents were standardized, in this case the following platform was used.
Testing the power profiler with the resistors, checking that the measurements are correct in the nRF Power Profile App:
BT Test:Checking that the Raspberry Pi works correctly as a Gateway.
Full Test:Here is a test of the entire system running at the same time.
The Final Product:nRF5340 BLE Control:
Open case:
Closed case:
Shock Detector Device:
Open case:
As a Biomedical Engineer myself and given access to the great capabilities of the Power Profiler II this application came to mind immediately. At this point Vital sign monitoring is very prevalent in a lot of operating rooms, ER's and even ambulances. That is not the case for devices that protect the patient and monitor at the same these vital sign devices which is a lost opportunity. At the same time the market does not have a very portable solution for this and I jumped at the opportunity to try and design one. I think the final prototype looks great and is very functional, it barely needs a few adjustments and the full capabilities of the nRF chip and the Power profiler are exploited to its utmost. For remote patient monitoring something like this can be miniaturized as we are increasingly incorporating medical devices (more on our Elders) pacemakers, humidifiers, pulse oximeters, dialysis machines and more that use certain currents and can easily adapt into its architecture a Shock Protector.
References:Links:
[1]. https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/macroshock
Comments