pressures

Dependencies:   KellerDruck_pressure PID PWM-Coil-driver Sensirion_SF04 VL6180

Fork of HSPFLOW by jack kemnitz

Committer:
iwolf32
Date:
Tue Aug 01 14:48:01 2017 +0000
Revision:
5:8e47d5323647
Parent:
4:79b23d1fbcd1
Child:
7:fb77fbe65357
REV1;

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