NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
void RotateMotorPID ( byte  outputs,
char  pwr,
long  angle,
byte  p,
byte  i,
byte  d 
)
inline

Rotate motor with PID factors.

Run the specified outputs forward for the specified number of degrees. Specify proportional, integral, and derivative factors.

The motor API functions are thread-safe and blocking on the motor resource(s) requested. If you call RotateMotor(OUT_AB, 75, 3600) then no other thread will be able to control motors A and B until the already executing RotateMotor function finishes. But now you can safely call RotateMotor(OUT_A, 75, 3600) on one thread and RotateMotor(OUT_B, 75, 720) on another simultaneously executing thread without having program errors or erratic motor behavior.

Since the functions do not know at compile time which port is being utilized when you use a variable as the port parameter, the RotateMotor functions acquire all three motor port resources for the duration of their operation in that case. So you can safely call RotateMotor using a variable for the port parameter on two simultaneously executing threads but one of the two calls will be blocked until the first one has completed executing.

Parameters
outputsDesired output ports. Can be a constant or a variable, see Output port constants. If you use a variable and want to control multiple outputs in a single call you need to use a byte array rather than a byte and store the output port values in the byte array before passing it into this function.
pwrOutput power, 0 to 100. Can be negative to reverse direction.
angleAngle limit, in degree. Can be negative to reverse direction.
pProportional factor used by the firmware's PID motor control algorithm. See PID constants.
iIntegral factor used by the firmware's PID motor control algorithm. See PID constants.
dDerivative factor used by the firmware's PID motor control algorithm. See PID constants.
Examples:
ex_rotatemotorpid.nxc.