View unanswered posts | View active topics It is currently Mon Dec 10, 2018 10:02 pm






Reply to topic  [ 3 posts ] 
Target encoders using PID 
Author Message
Rookie

Joined: Fri Jan 09, 2015 4:05 pm
Posts: 6
Post Target encoders using PID
Hello, when we use the targeting function our robot does a weird jerk motion to the side? Any ideas why that is? Just using straight our enocders directly to go a certain distance is better than the targeting and I think it should be the opposite.


Thu Feb 05, 2015 2:16 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Target encoders using PID
Please post the simplest code sample that replicates this issue using the [code] tags; we will need this to debug the code and see if there are any glaring issues.

Thank you in advance!

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Thu Feb 05, 2015 2:40 pm
Profile
Rookie

Joined: Fri Jan 09, 2015 4:05 pm
Posts: 6
Post Re: Target encoders using PID
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, PIDControl, reversed, encoder)


task main()
{

  nMotorEncoder[motorE] = 0;  //clear the TETRIX motor encoders
  nMotorEncoder[motorD] = 0;

  nMotorEncoderTarget[motorE] = 1440; //set the target stoping position
  nMotorEncoderTarget[motorD] = 1440;

  motor[motorE] = 30; //turn both motors on at 30 percent power
  motor[motorD] = 30;

  while (nMotorRunState[motorE] != runStateIdle || nMotorRunState[motorD] != runStateIdle) //while the encoder wheel turns one revolution
  {
    // This condition waits for motors D & E to come to an idle position. Both motors stop
    // and then jumps out of the loop
  }

  motor[motorE] = 0; //turn both motors off
  motor[motorD] = 0;

}



Thu Feb 05, 2015 2:53 pm
Profile
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.