Index: applications/pmsm/pmsm_ctrl.h
===================================================================
--- applications/pmsm/pmsm_ctrl.h (revision 1259)
+++ applications/pmsm/pmsm_ctrl.h (revision 1261)
@@ -63,5 +63,5 @@
 	PMSMCtrl():Controller()	{
 		rv = RV("{ua ub }");
-		rvc = RV("{o_ia o_ib o_ua o_ub o_om o_th Ww }");
+		rvc = RV("{o_ia o_ib t_ua t_ub o_om o_th Ww }");
 	}
 	
@@ -176,5 +176,5 @@
 	
 //receding horizon
-	const int rec_hor;
+	int rec_hor;
 	
 //system matrices
@@ -202,7 +202,5 @@
 				r(0.005), Dt(0.000125), rec_hor(10), 					//for r is a default value rewrited by pcp.txt file value
 				A(5, 5), B(5, 2), Q(5, 5), R(2, 2),
-				uab(2), icond(6), MAXu(100.0),
-				p_isa(rec_hor+1), p_isb(rec_hor+1), p_ome(rec_hor+1), p_the(rec_hor+1)
-	{			
+				uab(2), icond(6), MAXu(100.0)	{			
 		//set fix matrices elements & dimensions
 		A.zeros();
@@ -219,44 +217,5 @@
 			Q(2, 2) = 1.0;
 		R.zeros();
-			//load input penalty r from file
-			ifstream pcpfile;
-			double pcp;
-			
-			pcpfile.open("pcp.txt");
-			if(pcpfile){
-				if(pcpfile >> pcp) r = pcp;	
-				pcpfile.close();
-			}
-			R(0, 0) = R(1, 1) = r;
 								
-		//set lq
-		lq.rv = RV("u", 2, 0);			
-		lq.set_rvc(RV("x", 5, 0));
-		lq.horizon = rec_hor;	
-		
-		Array<linfnEx> model(2);
-		model(0).A = A;
-		model(0).B = vec("0 0 0 0 0");
-		model(0).rv = RV("x", 5, 0);
-		model(0).rv_ret = RV("x", 5, 1);
-		model(1).A = B;
-		model(1).B = vec("0 0");
-		model(1).rv = RV("u", 2, 0);
-		model(1).rv_ret = RV("x", 5, 1);
-		lq.Models = model;
-		
-		Array<quadraticfn> qloss(2);
-		qloss(0).Q.setCh(Q);
-		qloss(0).rv = RV("x", 5, 1);
-		qloss(1).Q.setCh(R);
-		qloss(1).rv = RV("u", 2, 0);		
-		lq.Losses = qloss;
-		
-		lq.finalLoss.Q.setCh(Q);
-		lq.finalLoss.rv = RV("x", 5, 1);
-		
-		lq.validate();
-						
-		uab.zeros();
 	}
 		
@@ -309,5 +268,5 @@
 		icond(3) = the;
 		icond(4) = Ww;
-		icond(5) = 0;
+		icond(5) = 1;
 		vec tmp = L*icond;		    
 		
@@ -321,4 +280,49 @@
 		return uab;
 	};
+	void from_setting(const Setting &set){
+		PMSMCtrl::from_setting(set);
+		UI::get(r,set, "r", UI::optional);
+		UI::get(rec_hor,set, "h", UI::optional);
+	}
+
+	void validate(){
+		R(0,0)=R(1,1)=r;
+
+		p_isa.set_length(rec_hor+1);
+		p_isb.set_length(rec_hor+1);
+		p_ome.set_length(rec_hor+1);
+		p_the.set_length(rec_hor+1);
+
+		Array<quadraticfn> qloss(2);
+		qloss(0).Q.setCh(Q);
+		qloss(0).rv = RV("x", 5, 1);
+		qloss(1).Q.setCh(R);
+		qloss(1).rv = RV("u", 2, 0);		
+		lq.Losses = qloss;		
+
+				//set lq
+		lq.rv = RV("u", 2, 0);			
+		lq.set_rvc(RV("x", 5, 0));
+		lq.horizon = rec_hor;	
+		
+		Array<linfnEx> model(2);
+		model(0).A = A;
+		model(0).B = vec("0 0 0 0 0");
+		model(0).rv = RV("x", 5, 0);
+		model(0).rv_ret = RV("x", 5, 1);
+		model(1).A = B;
+		model(1).B = vec("0 0");
+		model(1).rv = RV("u", 2, 0);
+		model(1).rv_ret = RV("x", 5, 1);
+		lq.Models = model;
+		
+		lq.finalLoss.Q.setCh(Q);
+		lq.finalLoss.rv = RV("x", 5, 1);
+		
+		lq.validate();
+						
+		uab.zeros();
+
+	}
 };
 UIREGISTER(PMSM_LQCtrl);
Index: applications/pmsm/experiments/ctrl_lq.cfg
===================================================================
--- applications/pmsm/experiments/ctrl_lq.cfg (revision 1258)
+++ applications/pmsm/experiments/ctrl_lq.cfg (revision 1261)
@@ -7,7 +7,7 @@
 system= {
 	class= "pmsmDSctrl";
-	params = "pmsm107@./cfg/zcu.cfg";
+	params = "pmsm107@../cfg/zcu.cfg";
 	tstep = 1; // steps for profile in [s]
-	profileW = [0, 30, 0, 2 ];
+	profileW = [0, 10, 0, 2 ];
 //	profileW = [0, -10, 30, 60, 90, 60, 30, 0, -30, -60, -30];
 //	profileW = [1, 10, 50, 200, 200, 30, 0, 0, -30, -30, -100, -100, -40, 0, 0];
@@ -16,13 +16,13 @@
 };
 
-UD = {class="EKFCh";
+UD = {class="EKFfull";
 	 IM = {class="IMpmsmStat";
-		params = "pmsm107@./cfg/zcu.cfg";
+		params = "pmsm107@../cfg/zcu.cfg";
 	 };
 	 OM = {class="OMpmsm";};
-	dQ=[0.01, 0.01, 0.0001, 0.000001];
+	dQ=[0.1, 0.1, 0.1, 0.01]; ///???????????????
 	dR=[0.05, 0.05];
 	 //connect
-	 log_level="logmean,logU,logG,logD";
+	 log_level="logmean";
 	 name = "Est0";
 	 };
@@ -31,4 +31,6 @@
 		class = "PMSM_LQCtrl";
 		estim = "UD";
+		r = 0.05;
+		h = 10;
 	}
 );
