Skip to content
Snippets Groups Projects
Commit e7b90ab9 authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Fix issue #21

Reset() is now called automatically on every start() with limitValue~=0
and brakeMode-change
parent 4f85a5da
No related branches found
No related tags found
No related merge requests found
......@@ -193,10 +193,14 @@ classdef Motor < handle & dynamicprops
% Trigger warning if power = 0 (as it still sets the motor internally in a
% 'running' mode
if motor.power == 0
warning('Motor::start: Motor starting with power=0.');
% if motor.power == 0
% warning('Motor::start: Motor starting with power=0.');
% end
if motor.brakeMode_ == BrakeMode.Coast
motor.reset();
end
% Call right function in commInterface depending on limitValue and limitMode
if motor.limitValue==0
if motor.sendPowerOnNextStart
......@@ -599,21 +603,32 @@ classdef Motor < handle & dynamicprops
error('Motor::set.smoothStop: Smooth stop steps are out of bounds.');
end
if ~isempty(motor.limitValue) && steps>motor.limitValue
error(['Motor::set.smoothStop: Smooth stop steps are greater than ',...
'limitValue.']);
end
% if ~isempty(motor.limitValue) && steps>motor.limitValue
% error(['Motor::set.smoothStop: Smooth stop steps are greater than ',...
% 'limitValue.']);
% end
motor.smoothStop = steps;
end
function set.brakeMode(motor, brakeMode)
validModes = {'Coast', 'Brake'};
if ~motor.init
oldMode = motor.brakeMode_;
end
if ~ischar(brakeMode) || ~ismember(brakeMode, validModes)
error('Motor::set.brakeMode: Given parameter is not a valid brake mode.');
else
motor.brakeMode = brakeMode;
motor.brakeMode_ = str2brake(brakeMode);
end
motor.brakeMode = brakeMode;
motor.brakeMode_ = str2brake(brakeMode);
if ~motor.init && motor.brakeMode_~=oldMode && ...
motor.connectedToBrick && motor.physicalMotorConnected
motor.reset();
% motor.setBrakeMode();
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment