Pada pagi yang cerah bertabur kilauan cahaya, kali ini saya akan mejelaskan mengenai bagaimana cara membuat sebuah alat yang menggunakan sensor MPX5700DP sebagai tekanan udara dan sensor water flow sebagai kecepatan aliran udara, alat ini menggunakan mikrokontroller Arduino sebagai processor dan pengolahan datanya, kemudian ada LCD display sebagai user interface-nya serta penampil angka hasil pengolahan. aplikasi dari alat ini sangatlah banyak salah satunya sebagai tensi meter atau bisa juga pengukur tekanan udara di paru-paru / tabung gas. untuk merubah parameter satuannya bisa di konversi menggunakan rumus. untuk lebih jelasnya berikut adalah skema dan programnya.
a. Arduino UNO + Skema
b. LCD 16x2
c. Sensor Tekanan MPX5700DP
d. Sensor Water Flow Hall Effect
e. Program Arduino IDE
#include "Wire.h"
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int x;
float v;
float kpa;
byte sensorInterrupt = 0; // 0 = digital pin 2
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;
unsigned long oldTime;
void setup() {
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop() {
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
/*
unsigned int frac;
Serial.print("Flow rate: ");
Serial.print(int(flowRate)); /
Serial.print(".");
frac = (flowRate - int(flowRate)) * 10;
Serial.print(frac, DEC) ;
Serial.print("L/min");
Serial.print(" Current Liquid Flowing: ");
Serial.print(flowMilliLitres);
Serial.print("mL/Sec");
Serial.print(" Output Liquid Quantity: ");
Serial.print(totalMilliLitres);
Serial.println("mL");
*/
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
x = analogRead(A0);
v = x*(5.0/1023.0);
kpa = ((v/5.0)-0.04)/0.0012858;
lcd.setCursor(0, 0);
lcd.print("kPa= ");
lcd.print(kpa);
lcd.setCursor(0, 1);
lcd.print("ml/s= ");
lcd.print(flowMilliLitres);
delay(200);
lcd.clear();
}
void pulseCounter()
{
pulseCount++;
}
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int x;
float v;
float kpa;
byte sensorInterrupt = 0; // 0 = digital pin 2
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
unsigned int frac;
float flowRate;
unsigned int flowMilliLitres;
float totalMilliLitres;
unsigned long oldTime;
void setup() {
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop() {
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
/*
unsigned int frac;
Serial.print("Flow rate: ");
Serial.print(int(flowRate)); /
Serial.print(".");
frac = (flowRate - int(flowRate)) * 10;
Serial.print(frac, DEC) ;
Serial.print("L/min");
Serial.print(" Current Liquid Flowing: ");
Serial.print(flowMilliLitres);
Serial.print("mL/Sec");
Serial.print(" Output Liquid Quantity: ");
Serial.print(totalMilliLitres);
Serial.println("mL");
*/
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
x = analogRead(A0);
v = x*(5.0/1023.0);
kpa = ((v/5.0)-0.04)/0.0012858;
lcd.setCursor(0, 0);
lcd.print("kPa= ");
lcd.print(kpa);
lcd.setCursor(0, 1);
lcd.print("ml/s= ");
lcd.print(flowMilliLitres);
delay(200);
lcd.clear();
}
void pulseCounter()
{
pulseCount++;
}
f. Merubah satuan sensor tekanan MPX
v =(float)(Dataadc*5.0)/1023.0
kpa = (float)((v / 5)-0.04)/0.0012858
Psi = (float)(kpa * 0.145)
mmhg = (float)(kpa * 7.5)
g. VIDEO HASILNYA
No comments:
Post a Comment