dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Files at this revision

API Documentation at this revision

Comitter:
sbh9428
Date:
Fri Mar 25 09:28:09 2016 +0000
Parent:
5:8e3b5ccf7207
Child:
7:851659cf185c
Commit message:
fin

Changed in this revision

controlt.cpp Show annotated file Show diff for this revision Revisions of this file
controlt.h Show annotated file Show diff for this revision Revisions of this file
--- a/controlt.cpp	Fri Mar 25 08:58:51 2016 +0000
+++ b/controlt.cpp	Fri Mar 25 09:28:09 2016 +0000
@@ -15,6 +15,7 @@
 control_t::control_t(temp_sensor_t* _temp_sensor, peltier_t* _peltier,BufferedSerial *_pc)
 {
 	log_count=0;
+	time=0;
 	
 	target_temp=15;
 	P_value=0;
@@ -66,7 +67,10 @@
 {
 	mode=_mode;	
 	if(mode==4)
-	start_temp=temp_sensor->get_temp();
+	{
+		start_temp=temp_sensor->get_temp();
+		time=0;
+	}
 }
 
 void control_t::set_PWM_value(float _PWM_value)
@@ -107,7 +111,8 @@
 void control_t::refresh_PWM()
 {
 	write_log();
-	printf("%f, %f, %f, %1.4f, %2.2f, %d, %d, %d, %d, %2.2f, %2.2f\n", P_value, I_value, D_value, PWM_value, start_temp, period, time, mode, target_temp, temp_sensor->get_temp());
+	time+=3;
+	printf("\n%f, %f, %f, %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());
 	if(mode==0)
 	{
 		PWM_value=0;
@@ -205,11 +210,12 @@
 	{
 		peltier->set_PWM(-1);
 		table_count++;
-		pc->printf("set initial temp %d/30\n", table_count);
+		pc->printf(",set initial temp %d/30", table_count);
 		if(table_count>29)
 		{
 			table_mode=1;	
 			table_count=0;
+			time=0;
 		}
 
 	}
@@ -226,7 +232,7 @@
 			table_min=table[0];
 			table_max=table[199];
 		}
-		pc->printf("build table %d/200", table_count);
+		pc->printf(",build table %d/200", table_count);
 	}
 }
 
@@ -235,7 +241,7 @@
 	int i;
 	for(i=0;i<201;i++)
 	{
-		pc->printf("%d/200 PWM: %1.3f, temp:%2.2f\n",i, (-1+0.005*i), table[i]); 	
+		pc->printf(",%d/200 PWM: %1.3f, temp:%2.2f",i, (-1+0.005*i), table[i]); 	
 		wait_us(2000);
 	}
 }
@@ -257,16 +263,16 @@
 	if(table_check!=1)
 	{
 		mode=0;
-		pc->printf("table not built\n");	
+		pc->printf(",table not built\n");	
 	}	
 	else if(target_temp>table_max|target_temp<table_min)
 	{
 		mode=0;
-		pc->printf("target temp out of range\n");	
+		pc->printf(",target temp out of range");	
 	}
 	else if(period<=step)
 	{
-		pc->printf("table follow end\n");
+		pc->printf(",table follow end");
 		step=0;
 		mode=2;
 	}
@@ -274,7 +280,7 @@
 	{
 		PWM_value=find_table(target_temp/period*step+start_temp/period*(period-step));
 		peltier->set_PWM(PWM_value);
-		printf("remain step: %d,",period-step);
+		printf(",remain step: %d",period-step);
 		step++;
 	}
 }	
\ No newline at end of file
--- a/controlt.h	Fri Mar 25 08:58:51 2016 +0000
+++ b/controlt.h	Fri Mar 25 09:28:09 2016 +0000
@@ -66,6 +66,8 @@
 	float PWM_log[10];
 	int log_count;
 	
+	int time;
+	
 	float table[201];
 	int table_count;
 	int table_mode;