function dx=dcm_ode(t,x,Xo);

% DCM_ODE
%       Matlab function describing the non-linear dynamic equations of a
%       separately excited cmotor given by eqs. 3.3-1, 3.3-5 and 3.3-6 of 
%       Electromechanical Motion Devices" P. Krause, McGraw Hill 1989.
%
%       This file should not be used stand alone.  It is invoqued by
%       DCMSIMU.M
%
% CALLS: DCM_INO.M (inputs file)

% Copyright JCCK, Feb 1999

% ------------------------------------------------------------------------ %

% 0. Declare any parameters of the system as global
%
  global Vf Va Tl Rf Ra Laa Lff Laf Bm Jm
 
% 1. External inputs (computed by external function dcm_inp.m)
%     input vector u = (Vf,Va,Tl)
%    	Vf - Field winding voltage
%    	Va - Armature winding voltage
%    	Tl - Load torque disturbance

  u=dcm_inp(t,x);

% 2. State Equations
%     state vector x=(If;Ia;Wr)
%    	If - Field current
%    	Ia - Armature current
%    	Wr - Motor speed

  dx(1) = -Rf/Lff*x(1) + 1/Lff*u(1);
  dx(2) = -Ra/Laa*x(2) - Laf/Laa*x(1)*x(3) + 1/Laa*u(2);
  dx(3) = -Bm/Jm*x(3) + Laf/Jm*x(1)*x(2) - 1/Jm*u(3);
  dx = dx(:);  %% <-- This line required for compatibility with Matlab 5 !!

