![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: BufferedSerial FastAnalogIn FastPWM mbed SHT75
Diff: controlt.cpp
- Revision:
- 10:c751a0e8b7f9
- Parent:
- 9:6ef12ac2ddc3
--- a/controlt.cpp Thu Mar 31 14:01:49 2016 +0000 +++ b/controlt.cpp Mon Jul 11 01:05:52 2016 +0000 @@ -28,6 +28,10 @@ table_count=0; table_mode=0; + + repeatTime=0; + repeatCount=0; + repeatSide=0; } control_t::~control_t() { @@ -111,8 +115,8 @@ void control_t::refresh_PWM() { write_log(); - time+=3; - printf("\n%1.4f, %1.4f, %1.4f, %1.4f, %2.2f, %d, %d, %d, %2.2f, %2.2f", P_value, I_value, D_value, PWM_value, start_temp, period, time, mode, target_temp, temp_sensor->get_temp()); + time+=10; + printf("\n%1.4f, %d, %d, %d, %d, %d, %d, %d, %2.2f, %2.2f, %2.2f, %2.2f", P_value, time, mode, repeatTime, repeatCount, repeatSide, highTempTime, lowTempTime, highTemp, lowTemp, target_temp, temp_sensor->get_temp()); if(mode==0) { PWM_value=0; @@ -133,6 +137,10 @@ { follow_table(); } + else if(mode==5) + { + repeatPeriod(); + } } int control_t::get_mode() @@ -283,4 +291,38 @@ printf(",remain step: %d",period-step); step++; } -} \ No newline at end of file +} + +void control_t::repeatPeriod() +{ + repeatTime+=10; + if(repeatSide==0) + { + target_temp=lowTemp; + if(repeatTime>lowTempTime) + { + repeatSide=1; + repeatTime=0; + } + } + else + { + target_temp=highTemp; + if(repeatTime>highTempTime) + { + repeatSide=0; + repeatTime=0; + repeatCount++; + if(repeatCount>=periodNumber) + { + repeatSide=0; + repeatTime=0; + repeatCount=0; + mode=0; + } + } + + } + control_temp(); + +} \ No newline at end of file