View unanswered posts | View active topics It is currently Fri Aug 22, 2014 8:53 am






Reply to topic  [ 5 posts ] 
Servo Position Issue 
Author Message
Rookie

Joined: Mon Jan 03, 2011 10:52 pm
Posts: 22
Post Servo Position Issue
I have the following code:

Code:
void DriveContain (const int nDistanceLeft, const int nDistanceRight, const int nVariableSpeedLeft, const int nVariableSpeedRight)
{
  nMotorEncoder[leftMotor] = 0;
  nMotorEncoder[rightMotor] = 0;
  wait1Msec(50);
  nMotorEncoderTarget[leftMotor] = (97.5 * nDistanceLeft);
  nMotorEncoderTarget[rightMotor] = (97.5 * nDistanceRight);
  motor[leftMotor] = nVariableSpeedLeft;
  motor[rightMotor] = nVariableSpeedRight;
  servo(rightsideDoor) = 120;
  servo(leftsideDoor) = 140;
  servo(contain) = 250;
  motor[conveyorMotor] = 0;
  while ((nMotorRunState[leftMotor] != runStateIdle) && (nMotorRunState[rightMotor] != runStateIdle))
  {
    EndTimeSlice();
  }
  return;
}


The problem: the servo(contain) is set to 250 before I run this part of the code. However, when this starts, it begins rotating toward the 0 position and then it rotates back to the 250 position. This is very bad for us as we drop what we are holding. Any and all help is loved.

Thanks,


Sat Feb 05, 2011 2:53 am
Profile
Rookie

Joined: Wed Feb 24, 2010 11:43 pm
Posts: 34
Post Re: Servo Position Issue
I think we need some of the other code... that function is not what is changing the servo as best as we can tell...


Sat Feb 05, 2011 7:20 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Servo Position Issue
Yep, RobotC does that. No matter what position you initialize the servo, RobotC will reset it to 0 first. I don't know how to stop RobotC from doing that. You can do one of two things:
1. Remount your servo such that your default position is 0.
2. Load the batons after your code initializes it to 250.


Sat Feb 05, 2011 7:24 am
Profile
Rookie

Joined: Wed Feb 24, 2010 11:43 pm
Posts: 34
Post Re: Servo Position Issue
Actually, RobotC seems to put the servos to 128 the first time any of them are positioned.

If you (in the initializerobot() function) set all the servos at the same time to the place you want them to be, it basically doesn't move them. Although the system sets them to 128 when it first runs, if you instantly set it to the desired location, it doesn't move them to 128 first.

We have a routine that sets the servo and at the same time stores that setpoint to a file (in the autonomous program). In the teleop program, during initialize(), we read that file and then set the servos to the same setpoint they were when the autonomous program stopped. They, thus, don't move.

Alan


Mon Feb 07, 2011 3:46 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Servo Position Issue
That's interesting. Our code initialized all servos to their proper positions in initrobot but some of them still decided to move to different positions before coming back to the positions we set them. That's why we concluded RobotC firmware was doing it. You are probably right about it being 128 instead of 0. I don't remember which extreme it was that the firmware init them, but it was different from our intented position.


Mon Feb 07, 2011 6:14 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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:  
cron



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