From 597eb3821de45a02fe5820266dbc87069162211a Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 6 Aug 2007 10:52:37 +0200 Subject: Added motor models. --- digital/asserv/models/limit_current.m | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 digital/asserv/models/limit_current.m (limited to 'digital/asserv/models/limit_current.m') diff --git a/digital/asserv/models/limit_current.m b/digital/asserv/models/limit_current.m new file mode 100644 index 00000000..e3d3d790 --- /dev/null +++ b/digital/asserv/models/limit_current.m @@ -0,0 +1,44 @@ +% Limit current. +motor; + +%global to_file = 1; + +function u = onoff (t) + global sys; + if (t < 1) + u = sys.control.u; + else + u = 0; + end +end + +function u = limit_current (t, x) + global sys; + u = onoff (t); + % Limit current by knowing the current speed and the motor terminal + % resistance. + umax = sys.control.current * sys.motor.R + x(2) / sys.motor.Kw; + umin = - sys.control.current * sys.motor.R + x(2) / sys.motor.Kw; + % Uncomment this if the maximum current can be overshooted when braking: + %umax = max ([umax, 0]); + %umin = min ([umin, 0]); + u = min ([u, umax]); + u = max ([u, umin]); +end + +global sys; +sys.motor = re40g; +sys.gear = gear4x; +sys.load = robot10w80; +sys.load.J /= 2; % Two motors. +sys.control.func = "limit_current"; +sys.control.current = 20; +sys.control.u = sys.motor.u; + +plotterm ("limit"); +sys_plot (2); + +sys.control.func = "onoff"; + +plotterm ("nolimit"); +sys_plot (2); -- cgit v1.2.3