View unanswered posts | View active topics It is currently Fri Jul 25, 2014 10:48 am






Reply to topic  [ 1 post ] 
PID, motor and const declaration... 
Author Message
Rookie

Joined: Wed Mar 07, 2007 5:07 pm
Posts: 3
Post 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;
}
}


Wed Mar 07, 2007 5:32 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.