Thursday, August 30, 2018

WEEK 7 (FYP 2)

Activity: Measure Respiration Rate

In this part, there is not much coding for the measurement respiration rate. i found some coding but there are certain part that need to be change. in order to measure respiration rate, the temperature change must be faster to the calculation in the micro controller to be correct. The coding for the respiration rate measure the temperature sensor in a ADC value. So, the voltage has be read as a ADC value. here the coding for the respiration rate measurement. 

#include <LiquidCrystal.h>
enum respState 
{
    Inhaling,
    Exhaling
};
unsigned long prevRespTime = 0;
unsigned long currRespTime = 0;
respState currentRespState;
int movingAvgRespRate = 0;
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() 
{
  lcd.begin(16, 2);
    Serial.begin(9600);
    pinMode(9,OUTPUT); //buzzer
}


void loop()
{
    //delay(500);  
    // don't need to delay because we'll only fire once per inhalation and once per exhalation
    int sensorValue = analogRead(A0);

    if (sensorValue > 510 && currentRespState == Exhaling)
    {
        currentRespState = Inhaling;
        prevRespTime = currRespTime;  // save time from last cycle
        currRespTime = millis();

        float period_respiration = currRespTime - prevRespTime;
        float breathrate = 60000 / period_respiration;
        Serial.print("Inhaling \tRespirations per minute: ");
        Serial.println(breathrate);
        lcd.setCursor(0, 1);
        lcd.print("RPM");
        lcd.print(breathrate);

         if (breathrate>1 && breathrate<9)
        {
          digitalWrite(9,HIGH);
          delay(2000);
          digitalWrite(9,LOW);
          delay(200);
        }
        if (breathrate>60 && breathrate<100)
        {
          digitalWrite(9,HIGH);
          delay(1000);
          digitalWrite(9,LOW);
          delay(200);
        }
        else if (breathrate>101 && breathrate<500 )
        {
           digitalWrite(9,HIGH);
          delay(500);
          digitalWrite(9,LOW);
          delay(200);
        }
        else
        {
          digitalWrite(9,LOW);
        }
        
      
    }
    else if (currentRespState == Inhaling && sensorValue < 490)
    {
        currentRespState = Exhaling;
        Serial.println("Exhaling");
        lcd.setCursor(0, 0);
        lcd.print("Exhaling       ");
        
    }


The sensor value was set from the voltage of the temperature changes. When exhale, the sensor value is more than 510 and when inhale the voltage less than 490.

But the value for the sensor value not a fix value. 







Tuesday, August 21, 2018

WEEK 6 (FYP 2)

Activity: Measure the Temperature Sensor


The figure showed the measurement of the temperature in a room temperature which means there are no inhalation and exhalation was doing. The temperature was not in constant value since the temperature was affected by the surrounding, for example, the room itself has air flow from the outside and the air-cond condition that made the room became colder. The average temperature if a no breathing was 24.53 Celsius.


The result from the Arduino software when there is a non-breathing action.


Result recorded in the LCD 

The figure below showed the value of temperature recorded in a room temperature when there is no breathing. The graph showed that the value doesn’t have a constant value. When the inhalation and exhalation were doing, the temperature does not change quickly but the temperature keeps increasing even though the nebulizer mask has a hole that can make the heat from the exhale and inhale can change faster.

The pattern of the temperature value when exhalation, inhalation and not breathing.




Thursday, August 16, 2018

WEEK 5 (FYP 2) WORKSHOP ON RESULT AND DISCUSSION

Activity: Briefing Week

In this week, the briefing was conducted in TTL and as usuall, all the attandance of all FYP 2 student is compulsory. The briefing was by Miss Najihah. this week briefing is about the Discussion (Chapter 4) and Conclusion (Chapter 5).

                    Date: 15/8/2018
                    Venue: TTL 2
                    Time: 3:00PM - 5:00PM

In this briefing, the FYP committees have been brief us about:


  • How to write the Discussion and Conclusion
  • If possible do a graph, chart or table for the measurement result
          *if graph, it must has a title, the x and y axis must be correct
  • The discussion and conclusion must be in past tense
  • The picture of the result must has a caption
  • For conclusion, just summarize what has been done
  • Its okay if the project not function but must explain the reason why doesn't function
  • The conclusion must reflect back the objective

Miss Najihah brief about Discussion and Conclusion

Saturday, August 11, 2018

WEEK 4 (FYP 2)


Activity: Hardware Parts

So, i have purchased the component needed from electronics online shopping and some in Jalan Pasar, Kuala Lumpur. 



the electronics shop

online shopping 




Mostly i founds all the the component that needed for my project except for the mask. i plan to use a plastic glass first as a mask.

So,  i need to start the project based on the simulation .





Activity: Study the Simulation and Coding


First of all, he want to see the circuit diagram that have been construct  based on the simulation that has been done in order to start the hardware project. Then he want us to searching and understand the coding for the project and try it.

After done some research about the coding, i found a coding to measure a temperature. The coding for this circuit also has been done by do some study in the Arduino website. This is because, to measure the respiration rate via temperature sensor, we need to measure the temperature first. So, the connection for the temperature sensor have been done in Proteus using 100k NTC thermistor. The circuit is function well as we increased the temperature sensor, the temperature displayed in the LCD also increase. 

This is the connection that i have been done in Proteus 8.



The connection of the temperature measurement


When the 100k NTC thermistor was set 25 Celcius, the temperature measurement is 24.53 Celcius


The coding use when run the program was:

#include <LiquidCrystal.h>
int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
}
void loop() {
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
T = T - 273.15;
T = (T * 9.0)/ 5.0 + 32.0;
lcd.print("Temp = ");
lcd.print(T);
lcd.print(" F");

delay(500);
lcd.clear();
}




Activity: Testing the construct circuit.

Since the thermistor is a variable resistor, we’ll need to measure the resistance before we can calculate the temperature. However, the Arduino can’t measure resistance directly, it can only measure voltage.


The Arduino will measure the voltage at a point between the thermistor and a known resistor. This is known as a voltage divider. The equation for a voltage divider is:
V_{out}=V_{in} \times (\frac{R2}{R1+R2})
In terms of the voltage divider in a thermistor circuit, the variables in the equation above are:
V_{out}: \ Voltage \ between \ thermistor \ and \ known \ resistor\\  V_{in}: \ V_{cc}, \ i.e. \ 5V\\  R1: \ Known \ resistor \ value \\  R2: \ Resistance \ of \ thermistor
This equation can be rearranged and simplified to solve for R2, the resistance of the thermistor:

R2= R1 \times (\frac{V_{in}}{V_{out}} - 1)
After done construct the circuit diagram, i test the function of the temperature sensor. The sensor can detect same as in the simulation. So this is the circuit. 


The testing to measure temperature

Plastic glass a mas and power bank as a power supply


After testing, i meet my supervisor to shown my little progress of the temperature sensor measured. The temperature measurement have been test with him. It work but the temperature not very accurate because we are doing this under cold temperature which is in their office.



Wednesday, August 1, 2018

WEEK 3 (FYP 2) INTRODUCTION

Activity: Briefing Week

Today is the third week for this FYP 2. This week id the first briefing for FYP 2. the briefing was conducted in TTL 2 and the attendence to all FYP 2 students is compulsory. The speaker is b Dr Kanendra with other staff to key-in the attendance.

Date: 1/8/2018
Venue: TTL 2
Time: 3:00PM - 5:00PM

In this briefing, the FYP committees have briefed us about:



  • The code of the Subject FYP must be correct and student should be register the project title for minor amendment before week 8. 
  • Assessment that need to be cover for FYP 2 which is final report (logbook/blog), presentation, and project proposal.
  • FYP 2 should be continues after the proposal report with do the result&analysis, discussions, and conclusion of overall project. 
  • The marks for this FYP 2 was; 


  • Ready for the presentation in Week 14
  • The report must be submit 23/11/2018

Briefring from Dr Kanendra