08/02/2021 To 14/02/2021
1.Research about more secure and patient friendly power supply
Medical power supplies are power supplies which produce conditioned outputs for medical devices, instruments, and equipment. They are built to satisfy the IEC601(EN60601)& UL60601 safety standard which covers electrical, medical, and dental equipment that is intended for professional use. This standard ensures the device's reliability, which is especially important in the medical field. By satisfying the standard, power supplies are defined as "medical-grade" devices. An important feature of these power supplies is their ability to isolate the patient from any electrical signals.
Medical power supplies also typically require longer design cycles than commercial devices, and designers often require more design support from the power supply vendor. They also tend to have a longer life expectancy, meaning they typically need to be supported by the vendor for many years.
Power Supply Types
Power supplies are categorized by the mechanism used to convert and transfer the input power to the output power. For medical power supplies, there are two main categories:
Linear power supplies accept AC inputs and provide one or more DC outputs for a wide variety of computer and industrial applications. They use an active element (normally a power transistor) operating in its linear region to generate a desired voltage. The output voltage is regulated by dropping excess input power in ohmic losses (heat) in a series dissipative component (resistor) or a transistor. Linear power supplies provide excellent regulation, very small ripple, and very little output noise.
Switching power supplies use a switching element or regulator (normally a power transistor) to generate the desired voltage. They are also called switch-mode products or switching mode power supplies (SMPSs). These power supplies incorporate electronic components that continuously switch ON and OFF at a very high frequency. This switching action connects and disconnects energy-storing devices (inductors or capacitors) to and from the input source voltage or the output load. A SMPS design results in high power density (smaller size for the same power output) and reduced power consumption (higher efficiency) in comparison to linear power supplies.
Protection
Several factors can affect the performance and/or the physical integrity of DC power supplies. Circuits to protect the power supplies are normally included in the design and construction of the device. Some of these are:
Short circuit protection
Overload protection
Over current protection
Over voltage protection
Under voltage protection
Over temperature protection
Switch Mode Power Supply(SMPS)
Switch mode power supplies are widely used because of the advantages they offer in terms of size, weight, cost, efficiency and overall performance. As a result of their performance, switch mode power supplies are used in all but the most exacting applications to provide an efficient and effective source of power for most forms of electronic systems. Switch mode power supplies have become an accepted part of the electronics scene and are often referred to as switch mode power converters, or just switchers.
The basic concept behind a switch mode power supply or SMPS is the fact that the regulation is undertaken by using a switching regulator. This uses a series switching element that turns the current supply to a smoothing capacitor on an off. The time the series element is turned on is controlled by the voltage on the capacitor. If it is higher than required, the series switching element is turned off, if it is lower than required, it is turned on. In this way the voltage on the smoothing or reservoir capacitor is maintained at the required level.
SMPS advantages
High efficiency: The switching action means the series regulator element is either on or off and therefore little energy is dissipated as heat and very high efficiency levels can be achieved.
Compact: As a result of the high efficiency and low levels of heat dissipation, the switch mode power supplies can be made more compact.
Costs: one of the points that makes switch mode power supplies very attractive is the cost. The higher efficiency and the switching nature of the design means that the heat that needs to be reduced is lower than that of linear supplies and this reduces costs. Long with this, the switching nature of the supply means that many of the components are lower cost.
Flexible technology: Switch mode power supply technology can be used to provide high efficiency voltage conversions in voltage step up or "Boost" applications or step down "Buck" applications.
SMPS Disadvantages
Noise: The transient spikes that occur from the switching action on switch mode power supplies are one of the largest problems. The spikes can migrate into all areas of the circuits that the SMPSs power if the spikes are not properly filtered. Additionally the spikes or transients can cause electromagnetic or RF interference which can affect other nearby items of electronic equipment, particularly if they receive radio signals.
External components: While it is possible to design a switch mode regulator using a single integrated circuit, external components are typically required. The most obvious is the reservoir capacitor, but filter components are also needed. In some designs the series switch element may be incorporated within the integrated circuit, but where any current is consumed, the series switch will be an external component. These components all require space, and add to the cost.
Expert design required: It is often possible to put together a switch mode power supply that works. To ensure that it performs to the required specification can be more difficult. Ensuring the ripple and interference levels are maintained can be particularly tricky.
Filtering: Careful consideration of the filtering for an SMPS because poor design can lead to high levels of noise and spikes on the output.
2.Programming Codes for used Arduino Modules
ESP8266 Wifi Module
Arduino code (Only for Wifi Module)
#include <SoftwareSerial.h>
#define RX 2
#define TX 3
String PID = "S.R.Hettiarachchi";
String AP = "SSID"; // AP NAME
String PASS = "AP PASSWORD"; // AP PASSWORD
String API = "Write API KEY"; // Write API KEY
String HOST = "api.thingspeak.com";
String PORT = "80";
String field = "field1";
int countTrueCommand;
int countTimeCommand;
boolean found = false;
int valSensor = 1;
SoftwareSerial esp8266(RX,TX);
void setup() {
Serial.begin(9600);
esp8266.begin(115200);
sendCommand("AT",5,"OK");
sendCommand("AT+CWMODE=1",5,"OK");
sendCommand("AT+CWJAP=\""+ AP +"\",\""+ PASS +"\"",20,"OK");
}
void loop() {
String getData = "GET /update?api_key="+ API +"&"+ field +"="+PID;
sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
esp8266.println(getData);delay(1500);countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");
}
int getSensorData(){
return random(1000); // Replace with your own sensor code
}
void sendCommand(String command, int maxTime, char readReplay[]) {
while(countTimeCommand < (maxTime*1))
{
esp8266.println(command);//at+cipsend
if(esp8266.find(readReplay))//ok
{
found = true;
break;
}
countTimeCommand++;
}
if(found == true)
{
//Serial.println("OYI");
countTrueCommand++;
countTimeCommand = 0;
}
if(found == false)
{
countTrueCommand = 0;
countTimeCommand = 0;
}
found = false;
}
By considering above code, The SSID must be replaced with customer SSID of the Wifi access point. AP PASSWORD must be replaced by Wifi password of the Wifi access point. Write API KEY must be replaced by API write key of the customer webserver channel.
Arduino Code (With Real Time Signal Processing)
#include <MovingAverageFilter.h>
#include <SoftwareSerial.h>
MovingAverageFilter movingAverageFilter(20);
MovingAverageFilter movingAverageFilter1(20);
MovingAverageFilter movingAverageFilter2(20);
SoftwareSerial WebServer(2, 3);
String wifi_send="";
int Person_ID= 1;
float avgdropvolume = 0.0257;
float Urine_Volume = 0.0;
float input;
float output;
float caltime;
float initialarray[2] = {0.0,0.0};
float currentarray[2];
float dy;
float dt;
float derivative_output;
float output1;
float initialarray1[2] = {0.0,0.0};
float currentarray1[2];
float dy1;
float dt1;
float derivative_output1;
float output2;
float output3;
float threshold=550.0;
int peakcount=0;
int k=0;
int Patient_No = 1;
float peak = 0.0;
float time1=0.0 ;
float time2=0.0;
float time3= 0.0;
float pre_peak_time = 0.0;
float current_peak_time = 0.0;
float Flow_rate = 0.0;
void setup()
{
Serial.begin(9600);
WebServer.begin(115200);
}
void loop()
{
input = analogRead(A0);
caltime = millis();
output = movingAverageFilter.process(input);
currentarray[0] = output*50.0;
currentarray[1] = caltime;
dy = currentarray[0]- initialarray[0];
dt = currentarray[1] - initialarray[1];
derivative_output = dy/dt;
initialarray[0] = currentarray[0];
initialarray[1] = currentarray[1];
output1 = movingAverageFilter1.process(derivative_output);
currentarray1[0] = output1*50.0;
currentarray1[1] = caltime;
dy1 = currentarray1[0]- initialarray1[0];
dt1 = currentarray1[1] - initialarray1[1];
derivative_output1 = dy1/dt1;
initialarray1[0] = currentarray1[0];
initialarray1[1] = currentarray1[1];
output2 = movingAverageFilter2.process(derivative_output1);
output3= output2*127.0;
if (k!=1){
if(output3 > threshold){
peak = threshold;
k= 1;
time1=millis();
}
}
if(k==1){
current_peak_time = time1;
if(output3 < 425.0){
peak = 0.0;
peakcount = peakcount +1;
Urine_Volume = Urine_Volume+ avgdropvolume;
k=0;
//time2=millis();
time3 = (current_peak_time- pre_peak_time)/1000.0;
pre_peak_time = current_peak_time;
Flow_rate = (avgdropvolume)/(time3/3600.0);
wifi_send = "*" + String(Person_ID)+ "," + String(peakcount) + "," + String(time3) + "," + String(Urine_Volume)+ "," + String(Flow_rate) + "," + "#";
//Serial.println(wifi_send);
}
}
WebServer.println(wifi_send);
}
Arduino Libraries
ESP8266 Node MCU Testing Codes
Storing data samples of a day by using Micro SD Card Module
Arduino Code (Only for SD Card Module)
#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
if (!SD.begin(10)) {
Serial.println("initialization failed!");
while (1);
}
myFile = SD.open("Urine_Volume_Meter.txt", FILE_WRITE);
if (myFile) {
float Timescale = millis();
myFile.print(Timescale);
myFile.print(",");
myFile.println(peakcount);
myFile.close();
} else {
Serial.println("error opening test.txt");
}
}
void loop() {
}
Arduino Code (With Real Time Signal Processing)
#include <MovingAverageFilter.h>
#include <SPI.h>
#include <SD.h>
File myFile;
MovingAverageFilter movingAverageFilter(50);
MovingAverageFilter movingAverageFilter1(20);
MovingAverageFilter movingAverageFilter2(20);
float input;
float output;
float caltime;
float initialarray[2] = {0.0,0.0};
float currentarray[2];
float dy;
float dt;
float derivative_output;
float output1;
float initialarray1[2] = {0.0,0.0};
float currentarray1[2];
float dy1;
float dt1;
float derivative_output1;
float output2;
float threshold=0.2;
int peakcount=0;
int k=0;
float peak = 0.0;
float time1=0.0 ;
float time2=0.0;
float time3= 0.0;
void setup()
{
Serial.begin(4800);
if (!SD.begin(10)) {
while (1);
}
}
void loop()
{
input = analogRead(A0);
caltime = millis();
output = movingAverageFilter.process(input); // here we call the fir routine with the input. The value 'fir' spits out is stored in the output variable.
currentarray[0] = output;
currentarray[1] = caltime;
dy = currentarray[0]- initialarray[0];
dt = currentarray[1] - initialarray[1];
derivative_output = dy/dt;
initialarray[0] = currentarray[0];
initialarray[1] = currentarray[1];
output1 = movingAverageFilter1.process(derivative_output);
currentarray1[0] = 100*output1;
currentarray1[1] = caltime;
dy1 = currentarray1[0]- initialarray1[0];
dt1 = currentarray1[1] - initialarray1[1];
derivative_output1 = dy1/dt1;
initialarray1[0] = currentarray1[0];
initialarray1[1] = currentarray1[1];
output2 = movingAverageFilter2.process(derivative_output1);
if (k!=1){
if(output2 > threshold){
peak = threshold;
k= 1;
time1=millis();
}
}
if(k==1){
if(output2 < 0.05){
peak = 0.0;
peakcount = peakcount +1;
k=0;
time2=millis();
time3 = time2-time1;
myFile = SD.open("Urine_Volume_Meter.txt", FILE_WRITE);
if (myFile) {
myFile.print(time1);
myFile.print(",");
myFile.print(time2);
myFile.print(",");
myFile.print(time3);
myFile.print(",");
myFile.println(peakcount);
myFile.close();
}
}
}
Serial.print(output2);
Serial.print(",");
Serial.println(peakcount);
}
Arduino Libraries