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

Clean up messy commit f83ac476

parent 44785c76
No related branches found
No related tags found
No related merge requests found
......@@ -168,14 +168,9 @@ classdef Motor < MaskedHandle & dynamicprops
end
if motor.brakeMode_ == BrakeMode.Coast
motor.internalReset();
motor.reset();
end
% if motor.internalTachoCount ~= 0
% motor.reset();
% end
% Call appropriate function in commInterface depending on limitValue and limitMode
if motor.limitValue==0
if motor.sendOnStart > 0
......@@ -422,8 +417,13 @@ classdef Motor < MaskedHandle & dynamicprops
motor.commInterface.outputStop(0, motor.port+syncMotor.port, motor.brakeMode_);
% On next start, both motors have to send power-opcode again
motor.sendPowerOnNextStart = true;
syncMotor.sendPowerOnNextStart = true;
if motor.sendPowerOnSet
motor.sendOnStart = bitset(motor.sendOnStart, SendOnStart.Power, 1);
end
if syncMotor.sendPowerOnSet
syncMotor.sendOnStart = bitset(syncMotor.sendOnStart, SendOnStart.Power, 1);
end
if motor.debug
fprintf('(DEBUG) Motor::stop: Called outputStop on Ports %s and %s\n.', ...
......@@ -455,7 +455,7 @@ classdef Motor < MaskedHandle & dynamicprops
'You have to call motor.connect(commInterface) first!']);
end
%pause(0.1);
pause(0.1);
while motor.isRunning
pause(0.03);
end
......@@ -490,8 +490,8 @@ classdef Motor < MaskedHandle & dynamicprops
% end
end
function internalReset(motor)
%internalReset Resets internal tacho count
function reset(motor)
% reset Resets internal tacho count
% Use this if motor behaves weird (i.e. not starting at all, or not correctly
% running to limitValue)
%
......@@ -504,23 +504,22 @@ classdef Motor < MaskedHandle & dynamicprops
%
if ~motor.connectedToBrick
error(['Motor::internalReset: Motor-Object not connected to brick handle.',...
error(['Motor::reset: Motor-Object not connected to brick handle.',...
'You have to call motor.connect(brick) first!']);
elseif ~motor.physicalMotorConnected
error('Motor::internalReset: No physical motor connected to Port %s',...
error('Motor::reset: No physical motor connected to Port %s',...
port2str('Motor', motor.port));
end
motor.commInterface.outputReset(0, motor.port);
if motor.debug
fprintf('(DEBUG) Motor::internalReset: Called outputReset on Port %s\n',...
fprintf('(DEBUG) Motor::reset: Called outputReset on Port %s\n',...
port2str('Motor', motor.port));
end
end
function resetTachoCount(motor)
if ~motor.connectedToBrick
error(['Motor::resetTachoCount: Motor-Object not connected to comm handle.',...
'You have to call motor.connect(commInterface) first!']);
......@@ -537,28 +536,6 @@ classdef Motor < MaskedHandle & dynamicprops
end
end
function releaseBrake(motor)
if ~motor.connectedToBrick
error(['Motor::releaseBrake: Motor-Object not connected to comm handle.',...
'You have to call motor.connect(commInterface) first!']);
elseif ~motor.physicalMotorConnected
error('Motor::releaseBrake: No physical motor connected to Port %s',...
port2str('Motor', motor.port));
elseif motor.isRunning
error('Motor::releaseBrake: Can''t loose brake because Motor is runnning');
end
motor.commInterface.outputPower(0, motor.port, 0);
motor.commInterface.outputStart(0, motor.port);
motor.commInterface.outputStop(0, motor.port, BrakeMode.Coast);
motor.sendPowerOnNextStart = true;
end
function state(motor)
fprintf('sendPowerOnSet: %d\n', uint8(motor.sendPowerOnSet));
fprintf('sendOnStart: %d\n', uint8(motor.sendOnStart));
end
%% Setter
function set.power(motor, power)
if ~isnumeric(power)
......@@ -583,13 +560,9 @@ classdef Motor < MaskedHandle & dynamicprops
function set.speedRegulation(motor, speedRegulation)
if ~isBool(speedRegulation)
error('Motor::set.speedRegulation: Given parameter is not a bool.');
elseif motor.connectedToBrick && motor.physicalMotorConnected && ...
motor.currentSpeed ~= 0
error(['Motor::set.speedRegulation: Cannot change speed regulation while ', ...
'is motor is moving.']);
end
if any(motor.speedRegulation) && speedRegulation ~= motor.speedRegulation
if ~isempty(motor.speedRegulation) && speedRegulation ~= motor.speedRegulation
if motor.sendPowerOnSet
motor.sendOnStart = bitset(motor.sendOnStart, SendOnStart.Power, 1);
end
......@@ -636,7 +609,7 @@ classdef Motor < MaskedHandle & dynamicprops
% if ~motor.init && motor.brakeMode_~=oldMode && ...
% motor.connectedToBrick && motor.physicalMotorConnected
% motor.internalReset();
% motor.reset();
% end
end
......@@ -659,7 +632,7 @@ classdef Motor < MaskedHandle & dynamicprops
if limitValue == 0
motor.sendOnStart = SendOnStart.Power;
if any(motor.limitValue) && motor.limitValue > 0
if ~isempty(motor.limitValue) && motor.limitValue > 0
motor.sendOnStart = motor.sendOnStart + SendOnStart.Stop;
end
motor.sendPowerOnSet = true;
......@@ -811,7 +784,6 @@ classdef Motor < MaskedHandle & dynamicprops
function running = get.isRunning(motor)
running = (motor.currentSpeed~=0);
%running = motor.commInterface.outputTest(0, motor.port);
end
function synced = get.isSynced(motor)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment