Index: /applications/pmsm/Barcelona/Mz.m
===================================================================
--- /applications/pmsm/Barcelona/Mz.m (revision 346)
+++ /applications/pmsm/Barcelona/Mz.m (revision 346)
@@ -0,0 +1,37 @@
+% script for estimation of Mz
+addpath ~/work/git/mixpp/library/mex/
+addpath ~/work/git/mixpp/applications/pmsm/
+
+dQ=[0.017, 0.017, 0.00000004, 1e-14, 1e-3];
+dR=[0.025, 0.025];
+
+% experiment
+S.experiment.ndat = 32000;
+
+Orv.type  = 'rv';
+Orv.names = { 'X' };
+Orv.sizes = [ 4 ];
+
+Oekf.type = 'rv';
+
+S.system= struct('type', 'ITppFileDS',...
+    'filename','tec0013ALL.it',...
+    'varname','D',...
+    'rv', Orv);
+
+S.estimator = {struct('type','EKF',...
+	 'IM', struct('type','pmsmIM',...
+		'params', struct('type', 'external', 'filename', '../cfg/zcu.cfg','path' ,'pmsm107'),...
+        'variant', 'Mz'),...
+	 'OM', struct('type','pmsmOM'),...
+	 'dQ',dQ,...
+	 'dR',dR,...
+	 'dP0',[1., 1., 1., 10., 1e-10],...
+    'drv', Orv,...
+    'rv', struct('type','rv', 'names', {{'EKFMz'}},'sizes',[5]),...
+	 'options','logll,logbounds')};
+	
+%S.logger= struct(	'type','mexlog','maxlen',32000);
+S.logger= struct(	'type','dirfilelog','maxlen',32000,'dirname','t2');
+
+%pmsm_estim_mex(S)
Index: /applications/pmsm/Barcelona/real.cfg
===================================================================
--- /applications/pmsm/Barcelona/real.cfg (revision 346)
+++ /applications/pmsm/Barcelona/real.cfg (revision 346)
@@ -0,0 +1,37 @@
+// settings for pmsm_estim.cpp
+
+experiment={
+	ndat = 32000;
+};
+
+system= {
+	type = "ITppFileDS";
+	filename = "tec0013ALL.it";
+	varname="D";
+	rv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+};
+
+estimator = (
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Mz";
+	 };
+	 OM = {type="pmsmOM";};
+//	 dQ=[0.017, 0.017, 0.00000004, 1e-14, 1e-30];
+	 dQ=[0.017, 0.017, 0.00000007, 1e-14, 1e-3];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 10., 1e-10];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["EKFMz"]; sizes=[5];};
+	 options="logll,logbounds";
+	 }
+);
+	
+logger= {
+	type="itpplog";
+	maxlen = 32000;
+	filename = "real.it";
+};
Index: /applications/pmsm/Barcelona/Mz_mx.m
===================================================================
--- /applications/pmsm/Barcelona/Mz_mx.m (revision 346)
+++ /applications/pmsm/Barcelona/Mz_mx.m (revision 346)
@@ -0,0 +1,11 @@
+M=pmsm_estim_mex('Mz_mx.cfg');
+
+figure(1)
+subplot(2,1,1);
+plot(M.x(:,3));
+
+subplot(2,1,2);
+hold off
+plot(M.crbz(:,4));
+hold on
+plot(M.crb(:,4),'r');
Index: /applications/pmsm/Barcelona/real_mx.cfg
===================================================================
--- /applications/pmsm/Barcelona/real_mx.cfg (revision 346)
+++ /applications/pmsm/Barcelona/real_mx.cfg (revision 346)
@@ -0,0 +1,50 @@
+// settings for pmsm_estim.cpp
+
+experiment={
+	ndat = 32000;
+};
+
+system= {
+	type = "ITppFileDS";
+	filename = "tec0013ALL.it";
+	varname="D";
+	rv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+};
+
+estimator = (
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Mz";
+	 };
+	 OM = {type="pmsmOM";};
+//	 dQ=[0.017, 0.017, 0.00000004, 1e-14, 1e-30];
+	 dQ=[0.017, 0.017, 0.00000007, 1e-14, 1e-3];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 10., 1e-10];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 rv = {type="rv"; names=["EKFMz"]; sizes=[5];};
+	 options="logll,logbounds";
+	 },
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Stat";
+	 };
+	 OM = {type="pmsmOM";};
+//	 dQ=[0.017, 0.017, 0.00000004, 1e-14, 1e-30];
+	 dQ=[0.017, 0.017, 1.0, 1e-8];
+	 dR=[0.025, 0.025];
+	 dP0=[1., 1., 1., 10.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 rv = {type="rv"; names=["EKF"]; sizes=[4];};
+	 options="logll,logbounds";
+	 }
+);
+	
+logger= {
+	type="mexlog";
+	maxlen = 31999;
+};
Index: /applications/pmsm/Barcelona/Mz_mx.cfg
===================================================================
--- /applications/pmsm/Barcelona/Mz_mx.cfg (revision 346)
+++ /applications/pmsm/Barcelona/Mz_mx.cfg (revision 346)
@@ -0,0 +1,79 @@
+// settings for pmsm_estim.cpp
+
+experiment={
+	ndat = 120000;
+};
+
+system= {
+	type = "pmsmDS";
+	params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+	tstep = 1.0; // steps for profile in [s]
+	profileW = [0, 1, 5, 10, 10, 3, 0, 0, -3, -3, -10, -10, -4, 0, 0];
+	profileM = [0, 10, 0, 0, 10, 0, 0, 0, 0, 0, 10, 0, 0];
+	options = "modelu";
+};
+
+estimator = (
+	 {type="EKF";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Mz";
+	 };
+	 OM = {type="pmsmOM";};
+/*	 dQ : 
+	{
+	elements = [ 0.001738643873, 0.001738643873, 1.00000004, 1.562501e-08, 1 ];
+	cols = 4;
+	};*/
+	dQ=[0.0017, 0.0017, 0.00000004, 1e-14, 1e-1];
+	 dR=[0.025, 0.025];
+	 dP0=[0., 0., 0., 0., 0.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","o_ua","o_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["EKFMz"]; sizes=[5];};
+	 options="logll,logbounds";
+	 },
+				 //
+				 				 //
+	 {type="pmsmCRBMz";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "Mz";
+	 };
+	 OM = {type="pmsmOM";};
+	dQ=[0.0017, 0.0017, 0.00000004, 1e-14, 1e-1];
+//	 dQ=[0.017, 0.017, .1, 1e-6];//[0.017, 0.017, 100., 1e-4];
+	 dR=[0.025, 0.025];
+	 dP0=[0., 0., 0., 0., 0.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["CRB"]; sizes=[5];};
+	 options="logll,logbounds";
+	 },
+
+	 {type="pmsmCRB";
+	 IM = {type="pmsmIM";
+		params = {type = "external";filename = "../cfg/zcu.cfg";path = "pmsm107";};
+		variant = "2o";
+	 };
+	 OM = {type="pmsmOM";};
+	dQ=[0.0017, 0.0017, 1.00000004, 1e-8];
+//	 dQ=[0.017, 0.017, .1, 1e-6];//[0.017, 0.017, 100., 1e-4];
+	 dR=[0.025, 0.025];
+	 dP0=[0., 0., 0., 0., 0.];
+	 //connect
+	 drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];};  // observed u
+	 //drv = {type="rv"; names=["o_ia","o_ib","t_ua","t_ub"];}; // true u
+	 rv = {type="rv"; names=["CRB2"]; sizes=[4];};
+	 options="logll,logbounds";
+	 }
+
+
+);
+	
+logger= {
+	type="mexlog";
+	maxlen = 119999;
+};
Index: /applications/pmsm/Barcelona/real_pmsm.m
===================================================================
--- /applications/pmsm/Barcelona/real_pmsm.m (revision 346)
+++ /applications/pmsm/Barcelona/real_pmsm.m (revision 346)
@@ -0,0 +1,26 @@
+M=pmsm_estim_mex('real_mx.cfg');
+
+ids = [1:size(M.EKFMz_mean,1)];
+kftime=[ids-ids(1)]*0.000125;
+
+figure(1);
+subplot(2,1,1);
+hold off
+plot(kftime,M.EKFMz_mean(ids,3)/2/pi);
+hold on
+plot(kftime,M.EKF_mean(ids,3)/2/pi,'r');
+
+subplot(2,1,2);
+plot(kftime, M.EKFMz_mean(ids,5));
+
+% ----- 
+
+load ~/work/vs/Pohony/DATA_MERENI/DATA_MCU/data1.dat -ascii
+
+subplot(2,1,1);
+setime=[0:799]*0.004666; % fitted on currents
+plot(setime,data13([0:799]+711,6),'--k','LineWidth',3);
+plot(setime,data13([0:799]+711,11),'--g','LineWidth',3);
+%plot(setime,2*pi*data1([0:799]+620,6),'--k','LineWidth',3);
+
+
