View unanswered posts | View active topics It is currently Sat Dec 20, 2014 7:29 pm






Reply to topic  [ 3 posts ] 
When nEncoderTarget are reset ? 
Author Message
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: When nEncoderTarget are reset ?
miki wrote:
Hello,

Some questions about nEncoderTarget:

RobotC firmware enters a motor in "active PID regulation mode" when both nEncoderTarget value is set and motor power is set.
RobotC firmware exits a motor of "active PID regulation mode" when nEncoderTarget value is reached.

1. Does RobotC firmware exits a motor of "active PID regulation mode" if motor power is changed ? (ie to go slower)
Code:
nMotorEncoder[motorB] = 0;                // Reset the Motor Encoder of Motor B.
nMotorEncoderTarget[motorB] = 360;        // Set the  target for Motor Encoder of Motor B to 360.
motor[motorB] = 75;                       // Motor B is run at a power level of 75.
wait1Msec(1);
motor[motorB] = 50;;                       // Motor B is run at a power level of 50. DOES THE POWER CHANGE MODIFY FIRMWARE REGULATION ???
while(nMotorRunState[motorB] != runStateIdle); 
motor[motorB] = 0;                       // Motor B is stopped at a power level of 0.
2. Does RobotC firmware exits a motor of "active PID regulation mode" if motor power is stopped the restarted ?
Code:
nMotorEncoder[motorB] = 0;                // Reset the Motor Encoder of Motor B.
nMotorEncoderTarget[motorB] = 360;        // Set the  target for Motor Encoder of Motor B to 360.
motor[motorB] = 75;                       // Motor B is run at a power level of 75.
wait1Msec(1);
motor[motorB] = 0;                       // Motor B is run at a power level of 0. DOES THE MOTOR STOP CANCEL µTHE PREVIOUS GOAL (REACH 360) ???
wait1Msec(1);
motor[motorB] = 75;                       // Motor B is run at a power level of 75. DOES THE FIRMWARE MAINTAIN ITS PREVIOUS GOAL (REACH 360) ???
while(nMotorRunState[motorB] != runStateIdle); 
motor[motorB] = 0;                       // Motor B is stopped at a power level of 0.
3. What are all conditions possible to cancel the nEncoderTarget ( except to reach it :-) )
4. Is there a safe way to abort a nEncoderTarget while motor is turning and target is not reached ?.

Thank you for your help.
Miki.


I think that your first two statements are wrong. It's my understanding that PID is on only when you've set it to be on, and off when you've set it to be off. But, I might be wrong.

My answers to your questions (again, these are just my answers, take them as you will. :twisted: ):

1. If by regulation you mean the PID, then no. The PID just tries to keep the motor going at the speed you set.
2. It doesn't cancel the target. That code is fine. (as far as I know)
3. None, I think (other than writing a new target).
4. I'm not exactly sure what you mean. Could you possibly explain better?

Anyway, these are correct as far as I know. Do they satisfy?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sun Mar 25, 2012 5:16 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: When nEncoderTarget are reset ?
miki wrote:
I set the motor to turn until an encoder target is reached AND while a Contact Sensor is not pressed.
A contact occurs on sensor (the robot front bumper) and I stop the motor. Internally, the firmware keeps the encoder target set.
Then I want to 'push' the obstacle for 5 secondes. So I set the motor to turn during 5 seconds.
But if encoder target is reached before the 5 seconds the firmware will stop motor.

My questions are related to my project (see my signature) where I created a small simulation of sensors and motors in order to validate my code first in PC-emulator then in real world. Understanding internal firmware behavior will help me to get an accurate motor simulation.

Thank for your help.


Ah, okay. To remove the target, simply set the target to "0". That means that you get full control of the motor back.

Here's an example:

Code:
nMotorEncoderTarget[motorA] = 360;

motor[motorA] = 100;

while(nMotorRunState[motorA] != runStateIdle && SensorValue(touch) == 0);

motor[motorA] = 0;

if(SensorValue(touch) == 1)
{
  nMotorEncoderTarget[motorA] = 0;  //Resets the encoder so that there is no target.
  wait1Msec(5000);
  motor[motorA] = 0;
}

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon Mar 26, 2012 7:09 pm
Profile WWW
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: When nEncoderTarget are reset ?
miki wrote:
D'oh!
And now I have the answer it's simple to read deeply the doc!!
doc wrote:
A target value of 0 (zero) means run forever.
Focused on code exemples I didn't pay attention to the text over them :mrgreen:

Thanks for your help NeXT-Generation.
Miki.


Your welcome. I know this stuff well. Encoders are my "friends" (Of course, by friends, I mean mortal enemies.) :roll: (Just try getting exact positioning with a high-speed robot(it's hard(if not impossible :lol: :o :x :( )))

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Wed Mar 28, 2012 11:24 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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.