Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ev3-toolbox-matlab
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mindstorms
ev3-toolbox-matlab
Commits
789341a4
Commit
789341a4
authored
Oct 5, 2016
by
Tim Stadtmann
Browse files
Options
Downloads
Patches
Plain Diff
Clean up messy commit
f83ac476
parent
44785c76
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Motor.m
+17
-45
17 additions, 45 deletions
source/Motor.m
with
17 additions
and
45 deletions
source/Motor.m
+
17
−
45
View file @
789341a4
...
...
@@ -168,14 +168,9 @@ classdef Motor < MaskedHandle & dynamicprops
end
if
motor
.
brakeMode_
==
BrakeMode
.
Coast
motor
.
internalR
eset
();
motor
.
r
eset
();
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
internalR
eset
(
motor
)
%
internalR
eset Resets internal tacho count
function
r
eset
(
motor
)
%
r
eset 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::
internalR
eset: Motor-Object not connected to brick handle.'
,
...
error
([
'Motor::
r
eset: Motor-Object not connected to brick handle.'
,
...
'You have to call motor.connect(brick) first!'
]);
elseif
~
motor
.
physicalMotorConnected
error
(
'Motor::
internalR
eset: No physical motor connected to Port %s'
,
...
error
(
'Motor::
r
eset: No physical motor connected to Port %s'
,
...
port2str
(
'Motor'
,
motor
.
port
));
end
motor
.
commInterface
.
outputReset
(
0
,
motor
.
port
);
if
motor
.
debug
fprintf
(
'(DEBUG) Motor::
internalR
eset: Called outputReset on Port %s\n'
,
...
fprintf
(
'(DEBUG) Motor::
r
eset: 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
an
y
(
motor
.
speedRegulation
)
&&
speedRegulation
~=
motor
.
speedRegulation
if
~
isempt
y
(
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.
internalR
eset();
% motor.
r
eset();
% end
end
...
...
@@ -659,7 +632,7 @@ classdef Motor < MaskedHandle & dynamicprops
if
limitValue
==
0
motor
.
sendOnStart
=
SendOnStart
.
Power
;
if
an
y
(
motor
.
limitValue
)
&&
motor
.
limitValue
>
0
if
~
isempt
y
(
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment