Dependencies:   KellerDruck_pressure PID PWM-Coil-driver Sensirion_SF04 VL6180

Fork of HSPFLOWFINAL by jack kemnitz

Committer:
212600191
Date:
Wed Aug 16 13:50:56 2017 +0000
Revision:
8:72b6c4a5320a
Parent:
7:fb77fbe65357
pressure;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dmwahl 0:67debf2ccbc2 1 #ifndef MAIN_H
dmwahl 0:67debf2ccbc2 2 #define MAIN_H
dmwahl 0:67debf2ccbc2 3
dmwahl 0:67debf2ccbc2 4 #include "mbed.h"
dmwahl 0:67debf2ccbc2 5 #include "keller_pressure.h"
dmwahl 0:67debf2ccbc2 6 #include "sensirion_sf04.h"
dmwahl 0:67debf2ccbc2 7 #include "PID.h"
dmwahl 0:67debf2ccbc2 8 #include "coil-driver.h"
dmwahl 1:d58df8cb271d 9 #include "VL6180.h"
dmwahl 1:d58df8cb271d 10
iwolf32 5:8e47d5323647 11 //Timer From Start of the Script
iwolf32 5:8e47d5323647 12 Timer t1;
iwolf32 5:8e47d5323647 13 float t;
iwolf32 4:79b23d1fbcd1 14
iwolf32 5:8e47d5323647 15 //High Speed Pressure
iwolf32 5:8e47d5323647 16 AnalogIn analog_value(A3);
iwolf32 5:8e47d5323647 17 Thread HighSpeedPressure;
212600191 7:fb77fbe65357 18
212600191 7:fb77fbe65357 19 float High_Speed_Pressure_Calibrated;
dmwahl 0:67debf2ccbc2 20
dmwahl 0:67debf2ccbc2 21 // Mbed application shield display
dmwahl 0:67debf2ccbc2 22 #include "C12832A1Z.h"
dmwahl 0:67debf2ccbc2 23 #include "Small_7.h"
dmwahl 0:67debf2ccbc2 24 #include "Fonts/ArialR12x14.h"
dmwahl 0:67debf2ccbc2 25
iwolf32 5:8e47d5323647 26 //C12832A1Z lcd(D11, D13, D12, D7, D10); // MOSI, SCK, Reset, A0, CS
dmwahl 0:67debf2ccbc2 27 // LCD width and height (minus 1)
dmwahl 0:67debf2ccbc2 28 #define lcdWidth 127
dmwahl 0:67debf2ccbc2 29 #define lcdHeight 31
dmwahl 0:67debf2ccbc2 30
dmwahl 0:67debf2ccbc2 31 // ISO/SEV pressure: 10psi, DES: 25-30psi
dmwahl 0:67debf2ccbc2 32 #define pumpSetPointPSI 45
dmwahl 0:67debf2ccbc2 33 #define pumpMinPSI 0
dmwahl 0:67debf2ccbc2 34 #define pumpMaxPSI 85
dmwahl 0:67debf2ccbc2 35 //#define pumpHystPSI 2
dmwahl 0:67debf2ccbc2 36
dmwahl 0:67debf2ccbc2 37 // Gas flow sensor defines
iwolf32 5:8e47d5323647 38 #define MAINFLOW_ADDR 0x40
iwolf32 5:8e47d5323647 39 #define LOOPFLOW_ADDR 0x40
dmwahl 0:67debf2ccbc2 40 // End gas flow sensor defines
dmwahl 0:67debf2ccbc2 41
dmwahl 0:67debf2ccbc2 42 // Liquid pump defines
dmwahl 0:67debf2ccbc2 43 // PID settings
dmwahl 0:67debf2ccbc2 44 #define pumpPIDRate .2 // Pump PID computation interval (seconds)
dmwahl 0:67debf2ccbc2 45 float pumpKp = 4.0;
dmwahl 0:67debf2ccbc2 46 float pumpKi = 1.0;
dmwahl 0:67debf2ccbc2 47 #define pumpKd 0
dmwahl 0:67debf2ccbc2 48 #define pumpPwmFrequency 1000 // Frequency of PWM signal supplied to pump
dmwahl 0:67debf2ccbc2 49 #define pumpTachPoles 6 // 6 pulses per revolution
iwolf32 5:8e47d5323647 50 #define pumpTachPin PA_10 // Pump tach input (green wire)
iwolf32 4:79b23d1fbcd1 51 #define pumpCtrlPin PB_13 // Pump control (white wire)
dmwahl 0:67debf2ccbc2 52 // End Liquid pump defines
dmwahl 0:67debf2ccbc2 53
iwolf32 5:8e47d5323647 54 Thread print_process_values_t, update_pressures_t, update_flow1_t, update_flow2_t, update_shutoff_t;
iwolf32 4:79b23d1fbcd1 55 Mutex i2c1_m, i2c2_m, i2c3_m, stdio_m;
dmwahl 0:67debf2ccbc2 56
dmwahl 0:67debf2ccbc2 57 Serial pc(USBTX, USBRX, 250000); // tx, rx, baud
dmwahl 0:67debf2ccbc2 58
dmwahl 0:67debf2ccbc2 59 // an I2C sub-class that provides a constructed default
dmwahl 0:67debf2ccbc2 60 class I2CPreInit : public I2C
dmwahl 0:67debf2ccbc2 61 {
dmwahl 0:67debf2ccbc2 62 public:
dmwahl 0:67debf2ccbc2 63 I2CPreInit(PinName sda, PinName scl, int freq) : I2C(sda, scl) {
dmwahl 0:67debf2ccbc2 64 frequency(freq);
dmwahl 0:67debf2ccbc2 65 };
dmwahl 0:67debf2ccbc2 66 };
dmwahl 0:67debf2ccbc2 67
dmwahl 0:67debf2ccbc2 68 //I2CPreInit gI2C1(I2C_SDA, I2C_SCL, I2C frequency);
iwolf32 5:8e47d5323647 69 I2CPreInit i2c1(PB_3, PB_10, 100000);
dmwahl 0:67debf2ccbc2 70
dmwahl 0:67debf2ccbc2 71 // Sensirion gas flow sensor object (i2c object, i2c address, calibration field, resolution 9-16 bit)
iwolf32 5:8e47d5323647 72 SF04 mainflow(i2c1, MAINFLOW_ADDR, 0, 16);
dmwahl 0:67debf2ccbc2 73 // Mbed application shield
dmwahl 0:67debf2ccbc2 74 AnalogIn pot2(A1);
dmwahl 0:67debf2ccbc2 75 PwmOut pump(pumpCtrlPin);
dmwahl 0:67debf2ccbc2 76
dmwahl 0:67debf2ccbc2 77 PID pump_control_PID(pumpKp, pumpKi, pumpKd, pumpPIDRate);
dmwahl 0:67debf2ccbc2 78
iwolf32 5:8e47d5323647 79 VL6180 level(i2c1); //I2C object
iwolf32 5:8e47d5323647 80 float agentlevel = 0;
dmwahl 0:67debf2ccbc2 81 #endif