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
main.cpp@1:00fe5bf692b4, 2020-06-06 (annotated)
- Committer:
- christodoulos
- Date:
- Sat Jun 06 17:00:06 2020 +0000
- Revision:
- 1:00fe5bf692b4
- Parent:
- 0:d034cdad5b6d
- Child:
- 2:322470aeeae9
Flow calibration
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| christodoulos | 0:d034cdad5b6d | 1 | #include "mbed.h" |
| christodoulos | 0:d034cdad5b6d | 2 | |
| christodoulos | 1:00fe5bf692b4 | 3 | Serial ttl(PC_12,PD_2); |
| christodoulos | 1:00fe5bf692b4 | 4 | AnalogIn flowIn(PA_1); |
| christodoulos | 0:d034cdad5b6d | 5 | |
| christodoulos | 0:d034cdad5b6d | 6 | float flowVal1; |
| christodoulos | 0:d034cdad5b6d | 7 | float flowVal2; |
| christodoulos | 0:d034cdad5b6d | 8 | float Pressure; |
| christodoulos | 1:00fe5bf692b4 | 9 | |
| christodoulos | 0:d034cdad5b6d | 10 | float finalflow; |
| christodoulos | 1:00fe5bf692b4 | 11 | float flow(){ |
| christodoulos | 0:d034cdad5b6d | 12 | flowVal1=3.3*flowIn; //Logic level 3.3 |
| christodoulos | 0:d034cdad5b6d | 13 | flowVal2 = 1.5*flowVal1; //5v |
| christodoulos | 0:d034cdad5b6d | 14 | Pressure =(125*flowVal2)-62.5; |
| christodoulos | 1:00fe5bf692b4 | 15 | //finalflow=(0.3425*sqrt(Pressure))-0.198; //flow in litter per min |
| christodoulos | 1:00fe5bf692b4 | 16 | //finalflow= (-6.12e-5)*(Pressure)*(Pressure) + (2.98e-2)*Pressure - 8.83e-2; |
| christodoulos | 1:00fe5bf692b4 | 17 | return Pressure; |
| christodoulos | 0:d034cdad5b6d | 18 | } |
| christodoulos | 0:d034cdad5b6d | 19 | |
| christodoulos | 0:d034cdad5b6d | 20 | int main(){ |
| christodoulos | 1:00fe5bf692b4 | 21 | ttl.baud(115200); |
| christodoulos | 1:00fe5bf692b4 | 22 | |
| christodoulos | 1:00fe5bf692b4 | 23 | ttl.printf("$");//enter command mode only for rn |
| christodoulos | 1:00fe5bf692b4 | 24 | wait(0.1); |
| christodoulos | 1:00fe5bf692b4 | 25 | ttl.printf("$$");//enter command mode |
| christodoulos | 1:00fe5bf692b4 | 26 | wait(0.5); |
| christodoulos | 1:00fe5bf692b4 | 27 | ttl.printf("SN,Flow Calibration\r");//set new name |
| christodoulos | 1:00fe5bf692b4 | 28 | wait(0.5); |
| christodoulos | 1:00fe5bf692b4 | 29 | ttl.printf("SS,C0\r");//set transparent uart |
| christodoulos | 1:00fe5bf692b4 | 30 | wait(0.5); |
| christodoulos | 1:00fe5bf692b4 | 31 | ttl.printf("---\r");//enter data mode |
| christodoulos | 1:00fe5bf692b4 | 32 | wait(0.5); |
| christodoulos | 1:00fe5bf692b4 | 33 | |
| christodoulos | 0:d034cdad5b6d | 34 | while(1){ |
| christodoulos | 1:00fe5bf692b4 | 35 | ttl.printf("%f\n", flow()); |
| christodoulos | 1:00fe5bf692b4 | 36 | wait(0.1); |
| christodoulos | 0:d034cdad5b6d | 37 | } |
| christodoulos | 0:d034cdad5b6d | 38 | |
| christodoulos | 0:d034cdad5b6d | 39 | } |