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

Fix issues #27 and #28

parent bfc8a1de
No related branches found
No related tags found
No related merge requests found
...@@ -452,31 +452,38 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -452,31 +452,38 @@ classdef Motor < MaskedHandle & dynamicprops
end end
end end
% Keep 'slave'-motor synchronized
syncMotor.speedRegulation = false;
syncMotor.limitValue= motor.limitValue;
syncMotor.brakeMode = motor.brakeMode;
syncMotor.power = motor.power;
% Save old states
motor.saveState();
syncMotor.saveState();
% Cache old values to make it possible to reset them on syncedStop % Cache old values to make it possible to reset them on syncedStop
% Note: the existence of 'slave' is also used to determine whether motor is % Note: the existence of 'slave' is also used to determine whether motor is
% running synchronized or not, see get.isSynced() % running synchronized or not, see get.isSynced()
motor.addProperty(syncMotor, 'slave', true); motor.addProperty(syncMotor, 'slave', true);
syncMotor.addProperty(motor, 'master', true); syncMotor.addProperty(motor, 'master', true);
motor.saveState();
syncMotor.saveState();
% Disable immediate sending of new power values % Disable immediate sending of new power values
motor.state.sendPowerOnSet = false; motor.state.sendPowerOnSet = false;
syncMotor.state.sendPowerOnSet = false; syncMotor.state.sendPowerOnSet = false;
% Keep 'slave'-motor synchronized % Synchronous running is a 'busy'-operation
syncMotor.speedRegulation = false; motor.state.startedNotBusy = false;
syncMotor.limitValue= motor.limitValue; syncMotor.state.startedNotBusy = false;
syncMotor.brakeMode = motor.brakeMode;
syncMotor.power = motor.power;
if strcmpi(motor.limitMode, 'Tacho') if strcmpi(motor.limitMode, 'Tacho')
motor.commInterface.outputStepSync(0, motor.port+syncMotor.port, ... motor.commInterface.outputStepSync(0, motor.port+syncMotor.port, ...
motor.power, turnRatio, ... motor.power, turnRatio, ...
motor.limitValue, motor.brakeMode_); motor.limitValue, motor.brakeMode_);
if motor.debug if motor.debug
fprintf(['(DEBUG) SyncMotor::syncedStart: Called outputStepSync on ' ,... fprintf(['(DEBUG) Motor::syncedStart: Called outputStepSync on ' ,...
'Ports %s and %s.\n'], port2str('Motor', motor.port), port2str('Motor', syncMotor.port)); 'Ports %s and %s.\n'], port2str('Motor', motor.port), port2str('Motor', syncMotor.port));
end end
elseif strcmpi(motor.limitMode, 'Time') elseif strcmpi(motor.limitMode, 'Time')
...@@ -484,7 +491,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -484,7 +491,7 @@ classdef Motor < MaskedHandle & dynamicprops
motor.power, turnRatio, ... motor.power, turnRatio, ...
motor.limitValue, motor.brakeMode_); motor.limitValue, motor.brakeMode_);
if motor.debug if motor.debug
fprintf('(DEBUG) SyncMotor::start: Called outputStepSync on Ports %s and %s.\n',... fprintf('(DEBUG) Motor::start: Called outputStepSync on Ports %s and %s.\n',...
port2str('Motor', motor.port), port2str('Motor', syncMotor.port)); port2str('Motor', motor.port), port2str('Motor', syncMotor.port));
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment