asdf

Dependencies:   KellerDruck_pressure PID PWM-Coil-driver Sensirion_SF04 VL6180

Fork of TestBenchSerenity-proto_F429ZI by Ian Wolf

Revision:
4:79b23d1fbcd1
Parent:
3:9ff79ea3a294
Child:
5:e3eff8a04b25
--- a/main.h	Mon Jul 24 15:38:39 2017 +0000
+++ b/main.h	Wed Jul 26 14:03:10 2017 +0000
@@ -7,9 +7,25 @@
 #include "PID.h"
 #include "coil-driver.h"
 #include "VL6180.h"
+/*Start of Where Additional Code was Added
+--------------------------------------------------------------------------------------------------*/
+//Coil shutoff(A1, 5000, 40, 6); // Shutoff valve, 5ms spike time, 25kHz PWM at 15% duty cycle
+Coil injector(A0, 200, 40, 3); // Injector valve, 200us spike time, 25kHz PWM at 7.5% duty cycle
 
-Coil shutoff(PE_5, 5000, 40, 6); // Shutoff valve, 5ms spike time, 25kHz PWM at 15% duty cycle
-Coil injector(PF_8, 200, 40, 3); // Injector valve, 200us spike time, 25kHz PWM at 7.5% duty cycle
+InterruptIn dutycycleup(A2);
+InterruptIn dutycycledown(D4);
+InterruptIn frequencyup(A5);
+InterruptIn frequencydown(A4);
+
+Thread Injector_Valve_Control;
+
+double frequency=5.00;
+double dutycycle=0.75;
+float openvalue=(((1/frequency)*dutycycle));
+float offvalue=(1/frequency)-openvalue;
+
+/*
+--------------------------------------------------------------------------------------------------*/
 
 
 // Mbed application shield display
@@ -30,6 +46,7 @@
 
 // Gas flow sensor defines
 #define SFM7033_ADDR 0x40
+#define SFM7034_ADDR 0x40
 // End gas flow sensor defines
 
 // Liquid pump defines
@@ -41,12 +58,12 @@
 
 #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)
+#define pumpTachPin PB_15 // Pump tach input (green wire)
+#define pumpCtrlPin PB_13 // Pump control (white wire)
 // End Liquid pump defines
 
-Thread print_process_values_t, update_pressures_t, update_airflow_t, update_level_t, update_lcd_t, update_shutoff_t;
-Mutex i2c1_m, i2c2_m, stdio_m;
+Thread print_process_values_t, update_pressures_t, update_flow1_t, update_flow2_t, update_level_t, update_lcd_t, update_shutoff_t;
+Mutex i2c1_m, i2c2_m, i2c3_m, stdio_m;
 
 //DigitalOut myled(LED2);
 Serial pc(USBTX, USBRX, 250000); // tx, rx, baud
@@ -62,19 +79,17 @@
 
 //I2CPreInit gI2C1(I2C_SDA, I2C_SCL, I2C frequency);
 I2CPreInit i2c1(PB_9, PB_8, 100000);
-I2CPreInit i2c2(PB_11, PB_10, 100000);
+I2CPreInit i2c2(PB_3, PB_10, 100000);
+I2CPreInit i2c3(PB_4, PA_8, 100000);
 
 KELLER_PRESSURE pumpPressure(i2c1, 0x40);
-KELLER_PRESSURE mixerPressure(i2c1, 0x41);
-
-
 
 // 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, 14); // Gas flow sensor (SFM7033)
-
+SF04 mainflow(i2c2, SFM7033_ADDR, 0, 9); // Gas flow sensor (SFM7033)
+SF04 loopflow(i2c3, SFM7034_ADDR, 0, 9);
 // Mbed application shield
-AnalogIn pot1(A0);
+//AnalogIn pot1(A0);
 AnalogIn pot2(A1);
 
 PwmOut pump(pumpCtrlPin);
@@ -86,11 +101,11 @@
 volatile int pumpTachCounts = 0;
 volatile float pumpRpm = 0;
 
-PwmOut ledRed(PE_11);
-PwmOut ledGrn(PD_15);
-DigitalOut ledBlu(PF_12);
+//PwmOut ledRed(PE_11);
+//PwmOut ledGrn(PD_15);
+//DigitalOut ledBlu(PF_12);
 
 // Level sensor
-VL6180 level(i2c1); //I2C object
-float agentlevel = 0;
+//VL6180 level(i2c1); //I2C object
+//float agentlevel = 0;
 #endif
\ No newline at end of file