View unanswered posts | View active topics It is currently Fri Dec 19, 2014 2:13 pm






Reply to topic  [ 6 posts ] 
servo problem please help 
Author Message
Rookie

Joined: Tue Jan 13, 2009 12:24 pm
Posts: 10
Post servo problem please help
my team and i were trying to finalize our robot for atlanta and were having a problem with our servos. whats happening is we have all the servos set to do what there supposed to do, i press a button that only 1 servo is suppose to respond to and they all go at the same time. i tried switching controllers and nxts that didnt work. i wrote a line of code that only turned 1 servo and the others werent even programmed in and they still went, i dont know why this is happening
does anyone know how to fix this?


Mon Mar 29, 2010 10:46 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: servo problem please help
If you post your code, we may be able to provide more help.

You mentioned that you wrote a line of code to move only one servo. Was that inside your existing program or did you try creating a new clean program to test with?


Tue Mar 30, 2010 3:07 pm
Profile
Rookie

Joined: Tue Jan 13, 2009 12:24 pm
Posts: 10
Post Re: servo problem please help
I wrote a clean program, ill post my code shortly the internet is down at the moment so I'm having to use my phone


Wed Mar 31, 2010 8:52 am
Profile
Rookie

Joined: Tue Jan 13, 2009 12:24 pm
Posts: 10
Post Re: servo problem please help
#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, RR, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C1_2, LR, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_1, LF, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C2_2, RF, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S2_C1_1, shoot, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S2_C1_2, load, tmotorNormal, openLoop)
#pragma config(Motor, motorA, idle, tmotorNormal, PIDControl, encoder)
#pragma config(Servo, srvo_S4_C1_1, aim, tServoNormal)
#pragma config(Servo, srvo_S4_C1_2, trig, tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tele-Operation Mode Code Template
//
// This file contains a template for simplified creation of an tele-op program for an FTC
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// initializeRobot
//
// Prior to the start of tele-op mode, you may want to perform some initialization on your robot
// and the variables within your program.
//
// In most cases, you may not have to add any code to this function and it will remain "empty".
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

void initializeRobot()
{
// Place code here to sinitialize servos to starting positions.
// Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.

return;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main Task
//
// The following is the main code for the tele-op robot operation. Customize as appropriate for
// your specific robot.
//
// Game controller / joystick information is sent periodically (about every 50 milliseconds) from
// the FMS (Field Management System) to the robot. Most tele-op programs will follow the following
// logic:
// 1. Loop forever repeating the following actions:
// 2. Get the latest game controller / joystick settings that have been received from the PC.
// 3. Perform appropriate actions based on the joystick + buttons settings. This is usually a
// simple action:
// * Joystick values are usually directly translated into power levels for a motor or
// position of a servo.
// * Buttons are usually used to start/stop a motor or cause a servo to move to a specific
// position.
// 4. Repeat the loop.
//
// Your program needs to continuously loop because you need to continuously respond to changes in
// the game controller settings.
//
// At the end of the tele-op period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase

while (true)
{
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//// ////
//// Add your robot specific tele-op code here. ////
//// ////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////

// Insert code to have servos and motors respond to joystick and button values.

// Look in the ROBOTC samples folder for programs that may be similar to what you want to perform.
// You may be able to find "snippets" of code that are similar to the functions that you want to
// perform.




// shooter controls

int motorloadrunning = 0;
if(joy2Btn (6)) // load
{
motor[load] = -60;
motorloadrunning = 1;
}

if(joy2Btn (3)) // reverse load for ball jam
{
motor[load] = 30;
motor[shoot] = 100;
motorloadrunning = 1;
}
if(joy2Btn (8)) // load for shooting
{
motor[load] = -30;
motorloadrunning = 1;
}

if (motorloadrunning == 0)
{
motor[load]= 0;
}



if(joy2Btn (9)) // shoot
{
motor[shoot] = -100;
motor[idle] = -100;
}
if(joy2Btn (10)) // shooter stop
{
motor[shoot] = -0;
motor[idle] = 0;
}
if(joy2Btn(7)) // aim shooter
{
servo[aim] = 100;
servo[trig] = 10;
}
if(joy2Btn(5)) // trigger to hold balls
{
servo[trig] = 150;
servo[aim] =20;
}

if(joy2Btn(4)) // increase angle
{
servo[aim] += 2;
wait1Msec(100);
}

if(joy2Btn(2)) // increase angle
{
servo[aim] -= 2;
wait1Msec(100);
}

/////////////////////////////// base programming

if(abs(joystick.joy1_y1)>10)
{
motor[RR]= (int)(((float)joystick.joy1_y1/127.0)*100.0);
motor[LF]= (int)(((float)-joystick.joy1_y1/127.0)*100.0);
}
else
{
motor[RR]= 0;
motor[LF]= 0;
}

if(abs(joystick.joy1_x1)>10)
{
motor[RF]= (int)(((float)-joystick.joy1_x1/127.0)*100.0);
motor[LR]= (int)(((float)joystick.joy1_x1/127.0)*100.0);
}
else
{
motor[RF]= 0;
motor[LR]= 0;
}


while(joy1Btn(6)) //while button 6 on joystick 1 is pressed turn robot right / clocwise
{
motor[RR]=-100;//right turn
motor[LF]=-100;//right turn
motor[RF]=-100;//right turn
motor[LR]=-100;//right turn
}
while(joy1Btn(3)) //strafe right
{

motor[RF]=-25;//
motor[LR]=25;//
}
while(joy1Btn(1)) //strafe left
{

motor[RF]=25;//
motor[LR]=-25;//
}
while(joy1Btn(5)) //while button 5 on joystick 1 is pressed turn left or counter clockwise
{
motor[RR]=100;//left turn
motor[LF]=100;//left turn
motor[RF]=100;//left turn
motor[LR]=100;//left turn
}

while(joy1Btn(8)) //while button 6 on joystick 1 is pressed turn robot right / clocwise
{
motor[RR]=-25;//right turn
motor[LF]=-25;//right turn
motor[RF]=-25;//right turn
motor[LR]=-25;//right turn
}
while(joy1Btn(7)) //while button 5 on joystick 1 is pressed turn left or counter clockwise
{
motor[RR]=25;//left turn
motor[LF]=25;//left turn
motor[RF]=25;//left turn
motor[LR]=25;//left turn
}







}
}


thats our drive program, we added more servos now so we really need to know how come its doing what its doing. if i take the servo trig out of the lines on that button it still moves around with that button

and if i write a simple code that says if i press button 3 servo aim goes to this position, THEY ALL DO and i didnt even define them at the top. help please i dont know why this is happening


Wed Mar 31, 2010 12:27 pm
Profile
Rookie

Joined: Wed Feb 24, 2010 11:19 am
Posts: 8
Post Re: servo problem please help
We just had the same problem. Don't understand what happened, but not being able to use the servo controller as the 4th controller on sensor port 1, we had it on sensor port 4 (like you). We competed at our regional and when we got back home, the servos wouldn't move.

We tested new servos, replaced the servo controller, tried a second NXT, and created a clean program using the telop template with only the servo controller on port 4 and only code to move servo 1. It still didn't work. Next we moved the servo controller to sensor port 1 and it worked. It worked on port 2 as well.

So, we ended up moving the servo controller to sensor port 2 and the light sensor in port 2 to port 4. All is fine now. Still don't understand why it quit working on port 4 though.

Andy


Thu Apr 01, 2010 12:04 am
Profile
Expert

Joined: Mon Oct 27, 2008 9:59 pm
Posts: 139
Post Re: servo problem please help
I have to agree with Andy as I do not see any coding issues but I do recall reports from a few teams with issues specific to controllers on sensor port 4.

Try moving your servo controller to sensor port 1-3 and test again.
Please post the results back here and if it does fix your issue, email support@robotc.net to log a formal bug report. That is the easist way for them to log/track bugs, and thus the best way for us to see fixes.


Thu Apr 01, 2010 10:44 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.