![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
LEX_Threaded_Programming
Dependencies: Heater_V2 MODSERIAL Nanopb FastPWM ADS8568_ADC
Diff: main.cpp
- Revision:
- 10:f8202e71e765
- Parent:
- 9:9474da78cec3
- Child:
- 11:7394f281e845
--- a/main.cpp Thu Sep 12 12:43:07 2019 +0000 +++ b/main.cpp Tue Sep 17 15:55:26 2019 +0000 @@ -24,6 +24,15 @@ Timer timer; DigitalIn adc_busy(PA_8); //Busy interrupt sig# +//Pressure Control +DigitalOut pump(PA_0); +float pres_in = 0.0; +float pres_out = 0.0; + +//int pressure_setpoint = 2540; +//int pressure_hysteresis = 48; +//int pressure_setpoint_low = pressure_setpoint - pressure_hysteresis/2; +//int pressure_setpoint_high = pressure_setpoint + pressure_hysteresis/2; //Heater Control FastPWM drive_main(PC_9); @@ -145,7 +154,6 @@ } - void log_trigger() { flags.set(0x2); @@ -153,19 +161,18 @@ void pressure_control() { - //Input pressure control function here - //i.e. - //read_pressure(); - //if (pressure < lower_bound) { - //pump_turn_on(); - //} - //else if (pressure > upper_bound) { - //pump_turn_off(); - //} +// if (pressure < pressure_setpoint_low) { +// pump = 1; +// valve_pres = 1; +// } +// else if (pressure > pressure_setpoint_high) { +// pump = 0; +// valve_pres = 0; +// } led_1 = !led_1; -} + pump = !pump; - +} //Other functions__________________________________________________________________ @@ -184,7 +191,7 @@ while(1){ flags.wait_any(0x2,osWaitForever,true); //Output time, R_ref, R, error, error_integrated - pc.printf("%10d,%10d,%10.6f,%10.6f\n", heater_ID, timer.read_ms(), heater->Get_R(), heater->Get_R_ref()); + pc.printf("%10d,%10d,%10.6f,%10.6f,%10.6f,%10.6f\n", heater_ID, timer.read_ms(), heater->Get_R(), heater->Get_R_ref(), pres_in, pres_out); } } @@ -211,14 +218,14 @@ wait_us(10); camTrigger = 1; led_0 = 1; - ledDrive.pulsewidth_ticks(LED_PULSE_WIDTH); + // ledDrive.pulsewidth_ticks(LED_PULSE_WIDTH); triggered_flag = true; } wait_us(200); } //Stop camera exposure and turn off LED at end of time segment camTrigger = 0; - ledDrive.pulsewidth_ticks(0); + // ledDrive.pulsewidth_ticks(0); led_0 = 0; } } @@ -277,8 +284,8 @@ logging_thread.start(& log_state); log_tick.attach_us(& log_trigger,exp_config.logging_interval_ms * 1000); - pc.printf("# Starting routine\n"); - pc.printf("# heater, time(ms), r, rSet\n"); + pc.printf("# Starting routine...\n"); + pc.printf("# heater, time(ms), r, rSet, pres_in, pres_out\n"); timer.start(); set_point_routine(profile);