Motor
(varargin)¶High-level class to work with motors.
This class is supposed to ease the use of the brick's motors. It is possible to set all kinds of parameters, request the current status of the motor ports and of course send commands to the brick to be executed on the respective port.
Notes
power
¶numeric in [-100, 100] – Power level of motor in percent. [WRITABLE]
speedRegulation
¶bool – Speed regulation turned on or off. When turned on, motor will try to 'hold' its speed at given power level, whatever the load. In this mode, the highest possible speed depends on the load and mostly goes up to around 70-80 (at this point, the Brick internally inputs 100% power). When turned off, motor will constantly input the same power into the motor. The resulting speed will be somewhat lower, depending on the load. [WRITABLE]
smoothStart
¶numeric s. t. smoothStart+smoothStop < limitValue – Degrees/Time
indicating how far/long the motor should smoothly start. Depending on limitMode,
the input is interpreted either in degrees or milliseconds. The first
{smoothStart}-milliseconds/degrees of limitValue the motor will slowly accelerate
until reaching its defined speed. See also limitValue
, limitMode
. [WRITABLE]
smoothStop
¶numeric s. t. smoothStart+smoothStop < limitValue – Degrees/Time
indicating how far/long the motor should smoothly stop. Depending on limitMode, the
input is interpreted either in degrees or milliseconds. The last
[smoothStop]-milliseconds/degrees of limitValue the motor will slowly slow down
until it has stopped. See also limitValue
, limitMode
. [WRITABLE]
limitValue
¶numeric>=0 – Degrees/Time indicating how far/long the motor should run.
Depending on limitMode, the input is interpreted either in degrees or
milliseconds. See also limitMode
. [WRITABLE]
limitMode
¶'Tacho'|'Time' – Mode for motor limit. See also limitValue
. [WRITABLE]
brakeMode
¶'Brake'|'Coast' – Action done when stopping. If 'Coast', the motor will (at tacholimit, if ~=0) coast to a stop. If 'Brake', the motor will stop immediately (at tacholimit, if ~=0) and hold the brake. [WRITABLE]
debug
¶bool – Debug turned on or off. In debug mode, everytime a command is passed to the sublayer ('communication layer'), there is feedback in the console about what command has been called. [WRITABLE]
isRunning
¶bool – True if motor is running. [READ-ONLY]
tachoCount
¶numeric – Current tacho count in degrees. [READ-ONLY]
currentSpeed
¶numeric – Current speed of motor. If speedRegulation=on this should equal power,
otherwise it will probably be lower than that. See also speedRegulation
. [READ-ONLY]
type
¶DeviceType – Type of connected device if any. [READ-ONLY]
internalReset
(motor)¶Resets internal tacho count. Use this if motor behaves weird (i.e. not starting at all, or not correctly running to limitValue).
The internal tacho count is used for positioning the motor. When the motor is running with a tacho limit, internally it uses another counter than the one read by tachoCount. This internal tacho count needs to be reset if you physically change the motor's position or it coasted into a stop. If the motor's brakemode is 'Coast', this function is called automatically.
Notes
See also MOTOR.RESETTACHOCOUNT / resetTachoCount
resetTachoCount
(motor)¶Resets tachocount.
See also MOTOR.TACHOCOUNT / tachoCount
setBrake
(motor, brake)¶Apply or release brake of motor.
Parameters: | brake (bool) – If true, brake will be pulled |
---|
Notes
See also MOTOR.BRAKEMODE / brakeMode
setProperties
(motor, varargin)¶Sets multiple Motor properties at once using MATLAB's inputParser.
Parameters: |
|
---|
Example
b = EV3(); %
b.connect('bt', 'serPort', '/dev/rfcomm0'); %
b.motorA.setProperties('debug', 'on', 'power', 50, 'limitValue', 720, 'speedRegulation', 'on'); %
% Instead of: b.motorA.debug = 'on';
% b.motorA.power = 50;
% b.motorA.limitValue = 720;
% b.motorA.speedRegulation = 'on';
start
(motor)¶Starts the motor.
stop
(motor)¶Stops the motor.
Notes
See also MOTOR.START, MOTOR.SYNCEDSTOP / start()
, syncedStop()
syncedStart
(motor, syncMotor, varargin)¶Starts this motor synchronized with another.
The motor, with which this method is called, acts as a master, meaning that the synchronized control is done with it und uses its parameters. When syncedStart is called, the master sets some of the slave's (syncMotor) properties to keep it consistent with the physical brick. So, for example, if the master has another power-value than the slave, the slave's power-value will be set to that of the master when syncedStart() is called. The following parameters will be affected on the slave: power, brakeMode, limitValue, speedRegulation
Parameters: |
|
---|
Notes
Example
b = EV3(); %
b.connect('usb'); %
m = b.motorA; %
slave = b.motorB; %
m.power = 50; %
m.syncedStart(slave); %
% Do stuff
m.stop(); %
See also MOTOR.STOP, MOTOR.SYNCEDSTOP / stop()
, syncedStop()
syncedStop
(motor)¶Stops both motors previously started with syncedStart.
Notes
See also MOTOR.SYNCEDSTART, MOTOR.STOP / syncedStart()
, stop()
waitFor
(motor)¶Stops execution of program as long as motor is running.
Notes