Motors

Both lpf2.port and the concrete lpf2.devices.encoder_motor expose the LPF2 output commands.

Conventions

  • Power / speed: signed -100..100. Sign selects direction.

  • maxPower: unsigned 0..100 — commanded-power cap for closed-loop moves.

  • endState (BrakingStyle):

    • 0 — float (coast)

    • 126 — hold (active brake to zero)

    • 127 — brake (short brake)

  • useProfile: low nibble = accel profile index, next nibble = decel profile index. Together with setAccTime() / setDecTime() they define ramp behaviour.

Open-loop power

port.startPower(60)     # 60 % CW
port.startPower(-30)    # 30 % CCW

For basic (encoder-less) motors this is the only command that matters — power maps directly to the H-bridge duty.

Continuous speed

port.startSpeed(speed=50, maxPower=80, useProfile=0)

Timed moves

port.startSpeedForTime(time=2000, speed=40, endState=127)

Relative-degree moves

Positive degree count; direction from speed sign:

port.startSpeedForDegrees(degrees=720, speed=60, endState=126)

Absolute position

port.presetEncoder(0)                       # zero here
port.gotoAbsPosition(180, speed=40, endState=126)

Ramp profiles

port.setAccTime(time=500, profile=0)   # 500 ms accel ramp, profile 0
port.setDecTime(time=500, profile=0)
port.startSpeed(speed=100, useProfile=0x11)   # both nibbles = 1

Motor tuning presets

motor_setting groups the built-in tuning presets for known LPF2 motors (fields of _motor_settings):

Preset

Motor

medium_linear

Medium linear

technic_large_linear

Technic Large linear

technic_xlarge_linear

Technic XL linear

technic_medium_angular

Technic Medium Angular

technic_large_angular

Technic Large Angular

technic_medium_angular_grey

Technic Medium Angular (grey Control+ variant)

technic_large_angular_grey

Technic Large Angular (grey Control+ variant)

Each preset is a _motor_settings with PID gains, kinetic floors, breakaway boost and deadbands. The encoder-motor controller picks the preset by device type; overriding fields in place changes behaviour immediately.

Reference: lpf2.port, lpf2.devices.encoder_motor, lpf2.devices.basic_motor, lpf2.motor_setting, lpf2._motor_settings.