Smart Motor#

Introduction#

Motors and motor groups control how parts of a robot move. A motor controls one configured Smart Motor, while a motor group controls two configured Smart Motors together so they move in tandem. Motors and motor groups can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two or four motors can work together as a drivetrain to move and turn the whole robot.

Each motor is configured in the Devices window. Depending on the build, the names of the motors and directions can change. A custom robot may use different motor names or directions.

By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse in the Devices window, those directions will be switched.

A VEX EXP Motor showing the forward direction indicated by a plus sign and an arrow indicating it is rotating left, or counterclockwise. A VEX EXP Motor showing the reverse direction indicated by a minus sign and an arrow indicating it is rotating right, or clockwise.

There are many ways to code motors and motor groups. Below is a list of all Smart Motor blocks:

Actions — Stop and spin motors and motor groups.

  • spin motor – Spins a motor or motor group forward or reverse forever.

  • spin motor for – Spins a motor or motor group for a specific distance in degrees or turns.

  • spin motor to position – Spins a motor or motor group to a set position.

  • stop motor – Stops a motor or motor group from spinning.

Settings — Adjust motor and motor group settings.

  • set motor velocity – Tells a motor or motor group how fast to spin.

  • set motor position – Changes the motor or motor group’s current position to a new value.

  • set motor stopping – Sets how a motor or motor group will stop moving: by braking, coasting, or holding.

  • set motor max torque – Sets how hard a motor or motor group is allowed to push while spinning.

  • set motor timeout – Sets how many seconds a motor or motor group will try to finish a movement.

Values — Check motor and motor group status.

  • motor is done – Reports whether the motor or motor group is finished moving.

  • motor is spinning – Reports whether the motor or motor group is spinning.

  • motor position – Reports the motor or motor group’s current position.

  • motor velocity – Reports how fast the motor or motor group is spinning, as a percentage from -100% to 100%.

  • motor current – Reports how much electrical current the motor or motor group is using.

  • motor power – Reports how much power the motor or motor group is using.

  • motor torque – Reports how much torque the motor or motor group is using.

  • motor efficiency – Reports how efficiently the motor or motor group is using power.

  • motor temperature – Reports the temperature of the motor or motor group.

Actions#

spin motor#

The spin motor stack block spins a motor or motor group forward or reverse forever. The motor or motor group will continue to spin until it is given another action, like spinning in a different direction or stopping.

  spin [Motor1 v] [forward v]

Parameters

Description

motor

The motor or motor group to spin. Choose from the motors configured in the Devices window.

direction

The direction the motor or motor group spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration.

  when started
  [Spin the motor forward for 1 second.]
  spin [Motor1 v] [forward v]
  wait (1) seconds
  stop [Motor1 v]

spin motor for#

The spin motor for stack block spins a motor or motor group for a specific distance. The spin is relative to the current position of the motor or motor group. The project will wait until the motor or motor group is done spinning before the next block in the stack runs.

  spin [Motor1 v] [forward v] for [90] [degrees v] ▶

Parameters

Description

motor

The motor or motor group to spin. Choose from the motors configured in the Devices window.

direction

The direction the motor or motor group spins. By default, the choices are forward and reverse. Direction choices can change depending on the motor’s configuration.

distance

The distance the motor or motor group spins. Degrees use whole numbers. Turns can use whole numbers or decimals.

unit

The distance unit: degrees or turns.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

Example

    when started
    [Spin the motor forward once, then reset.]
    spin [Motor1 v] [forward v] for (90) [degrees v] ▶
    spin [Motor1 v] [reverse v] for (90) [degrees v] ▶

spin motor to position#

The spin motor to position stack block spins a motor or motor group to a specific position.

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor position is set to 0 degrees. The motor position can also be set using the set motor position block.

Position values are absolute. This means the direction of the spin depends on the motor or motor group’s current position.

For example, if the motor starts at 0 degrees and spins to a position of 720 degrees, it will spin forward two turns. If it then spins to a position of 360 degrees, it will spin reverse one turn, because 360 is less than 720.

  spin [Motor1 v] to position (90) [degrees v] ▶

Parameters

Description

motor

The motor or motor group to spin. Choose from the motors configured in the Devices window.

position

The position value the motor or motor group will spin to. Degrees use whole numbers. Turns can use whole numbers or decimals.

unit

The position unit: degrees or turns.

and don’t wait

Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away.

    when started
    [Spin the motor to the new 0 position.]
    set [Motor1 v] position to [180] [degrees v]
    spin [Motor1 v] to position [0] [degrees v] ▶

stop motor#

The stop motor stack block stops the selected motor or motor group. The motor or motor group stops based on the current stopping behavior: brake, coast, or hold.

  stop [Motor1 v]

Parameters

Description

motor

The motor or motor group to stop. Choose from the motors configured in the Devices window.

  when started
  spin [Motor1 v] [forward v]
  wait (1) seconds
  stop [Motor1 v]

Settings#

set motor position#

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The set motor position stack block changes the motor or motor group’s current position to a new value.

For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.

  set [Motor1 v] position to (0) [degrees v]

Parameters

Description

motor

The motor or motor group to set the position of. Choose from the motors configured in the Devices window.

position

The position value to set for the motor or motor group. Degrees use whole numbers. Turns can use whole numbers or decimals.

unit

The position unit: degrees or turns.

    when started
    [Spin the motor to the new 0 position.]
    set [Motor1 v] position to [180] [degrees v]
    spin [Motor1 v] to position [0] [degrees v] ▶

set motor velocity#

The set motor velocity stack block tells a motor or motor group how fast to spin. A higher percentage makes the motor or motor group spin faster and a lower percentage makes the motor or motor group spin slower.

Every project begins with each motor or motor group spinning at 50% velocity by default.

Note: A higher velocity makes the motor or motor group spin faster, but it may be less precise. A lower velocity makes the motor or motor group spin slower, but it can be more precise.

  set [Motor1 v] velocity to [50] [% v]

Parameters

Description

motor

The motor or motor group to set the velocity of. Choose from the motors configured in the Devices window.

velocity

The speed the motor or motor group will spin at. Percent uses whole numbers from 0% to 100%. RPM uses whole numbers from 0 to 127.

unit

The velocity unit: % or rpm (revolutions per minute).

    when started
    [Spin forward at the default velocity.]
    spin [Motor1 v] [forward v] for [90] [turns v] ▶
    [Spin slower.]
    set [Motor1 v] velocity to (20) [% v]
    spin [Motor1 v] [reverse v] for [90] [turns v] ▶
    [Spin faster.]
    set [Motor1 v] velocity to (100) [% v]
    spin [Motor1 v] [forward v] for [90] [turns v] ▶

set motor stopping#

The set motor stopping stack block sets how a motor or motor group will stop moving: by braking, coasting, or holding.

Every project begins with each motor or motor group stopping with brake by default.

  set [Motor1 v] stopping to [brake v]

Parameters

Description

motor

The motor or motor group to set the stopping behavior of. Choose from the motors configured in the Devices window.

stopping behavior

How the motor or motor group will stop:

  • brake — Stops immediately.
  • coast — Slows to a stop.
  • hold — Stops immediately and holds the motor’s position.

set motor max torque#

Torque shows how hard a motor or motor group can push or pull while it spins.

The set motor max torque stack block sets the most torque a motor or motor group is allowed to use.

A higher percentage lets the motor or motor group push harder, like when lifting a heavy object. A lower percentage limits how hard the motor or motor group can push. This can help protect the robot if the motor gets stuck or reaches the end of how far it can move.

Every project begins with each motor or motor group’s torque at 50% by default.

  set [Motor1 v] max torque to [50] %

Parameters

Description

motor

The motor or motor group to set the max torque of. Choose from the motors configured in the Devices window.

torque

The maximum torque the motor or motor group is allowed to use, from 0% to 100%.

set motor timeout#

The set motor timeout stack block sets how many seconds a motor or motor group will try to finish a movement. If the motor or motor group cannot finish in that time, it will stop trying and move on to the next block in the stack. This keeps the motor or motor group from getting stuck on a movement.

  set [Motor1 v] timeout to [1] seconds

Parameters

Description

motor

The motor or motor group to set the timeout of. Choose from the motors configured in the Devices window.

time

The number of seconds the motor or motor group can try to finish a movement. This can be a positive whole number or decimal.

Values#

motor is done#

The motor is done Boolean block reports whether the motor or motor group is finished moving. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.

  • True — The motor or motor group is finished moving.

  • False — The motor or motor group is still moving.

This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.

    <[Motor1 v] is done?>

Parameters

Description

motor

The motor or motor group to report whether it is finished moving. Choose from the motors configured in the Devices window.

Example

    when started
    [Drive forward until the motor is done spinning.]
    spin [Motor1 v] [forward v] for (200) [degrees v] ◀ and don't wait
    forever
    if <[Motor1 v] is done?> then
    stop driving
    else
    drive [forward v]

motor is spinning#

The motor is spinning Boolean block reports whether the motor or motor group is spinning. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.

  • True — The motor or motor group is spinning.

  • False — The motor or motor group is not spinning.

This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.

    <[Motor1 v] is spinning?>

Parameters

Description

motor

The motor or motor group to report whether it is spinning. Choose from the motors configured in the Devices window.

Example

    when started
    [Move forward while the motor is spinning.]
    spin [Motor1 v] [forward v] for (200) [degrees v] ◀ and don't wait
    while <[Motor1 v] is spinning?>
    drive [forward v]
    end
    stop driving

motor position#

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The motor position reporter block reports the motor or motor group’s current position.

At the beginning of a project, the motor position is set to 0 degrees. If the motor spins one full turn forward, the position will be 360 degrees or 1 turn. If the motor spins the other direction, the position will be negative.

    ([Motor1 v] position in [degrees v])

Parameters

Description

motor

The motor or motor group to report the position of. Choose from the motors configured in the Devices window.

unit

The unit to report the motor position in: degrees or turns.

Example

    when started
    [Display the motor's position after spinning.]
    print ([Motor1 v] position in [degrees v]) on screen ◀ and set cursor to next row
    spin [Motor1 v] [forward v]
    wait (1) seconds
    print ([Motor1 v] position in [degrees v]) on screen ▶
    stop [Motor1 v]

motor velocity#

The motor velocity reporter block reports how fast the motor or motor group is spinning, as a percentage from -100% to 100% or as revolutions per minute (rpm) from -127 to 127.

    ([Motor1 v] velocity in [% v])

Parameters

Description

motor

The motor or motor group to report the velocity of. Choose from the motors configured in the Devices window.

unit

The unit to report the motor velocity in: % or rpm (revolutions per minute).

motor current#

The motor current reporter block reports how much electrical current the motor or motor group is using, measured in amps from 0.0 to 1.2 A. Current is the amount of electricity flowing through the motor or motor group.

A higher current value means the motor or motor group is using more electrical current. This can happen when the motor or motor group is lifting something heavy, pushing against an object, or trying to move when it is stuck.

This can be used to check if the motor or motor group is struggling during a movement. If current stays high, the motor or motor group may get warmer or use power less efficiently.

    ([Motor1 v] current in amps)

Parameters

Description

motor

The motor or motor group to report the current of. Choose from the motors configured in the Devices window.

unit

The unit to report current in: amps.

motor power#

The motor power reporter block reports how much power the motor or motor group is using, measured in watts from 0.0 to 11.0 W. Power shows how quickly the motor or motor group is using energy.

A higher power value means the motor or motor group is using energy faster. This can happen when the motor or motor group is lifting something heavy, pushing against an object, or trying to move when it is stuck.

This can be used to compare movements or check if the motor or motor group is struggling. If power stays high, the motor or motor group may get warmer or use energy less efficiently.

    ([Motor1 v] power in watts)

Parameters

Description

motor

The motor or motor group to report the power of. Choose from the motors configured in the Devices window.

unit

The unit to report power in: watts.

motor torque#

Torque shows how hard a motor or motor group is twisting, pushing, or pulling while it spins.

The motor torque reporter block reports how much torque the motor or motor group is using, measured in inch-pounds (InLb) from 0.0 to 22.0 or Newton-meters (Nm) from 0.0 to 2.1.

A higher torque value means the motor or motor group is pushing or pulling harder. This can happen when the motor or motor group is lifting something heavy, pushing against an object, or trying to move when it is stuck.

This can be used to check if the motor or motor group is struggling or to compare how much push different movements need.

To set the torque of a motor, use the set motor max torque block.

    ([Motor1 v] torque in [InLb v])

Parameters

Description

motor

The motor or motor group to report the torque of. Choose from the motors configured in the Devices window.

unit

The unit to report motor torque in: InLb (inch-pounds) or Nm (Newton-meters).

motor efficiency#

The motor efficiency reporter block reports how efficiently the motor or motor group is using power, as a percentage from 0% to 100%.

Efficiency shows how much of the motor or motor group’s power is being used for movement. A higher efficiency value means more of the motor or motor group’s power is being used to move. A lower efficiency value can happen when the motor or motor group is working hard but not moving much, like when it is stuck or pushing against an object.

This can be used to compare movements or check if the motor or motor group is wasting power instead of using it for movement.

    ([Motor1 v] efficiency in %)

Parameters

Description

motor

The motor or motor group to report the efficiency of. Choose from the motors configured in the Devices window.

unit

The unit to report efficiency in: %.

motor temperature#

The motor temperature reporter block reports the temperature of the motor or motor group as a percentage from 0% to 100%.

Motor temperature shows how warm the motor or motor group is. A higher temperature means the motor or motor group is getting warmer while it works. The motor or motor group should stay below 55°C to keep working at full performance.

If the motor or motor group gets too hot, it will lower its maximum current to protect itself. At 70°C, a motor will stop running until it cools down.

This can be used to check if the motor or motor group is getting too hot during repeated movements, long runs, or when it is pushing against an object.

    ([Motor1 v] temperature in %)

Parameters

Description

motor

The motor or motor group to report the temperature of. Choose from the motors configured in the Devices window.

unit

The unit to report temperature in: %.