% Lego EV3 DC mootori parameetrite sisestus:
% http://nxt-unroller.blogspot.com/2015/03/mathematical-model-of-lego-ev3-motor.html
% http://www.philohome.com/motors/motorcomp.htm
% Ra - mootori mähise takistus	[ohm] (Armature resistance of motor)	
% La - mootori mähise induktiiv.[H]   (Armature inductance of motor)	
% Km - mootori jõumomendi konst.[Nm/A](Torque constant of motor)	
% Kb - mootori vastu-emj. konst.[V/rad/s](Back-emf constant of motor)
% D  - dry friction [Nm], Stall torque 0.43 Nm
% Jm - rootori inertsmoment 	[kg.m^2](Inertia of motor rotor)	
% JL - koormuse inertsmoment 	[kg.m^2](Inertia of load)		
% Bm - mootori hõõrdetegur	[Nms] (Motor Viscous-friction coef.)	
% BL - koormuse hõõrdetegur	[Nms] (Load Viscous-friction coef.)	
% N  - ülekande suhe		      (Gear-train ratio)


N  = 1/1;

Ra = 4.3+2.5;
La = 4.94e-03;

Km = 0.30477; % [Nm/A] 
Kb = 0.47165; % [V/rad/s]

D = 0.00662
Jm = 0.00150; % [Nm.s^2],[kg.m^2]
JL = 0.003;   % [Nm.s^2],[kg.m^2] TL c 0.19 Nm

Bm = 0.000619; % [Nms]  
BL = 0.020;   % [Nms]  TL c 0.19 Nm

% Tau_meh=17ms
Tau_meh=roots([Jm Bm])

% Kogu inertsmoment (Total inertia)
Jt = Jm + JL/(N^2)

% Kogu hõõrdetegur
Bt = Bm + BL/(N^2)
