View unanswered posts | View active topics It is currently Wed Apr 16, 2014 5:54 pm






Reply to topic  [ 9 posts ] 
Servo Programming Issue 
Author Message
Rookie

Joined: Mon Jan 03, 2011 10:52 pm
Posts: 22
Post Servo Programming Issue
Hi,

Here is my current code:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Hubs,  S2, HTMotor,  none,     none,     none)
#pragma config(Hubs,  S4, HTServo,  none,     none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     rightMotor,    tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C2_1,     leftMotor,     tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S2_C1_1,     conveyorMotor, tmotorNormal, openLoop, encoder)
#pragma config(Servo,  srvo_S4_C1_1,    rightsideDoor,                     tServoNormal)
#pragma config(Servo,  srvo_S4_C1_2,    rightsideconveyorLift,                     tServoNormal)
#pragma config(Servo,  srvo_S4_C1_3,    leftsideconveyorLift,                     tServoNormal)
#pragma config(Servo,  srvo_S4_C1_4,    latch,                     tServoNormal)
#pragma config(Servo,  srvo_S4_C1_5,    hopper,                     tServoNormal)
#pragma config(Servo,  srvo_S4_C1_6,    leftsideDoor,                     tServoNormal)


task main()
{
  servo(rightsideDoor) = 500;
  servo(rightsideconveyorLift) = -500;
  wait1Msec(2000);
}


There are 2 issues I have with this program.

1.) When I use this code, it activates an extra servo to a preset position. Not really sure why, since I don't have it initializing anything.

2.) These are both continuous servo's. They run much longer than the 2 seconds I have assigned to them, it's more like 10 seconds.

Any help to fix this is appreciated.

Thanks,

Tim


Wed Jan 19, 2011 10:14 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1342
Post Re: Servo Programming Issue
We observed the same thing. I assume the initialization of all servos must have been done by NXT firmware automatically on first servo use. That's annoying because we have loaded our arm with some batons but when autonomous starts, the NXT intiailization would dump them all on the floor before our initialization takes over and resets the arm servo to the proper position. We avoid this problem by loading the batons after the initialization is done. I hope the RobotC folks will fix this for next year.


Wed Jan 19, 2011 1:38 pm
Profile
Rookie

Joined: Mon Jan 03, 2011 10:52 pm
Posts: 22
Post Re: Servo Programming Issue
Well this is a giant issue, especially considering that it initializes our arms to be outside of the starting box. I'll have to check to see if it remains under power after it initializes, if not it's not that big of an issue as I can just fold it all back in.

Sadly, I won't be able to work on it tonight, but I will see if this is the case tomorrow (unless I can get in touch with the school and get in to get the robot to take home with me).

If anyone else has had this issue, please let me know. I'd love to see how many teams this is actually affecting.

Thanks,

Tim


Wed Jan 19, 2011 2:06 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1342
Post Re: Servo Programming Issue
What you can do is to write your own servo intialization code before waitForStart so it will return the servo to the position you want before waiting for autonomous start.


Wed Jan 19, 2011 2:42 pm
Profile
Rookie
User avatar

Joined: Mon Feb 23, 2009 12:40 pm
Posts: 27
Post Re: Servo Programming Issue
Well MHTS beat me to the initialization part. As for the servos not stopping, you don't send a command to stop the servos. Your program simply ends. The servos will continue until the servo controller times out (I think). I really wish there was a way to get the controllers to time out sooner if they do not get a command to halt the servos or motors. We are still trying to figure out why our robot lost control in a match in the finals in MD last month. If we could time out these controllers quicker, then maybe we could have prevented a smoked motor....but that is another issue.


Wed Jan 19, 2011 2:50 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1342
Post Re: Servo Programming Issue
Hmm, that's interesting. Never try continuous servo but I would expect when the program ends, all motors and servos are shut down. At least the main motors do.


Wed Jan 19, 2011 2:57 pm
Profile
Rookie

Joined: Wed Feb 24, 2010 11:43 pm
Posts: 34
Post Re: Servo Programming Issue
People have answered part of your question:
you can definitely preset the servos in an initializerobot() type routine before the autonomous starts. When the first servo is initialized all of them are. If you don't supply an initialize value, they automatically go to 128.

the other part is the servos not stopping after the program stops.
The obvious thing to do is to stop the servos at the end of the program (then wait 50mSec or so for the servo task to send it). if you set a value of 127 to the continuous rotation servos, they stop moving.

BTW, your values (-500 and 500) are a bit odd... servos only react from 0 to 255, any more than that it may wrap around and may or may not give the results you really want. From experimentation we've found that continuous rotation servos really only react at 128 +/- 48 (about)... in other words, going 255 is the same as going 176... and going 0 is the same as 80.


Thu Jan 20, 2011 12:44 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1342
Post Re: Servo Programming Issue
Yes, I agree that you should always stop the motors/servos before the program ends. However, at competition, your program does not end. It is usually in a never-ending loop. So it may not be possible to determine "end" and stop everything. The field control system will just "kill" your program. As far as I know, when your program gets killed, the motors stop. That's why I assume the same for servos. But since I never use continuous servo, I am not positive.


Thu Jan 20, 2011 1:52 pm
Profile
Rookie

Joined: Mon Jan 03, 2011 10:52 pm
Posts: 22
Post Re: Servo Programming Issue
For the values I had assigned to continuous servo's I noticed that they were incorrect. I had thought that you would set the angle that it should be. But now that I know that I can adjust for it.

Thanks guys. Another question is coming :)


Thu Jan 20, 2011 8:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 9 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.