asdf
Dependencies: KellerDruck_pressure PID PWM-Coil-driver Sensirion_SF04 VL6180
Fork of TestBenchSerenity-proto_F429ZI by
Diff: main.h
- Revision:
- 0:67debf2ccbc2
- Child:
- 1:d58df8cb271d
diff -r 000000000000 -r 67debf2ccbc2 main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Fri Jul 07 20:52:31 2017 +0000 @@ -0,0 +1,84 @@ +#ifndef MAIN_H +#define MAIN_H + +#include "mbed.h" +#include "keller_pressure.h" +#include "sensirion_sf04.h" +#include "PID.h" +#include "coil-driver.h" + +// Mbed application shield display +#include "C12832A1Z.h" +#include "Small_7.h" +#include "Fonts/ArialR12x14.h" + +C12832A1Z lcd(D11, D13, D12, D7, D10); // MOSI, SCK, Reset, A0, CS +// LCD width and height (minus 1) +#define lcdWidth 127 +#define lcdHeight 31 + +// ISO/SEV pressure: 10psi, DES: 25-30psi +#define pumpSetPointPSI 45 +#define pumpMinPSI 0 +#define pumpMaxPSI 85 +//#define pumpHystPSI 2 + +// Gas flow sensor defines +#define SFM7033_ADDR 0x40 +// End gas flow sensor defines + +// Liquid pump defines +// PID settings +#define pumpPIDRate .2 // Pump PID computation interval (seconds) +float pumpKp = 4.0; +float pumpKi = 1.0; +#define pumpKd 0 + +#define pumpPwmFrequency 1000 // Frequency of PWM signal supplied to pump +#define pumpTachPoles 6 // 6 pulses per revolution +#define pumpTachPin PE_7 // Pump tach input (green wire) +#define pumpCtrlPin PE_10 // Pump control (white wire) +// End Liquid pump defines + +Thread print_process_values_t, update_pressures_t, update_airflow_t, update_lcd_t; +Mutex i2c1_m, i2c2_m, stdio_m; + +//DigitalOut myled(LED2); +Serial pc(USBTX, USBRX, 250000); // tx, rx, baud + +// an I2C sub-class that provides a constructed default +class I2CPreInit : public I2C +{ +public: + I2CPreInit(PinName sda, PinName scl, int freq) : I2C(sda, scl) { + frequency(freq); + }; +}; + +//I2CPreInit gI2C1(I2C_SDA, I2C_SCL, I2C frequency); +I2CPreInit i2c1(PB_9, PB_8, 100000); +I2CPreInit i2c2(PB_11, PB_10, 100000); + +KELLER_PRESSURE pumpPressure(i2c1, 0x40); + +// Sensirion gas flow sensor object (i2c object, i2c address, calibration field, resolution 9-16 bit) +// calibration field 1: Air, 2: O2, 3: N2O +SF04 sfm7033(i2c2, SFM7033_ADDR, 1, 12); // Gas flow sensor (SFM7033) + +// Mbed application shield +AnalogIn pot1(A0); +AnalogIn pot2(A1); + +PwmOut pump(pumpCtrlPin); +//pump.period(.001); + +PID pump_control_PID(pumpKp, pumpKi, pumpKd, pumpPIDRate); + +//InterruptIn pumpTach(pumpTachPin); +volatile int pumpTachCounts = 0; +volatile float pumpRpm = 0; + +PwmOut ledRed(PE_11); +PwmOut ledGrn(PD_15); +DigitalOut ledBlu(PF_12); +#endif \ No newline at end of file