Learn EV3 Python‎ > ‎

### Using Motors

 In EV3 Python you set the target speed by setting a value for speed_sp or 'speed setpoint'. For the EV3 motors, speed_sp is in degrees per second so if you set speed_sp to 360 the motor will try to rotate 360° per second or one rotation per second. For the standard EV3 large motors, a speed_sp value of 1000 (degrees per second) is roughly equivalent to a power value of 100 in the standard Lego EV3 software (EV3-G). Therefore with the large motors you should always use speed_sp values in the range -1000 to +1000. In fact I recommend that you use values in the range -900 to +900 with the large motors because they may not be capable of accurately achieving speeds higher than that. With the standard EV3 medium motor it should be safe to use values of speed_sp up to 1400 but it is very convenient to assume that the maximum advisable value is 1000 so that the medium motor can be considered to behave just like the large motor.Note that speed_sp represents the TARGET speed in degrees per second but motors are of course subject to the laws of physics so the real speed may sometimes not correspond to the requested speed. For example, if you run this code mB.run_timed(time_sp=600, speed_sp=600) then you might expect the motor to turn 0.6s*600°/s=360°=1 rotation but in reality it will turn significantly less (maybe 15% less) because the inertia of the motor stops the motor from reaching its target speed instantly and therefore for a short period at the beginning of the motion the motor turns less fast than requested.When low values of speed_sp are used the movements can again differ from what was requested but in this case the motor tends to move faster than requested, for reasons that are not yet well understood. For example, when using speed_sp=100 the motor may turn about 23% faster than requested.For the official motor documentation click HERE. You may want to make one or more motors turn at a given speed through a given angle or number of rotations for a given time 'forever' (until the motor is stopped by a stop() command later during program execution) Turn motor through a given angle Use run_to_rel_pos(position_sp=, speed_sp=). If you want to motor to run backwards then use a negative value for position_sp rather than for speed_sp. Using a negative value for speed_sp will not work because the sign of speed_sp is ignored by this command (but not by others). Use speed_sp values between 0 and 1000 and try to avoid using values above 900 since your motor may not be able to deliver the requested speed above 900. Example To make a large motor on port B turn through 360° at speed 900 and optionally apply a 'hold' (like a strong brake - see later):#!/usr/bin/env python3# so that script can be run from Brickman from ev3dev.ev3 import * from time import sleep m = LargeMotor('outB') m.run_to_rel_pos(position_sp=360, speed_sp=900, stop_action="hold") sleep(5)   # Give the motor time to move Run motor for a given time Use  run_timed(time_sp=
Subpages (1):