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

Fix issue #34

parent c1d34f1d
Branches
Tags
No related merge requests found
...@@ -142,6 +142,10 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -142,6 +142,10 @@ classdef Motor < MaskedHandle & dynamicprops
% state (MotorState): State-struct consisting of several special Motor-flags . % state (MotorState): State-struct consisting of several special Motor-flags .
% See also MOTORSTATE % See also MOTORSTATE
state = MotorState(); state = MotorState();
% currentSpeedRegulation (bool): speedRegulation-value with which the motor has been started
% See also SPEEDREGULATION
currentSpeedRegulation;
end end
properties (Hidden, Dependent, Access = private) % Hidden, dependent properties for internal use only properties (Hidden, Dependent, Access = private) % Hidden, dependent properties for internal use only
...@@ -204,6 +208,11 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -204,6 +208,11 @@ classdef Motor < MaskedHandle & dynamicprops
error('Motor::start: Motor is already running!'); error('Motor::start: Motor is already running!');
end end
if motor.speedRegulation ~= motor.currentSpeedRegulation
motor.currentSpeedRegulation = motor.speedRegulation;
motor.state.sendOnStart = bitset(motor.state.sendOnStart, SendOnStart.Power, 1);
end
% If motor has been started synced with another, and it stopped 'itself' (when % If motor has been started synced with another, and it stopped 'itself' (when
% using a tacholimit), the sync cache has to be deleted (otherwise, syncedStop % using a tacholimit), the sync cache has to be deleted (otherwise, syncedStop
% would do so) % would do so)
...@@ -668,15 +677,37 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -668,15 +677,37 @@ classdef Motor < MaskedHandle & dynamicprops
speedRegulation = str2bool(speedRegulation); speedRegulation = str2bool(speedRegulation);
if ~isempty(motor.speedRegulation) && (speedRegulation ~= motor.speedRegulation) if speedRegulation ~= motor.speedRegulation
if motor.state.sendPowerOnSet if ~isempty(motor.speedRegulation)
motor.state.sendOnStart = bitset(motor.state.sendOnStart, SendOnStart.Power, 1); if motor.state.sendPowerOnSet
motor.state.sendOnStart = bitset(motor.state.sendOnStart, SendOnStart.Power, 1);
end
end
if ~motor.isRunning
motor.currentSpeedRegulation = speedRegulation;
end end
end end
motor.speedRegulation = speedRegulation; motor.speedRegulation = speedRegulation;
end end
function set.currentSpeedRegulation(motor, currentSpeedRegulation)
if ~isBool(currentSpeedRegulation)
error('Motor::set.currentSpeedRegulation: Given parameter is not a bool.');
end
currentSpeedRegulation = str2bool(currentSpeedRegulation);
% if ~isempty(motor.speedRegulation) && (speedRegulation ~= motor.speedRegulation)
% if motor.state.sendPowerOnSet
% motor.state.sendOnStart = bitset(motor.state.sendOnStart, SendOnStart.Power, 1);
% end
% end
motor.currentSpeedRegulation = currentSpeedRegulation;
end
function set.smoothStart(motor, steps) function set.smoothStart(motor, steps)
if ~isnumeric(steps) if ~isnumeric(steps)
error('Motor::set.smoothStart: Given parameter is not a numeric.'); error('Motor::set.smoothStart: Given parameter is not a numeric.');
...@@ -746,7 +777,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -746,7 +777,7 @@ classdef Motor < MaskedHandle & dynamicprops
motor.state.sendPowerOnSet = false; motor.state.sendPowerOnSet = false;
end end
motor.limitValue= limitValue; motor.limitValue = limitValue;
end end
function set.port(motor, port) function set.port(motor, port)
...@@ -847,6 +878,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -847,6 +878,7 @@ classdef Motor < MaskedHandle & dynamicprops
motor.brakeMode = p.Results.brakeMode; motor.brakeMode = p.Results.brakeMode;
motor.debug = p.Results.debug; motor.debug = p.Results.debug;
motor.speedRegulation = p.Results.speedRegulation; motor.speedRegulation = p.Results.speedRegulation;
motor.currentSpeedRegulation = p.Results.speedRegulation;
motor.smoothStart = p.Results.smoothStart; motor.smoothStart = p.Results.smoothStart;
motor.smoothStop = p.Results.smoothStop; motor.smoothStop = p.Results.smoothStop;
end end
...@@ -955,7 +987,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -955,7 +987,7 @@ classdef Motor < MaskedHandle & dynamicprops
return; return;
end; end;
if motor.speedRegulation if motor.currentSpeedRegulation
motor.commInterface.outputSpeed(0, motor.port, power); motor.commInterface.outputSpeed(0, motor.port, power);
if motor.debug if motor.debug
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment