View unanswered posts | View active topics It is currently Sat Jul 26, 2014 7:11 am






Reply to topic  [ 4 posts ] 
TETRIX servo not returning correct value 
Author Message
Rookie

Joined: Mon Oct 04, 2010 8:40 am
Posts: 13
Post TETRIX servo not returning correct value
hey im not sure if the tetrix servos are really third party sensors but i figured this fit the post the best.

so here is my code
Code:

    if(joy1Btn(6) != 0) //If Joy1-Button6 is pressed
      {
        servoTarget[servo1] = ServoValue [servo1] + 1; // Adds an Integer to servo1's current position
      }
    if(joy1Btn(8) != 0) //If Joy1-Button8 is pressed
      {
        servoTarget[servo1] = ServoValue [servo1] - 1; // Subtracts an Integer to servo1's current position
      }



so when i press the buttons servo 1 just jumps to either the farthest or the closest it can the code is supposed to make servo1 move slowly until the button is released. It used to work but ever since my team messed with the robot it hasn't worked. I haven't changed the code at all and I made sure the servo and everything else was plugged into the port it was plugged into before. another thing to note is that it worked when i was at 2.25 then i updated the software and firmware on the nxt to 2.26 while my team was messing with the robot. could that be it?


Mon Nov 22, 2010 7:45 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 137
Post Re: TETRIX servo not returning correct value
As long as the servo is responding to your input, it is likely wired correctly even if it does not act as you expect.

Looking at your code, it seems possible that that servo target is being set and incremented rapidly as the program loops. Have you noticed the servo moving further depending on how quickly you release the button on the joystick? It only takes a second for the code to loop many, many times. If this is the case, you may need to add some sort of wait/timer when manually incrementing/decrementing.

Lastly, your code has no limits set to prevent the servo from rotating its full degree of movement. This may be what you want, but generally you want a servo to only move between two specific points that are within the full range. Below is some sample code similar to yours but with an added range check for safety. You just change the value of the two constants to set the correct limits.
Code:
//manual servo control
const int SERVO_OPEN_POSITION = 127;
const int SERVO_CLOSED_POSITION = 0;
if(joy1Btn(6) && ServoValue(servo1) < SERVO_OPEN_POSITION) //manual open
{
   servoTarget(servo1) = ServoValue(servo1) + 1;
}
else if(joy1Btn(8) && ServoValue(servo1) > SERVO_CLOSED_POSITION //manual close
{
   servoTarget(servo1) = ServoValue(servo1) - 1;
}


Tue Nov 23, 2010 9:55 am
Profile
Rookie

Joined: Mon Oct 04, 2010 8:40 am
Posts: 13
Post Re: TETRIX servo not returning correct value
Thanks for the code but it didnt work. I did, however, find the problem. My team switched the normal servos with continuous rotation servos, which need to be addressed differently in the #pragma

#EDIT

I do have a new problem now though. the problem I described above seems to be affecting ALL 360 degree servos, no matter if I set them as standard servos or continuous rotation. Are these continuous servos supposed to keep going and never stop?


Mon Nov 29, 2010 12:52 pm
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 137
Post Re: TETRIX servo not returning correct value
Continuous rotation servos have their potentiometer disabled and therefore have no positional feedback and act more like motors than servos. You can't tell them to go to a specific location anymore, just to go a certain direction/speed.

Depending on your need/intent, you may want to put the 180 degree normal servos back in?

Also, FYI that there is an FTC specific sub-forum here which may get you more responses in future posts related to FTC:
http://www.robotc.net/forums/viewforum.php?f=52


Tue Nov 30, 2010 11:10 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.