Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

Using Motors

GongYi edited this page Jul 26, 2014 · 4 revisions

Overview

ev3.Motor class maps to ev3dev /sys/bus/legoev3/devices/out* nodes. Please read ev3dev Using Motor for detail.

Motor speed properties data type

You can use integer for all motor speed properties.

Motor regulation_mode and speed_sp

regulation_mode properties is converted to bool data type.
Depends on the regulation_mode, python-ev3 write the speed_sp to either pulses_per_second_sp or duty_cycle_sp

	<td>
		duty_cycle_sp
	</td>
</tr>
<tr>
	<td>
		True
	</td>
	<td>
		pulses_per_second_sp
	</td>
</tr>
regulation_mode speed_sp
False (default)

Motor API

run_forever

from ev3.ev3dev import Motor
d=Motor(port=Motor.PORT.A)
d.run_forever(speed_sp=50)

run_time_limited

from ev3.ev3dev import Motor
d=Motor(port=Motor.PORT.A)
d.run_time_limited(time_sp=10000, speed_sp=80)

run_position_limited

from ev3.ev3dev import Motor
d=Motor(port=Motor.PORT.A)
d.run_position_limited(position_sp=160, speed_sp=800)

No limited number named arguments

All above methods support no limited number named arguments. You may pass any ev3dev supported motor argument in a single method call by python Named Arguments syntax

from ev3.ev3dev import Motor
d=Motor(port=Motor.PORT.A)
d.run_position_limited(position_sp=160, speed_sp=800)
d.run_time_limited(time_sp=10000, speed_sp=80, regulation_mode=False,
                           stop_mode=Motor.STOP_MODE.COAST, ramp_up_sp=1000, ramp_down_sp=1000)