Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
flow.h
- Committer:
- mehrnaz
- Date:
- 2019-07-12
- Revision:
- 2:ef98576cd67b
- Child:
- 3:3d51f8870e91
File content as of revision 2:ef98576cd67b:
#include "mbed.h"
AnalogIn flowIn(PA_0);
Serial co2(PC_10,PC_11); //USED IN MAIN
//Serial ttl(A1,A0);
float finalflow;
float flowVal1;
float flowVal2;
float P1;
int flag=0;
int o=0;
float bpArray[10];
float fp;float sp;
float FPressure;
int value;
//
float flow()
{
while(1)
{
wait(0.01);
flowVal1=3.3*flowIn; //Logic level 3.3
flowVal2 = 1.5*flowVal1; //5v
P1 =(125*flowVal2)-62.5;
if(flag==0)
{
finalflow=0;
bpArray[o]=P1;
sp+=bpArray[o];
o=o+1;
if (o=9)
{
fp=sp/10;
flag=1;
}
}
if (flag==1)
{
FPressure=P1-fp;
finalflow=(0.24*sqrt(FPressure)); //flow in litter per min
//ttl.printf("Flow: %f\n",finalflow);
return finalflow;
}
}
}
float carbon()
{
bool allow = false;
char c;
char co2_measure[5];
int count=0;
while(1)
{
c = co2.getc();
if(c=='Z') {
allow = true;
}
if(allow) {
if(c>=48 && c<=57) {
co2_measure[count]=c;
count++;
}
if(count>=6) { //NOT SURE IF 5 OR 6
value = ((co2_measure[0]-'0')*100000+co2_measure[1]-'0')*10000+(co2_measure[2]-'0')*1000+(co2_measure[3]-'0')*100;
//ttl.printf("CO2: %d\n",value);
float CAR;
CAR=(float)value/10000;
count=0;
allow=false;
return CAR;
}
}
}
}