ROBOTC.net forums
http://robotc.net/forums/

PID, motor and const declaration...
http://robotc.net/forums/viewtopic.php?f=1&t=64
Page 1 of 1

Author:  Jesspepette [ Wed Mar 07, 2007 5:32 pm ]
Post subject:  PID, motor and const declaration...

Hi
I just registered my robotC this morning!! :) Very interesting language !!
Firstly, i'm french so apologize for my english writing ;)
Regarding this program written below, NXT motor synchronisation, that I found in the sample programs from your website:

1) I assume that you use the PID closed loop but why didn't you use this declaration at the beginning ? :
Code:
nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg;


And then if motor C ISN'T slaved to motor A, do we still have to write these two lines? :
Code:
nMotorPIDSpeedCtrl[motorA] = mtrSpeedReg;
nMotorPIDSpeedCtrl[motorC] = mtrSpeedReg;


2) Why RobotC wizard generate this line? :
Code:
const tMotor kPrimaryMotor = (tMotor) motorA;
Why this cast operator doesnt appear below on your example ? I don't think it's important but ??

3) Why did you use 10 ms in this line? :
Code:
nPidUpdateInterval = 10;
Is this a good setting ?

4) And the last one;) Does the nMax RegulatedSpeed variable apply to all the declared motor in the program ?
Or do we have to set it for each motor connected even it have the same value ?

Thanks for your help!

Your NXT motor synchronisation sample program:

Code:
task main()
{

int nMoveSize = 360;
int nSpeed = 35;
int nDelay = 2000;
int nTurnRatio = 50;
const TSynchedMotors kSyncType = synchAC;
const tMotor kPrimaryMotor = motorA;

bFloatDuringInactiveMotorPWM = false;
nMotorEncoder[kPrimaryMotor] = 0;
nMotorEncoderTarget[kPrimaryMotor] = 0;

nSyncedMotors = kSyncType; // "C" will be synchronized to "A".
nSyncedTurnRatio = nTurnRatio;
nPidUpdateInterval = 10;

while (true)
{
nMotorEncoderTarget[kPrimaryMotor] = nMoveSize;
motor[kPrimaryMotor] = nSpeed;
wait1Msec(nDelay);
nSyncedMotors = synchCA;
nSyncedTurnRatio = nTurnRatio;
nMotorEncoderTarget[motorC] = nMoveSize;
motor[motorC] = nSpeed;
wait1Msec(nDelay);
nSyncedMotors = kSyncType;
nSyncedTurnRatio = nTurnRatio;
}
}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/