Reference   Language | Libraries | Comparison | Changes

MKRMotorCarrierPID

PID

Description

Allow setting Motor1 or Motor2 to a specific speed or position. There are two PID virtual objects in the controller: pid1 and pid2. pid1 acts on M1 and encoder1. pid2 acts on M2 and encoder2. It is advisable to control the motors using these functions.

Syntax

pid1. setGains(int P, int I, int D)

Functions

setGains(int P, int I, int D): Set PID gains.
resetGains(): Reset PID gains to factory default settings.
setControlMode(cl_control): Set control mode to either CL_VELOCITY or CL_POSITION.
setSetpoint(cl_mode, int target): Set a specific velocity or position in one of the motors. Define cl_mode as TARGET_POSITION or TARGET_VELOCITY and the desired value in target.
setMaxAcceleration(int): Sets maximum acceleration.
setMaxVelocity(int): Sets maximum velocity (To be implemented)
setLimits(int min, int max): Sets duty cycle limits (for example, to limit the maximum speed of the motor)

See also



Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.