View unanswered posts | View active topics It is currently Fri Jul 01, 2016 12:44 am

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
When nEncoderTarget are reset ?
Author Message
Senior Roboticist

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

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 ?.

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. ):

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
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
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
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
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

Miki.

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

_________________
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning