Overview
Comment:ppp_int_obs now returns corrected as well as predicted output
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 4c9bb5509d77e7b5109c2a3894764b1c80e7e84b5715cc5c3049e36b62dd9f4c
User & Date: gawthrop@users.sourceforge.net on 2003-10-16 07:30:24
Other Links: branch diff | manifest | tags
Context
2003-10-20
17:10:30
Added initial revision of ntt:
new transformation tools for using bond graphs with Matlab.
Copyright 2003 Dr. Dominic J. Diston.
check-in: 745f0b3e31 user: geraint@users.sourceforge.net tags: origin/master, trunk
2003-10-16
07:30:24
ppp_int_obs now returns corrected as well as predicted output check-in: 4c9bb5509d user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2003-10-15
16:21:20
Simulation and real now compatible! check-in: 2e7eb80963 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/lib/control/PPP/ppp_int_obs.m from [982a22072f] to [9bfdfe49cb].

1
2
3
4
5
6
7
8
9
10
11
12





13
14
15
16
17
18
19
20
21
22
23

24
25
26
27
28
function [x_p,y_p,error] = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)

  ## usage: x_new = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)
  ##
  ## Intermittent observer for PPP
  ##
  ## x,y Current estimated state and measured output
  ## U PPP control weights
  ## A,B,C,D System matrices
  ## A_u PPP basis matrix
  ## delta time step
  ## L Observer gain






  ## Sanity check
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  if nargin<10
    L = zeros(n_x,n_y);
  endif
  
  ## Corrector (on current value of output)
  error = (C*x-y);
  x_new = x - L*error;


  ## Predictor (predicts Delta_OL ahead)
  [y_p,us,x_p] = ppp_ystar (A,B,C,D,x_new,A_u,U,delta);

endfunction
|











>
>
>
>
>











>





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [x_p,y_p,y_new,error] = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)

  ## usage: x_new = ppp_int_obs (x,y,U,A,B,C,D,A_u,delta,L)
  ##
  ## Intermittent observer for PPP
  ##
  ## x,y Current estimated state and measured output
  ## U PPP control weights
  ## A,B,C,D System matrices
  ## A_u PPP basis matrix
  ## delta time step
  ## L Observer gain
  ## x_p, y_p predicted estimated state and output
  ## y_new corrected estimated current output
  ## error corresponding error

  ## Copyright (C) 2003 by Peter J. Gawthrop

  ## Sanity check
  [n_x,n_u,n_y] = abcddim(A,B,C,D);

  if nargin<10
    L = zeros(n_x,n_y);
  endif
  
  ## Corrector (on current value of output)
  error = (C*x-y);
  x_new = x - L*error;
  y_new = C*x_new;

  ## Predictor (predicts Delta_OL ahead)
  [y_p,us,x_p] = ppp_ystar (A,B,C,D,x_new,A_u,U,delta);

endfunction

Modified mttroot/mtt/lib/control/PPP/ppp_lin_run.m from [66d5fae7bd] to [96369350d9].

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
	t_i = ti(1);
      else			# The real thing
	[t_i,y_i,u_i] = ppp_put_get(U); # Generic interface to real-time
      endif

      ## Observer
      if strcmp(p_o.method, "intermittent")
	[x_est y_est e_est] = ppp_int_obs \
	    (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,L);
      elseif strcmp(p_o.method, "continuous")
	Ui = U;			# U at sub intervals
	for k = 1:p_c.N
	  [x_est y_est e_est] = ppp_int_obs \
	      (x_est,yi(:,k),Ui,A,B,C,D,p_c.A_u,dt,L);
	  Ui = A_ud'*Ui;
	  y_e = [y_e; y_est'];
	  e_e = [e_e; e_est];
	endfor
      endif
      
      ##Control
      U = K_w*w - K_x*x_est;

      ## Save data
      if Simulate
	t = [t;ti'];
	y = [y;yi'];
	u = [u;ui'];
      else
	t = [t;t_i];
	y = [y;y_i'];
	u = [u;u_i'];
      endif
      

      if strcmp(p_o.method, "intermittent")
	y_e = [y_e; y_est'];
	e_e = [e_e; e_est'];
	t_e = [t_e; t_i];
      endif

      delta_comp = time-tim;
      usleep(floor(1e6*(p_c.delta_ol-delta_comp-0.01)));
    endfor			# Main loop







|




|


|
|



















|







207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
	t_i = ti(1);
      else			# The real thing
	[t_i,y_i,u_i] = ppp_put_get(U); # Generic interface to real-time
      endif

      ## Observer
      if strcmp(p_o.method, "intermittent")
	[x_est y_est y_new, e_est] = ppp_int_obs \
	    (x_est,y_i,U,A,B,C,D,p_c.A_u,p_c.delta_ol,L);
      elseif strcmp(p_o.method, "continuous")
	Ui = U;			# U at sub intervals
	for k = 1:p_c.N
	  [x_est y_est y_new e_est] = ppp_int_obs \
	      (x_est,yi(:,k),Ui,A,B,C,D,p_c.A_u,dt,L);
	  Ui = A_ud'*Ui;
	  y_e = [y_e; y_new'];
	  e_e = [e_e; e_est'];
	endfor
      endif
      
      ##Control
      U = K_w*w - K_x*x_est;

      ## Save data
      if Simulate
	t = [t;ti'];
	y = [y;yi'];
	u = [u;ui'];
      else
	t = [t;t_i];
	y = [y;y_i'];
	u = [u;u_i'];
      endif
      

      if strcmp(p_o.method, "intermittent")
	y_e = [y_e; y_new'];
	e_e = [e_e; e_est'];
	t_e = [t_e; t_i];
      endif

      delta_comp = time-tim;
      usleep(floor(1e6*(p_c.delta_ol-delta_comp-0.01)));
    endfor			# Main loop


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]