Dependencies: KellerDruck_pressure PID PWM-Coil-driver Sensirion_SF04 VL6180
Fork of TestBenchSerenity-proto_F429ZI1 by
Revision 8:bf86306ce7bf, committed 2017-09-05
- Comitter:
- iwolf32
- Date:
- Tue Sep 05 19:27:50 2017 +0000
- Parent:
- 7:b385e6a3f622
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Aug 03 19:07:43 2017 +0000 +++ b/main.cpp Tue Sep 05 19:27:50 2017 +0000 @@ -1,35 +1,5 @@ #include "main.h" //--------------------------- -void dutycycleincrease() -{ - dutycycle=dutycycle+0.01; -} - -void dutycycledecrease() -{ - dutycycle=dutycycle-0.01; -} - -void frequencyincrease() -{ - frequency=frequency+1; -} -void frequencydecrease() -{ - frequency=frequency-1; -} -void injectorvalvecontrol(){ - -while(true){ -float openvalue=(((1/frequency)*dutycycle)); -float offvalue=(1/frequency)-openvalue; - -injector.on(); -wait(openvalue); -injector.off(); -wait(offvalue); -} -} //----------------------------- void pumpTachTrigger() @@ -96,36 +66,6 @@ } } -/*void update_flow1() -{ - Timer timer; - timer.start(); - char error; - while (true) { - i2c2_m.lock(); - timer.reset(); - error = mainflow.Measure(FLOW); - int wait = (200 - timer.read_ms()); - i2c2_m.unlock(); - Thread::wait(wait); - } -} - -//------------------------------------------------ -void update_flow2() -{ - Timer timer; - timer.start(); - char error; - while (true) { - i2c3_m.lock(); - timer.reset(); - error = loopflow.Measure(FLOW); - int wait = (200 - timer.read_ms()); - i2c3_m.unlock(); - Thread::wait(wait); - } -}*/ //------------------------------------------------ void print_process_values() @@ -137,9 +77,8 @@ stdio_m.lock(); timer.reset(); - pc.printf(" %.02fprespsi %.01fsetpsi %.0fRPM %.02fHz %.02f\r\n", - pumpPressure.pressurePSI, ((double)pot2-.002)*pumpMaxPSI, pumpRpm, - frequency, dutycycle);//, agentlevel; + pc.printf(" %.02f\t %.01f\t %.0f\r\n", + pumpPressure.pressurePSI, ((double)pot2-.002)*pumpMaxPSI, pumpRpm); int wait = (1000 - timer.read_ms()); stdio_m.unlock(); @@ -155,16 +94,10 @@ //ledBlu = 1; pc.printf("Serenity Starting up...\n\r"); //-------------------------------------------- -dutycycleup.rise(&dutycycleincrease); -dutycycledown.rise(&dutycycledecrease); -frequencyup.rise(&frequencyincrease); -frequencydown.rise(&frequencydecrease); + pumpTach.rise(&pumpTachTrigger); pump_tach_ticker.attach(&pump_tach_update, 1.0); - //Thread to execute injector valve control - Injector_Valve_Control.set_priority(osPriorityHigh); - Injector_Valve_Control.start(injectorvalvecontrol); //-------------------------------------------- // Thread to poll pressure sensors