|
Page 1 of 1
|
[ 3 posts ] |
|
| Author |
Message |
|
FTC_Team_4024
Rookie
Joined: Sat Jan 08, 2011 5:00 pm Posts: 2
|
 Servos Not Responding
The problem my team is having is that the servos on our robot are not responding. I've checked the motor and sensor setup multiple times and it matches what we have on the robot. I'm not sure what is wrong with our servos. Here is the code:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor) #pragma config(Sensor, S2, sonic, sensorSONAR) #pragma config(Sensor, S3, magnetic, sensorNone) #pragma config(Motor, motorA, , tmotorNormal, openLoop) #pragma config(Motor, motorB, , tmotorNormal, openLoop) #pragma config(Motor, motorC, , tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_1, leftF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, leftB, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, rightB, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, rightF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_1, collector, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_2, Rotator, tmotorNormal, openLoop) #pragma config(Servo, srvo_S1_C3_3, dispenser, tServoStandard) #pragma config(Servo, srvo_S1_C3_4, bridge, tServoStandard) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
void initializeRobot() { servo[bridge] = 255; servo[dispenser] = 5; return; }
task main() { initializeRobot();
waitForStart();
while (true) { getJoystickSettings(joystick);
if(joy1Btn(1) == 1) {
motor[leftF] = 100;
motor[rightF] = 100;
motor[leftB] = -100;
motor[rightB] = -100; }
if(joy1Btn(2) == 1) {
motor[leftF] = 100;
motor[rightF] = -100;
motor[leftB] = 100;
motor[rightB] = -100; }
if(joy1Btn(3) == 1) {
motor[leftF] = -100;
motor[rightF] = -100;
motor[leftB] = 100;
motor[rightB] = 100; } if(joy1Btn(4) == 1) {
motor[leftF] = -100;
motor[rightF] = 100;
motor[leftB] = -100;
motor[rightB] = 100; } if(joy1Btn(4) == 0 && joy1Btn(3) == 0 && joy1Btn(2) == 0 && joy1Btn(1) == 0 && joy1Btn(5) == 0 && joy1Btn(6) == 0) { motor[leftF] = 0;
motor[rightF] = 0;
motor[leftB] = 0;
motor[rightB] = 0; } if(joy1Btn(7) == 1) {
motor[leftF] = 100;
motor[rightF] = 100;
motor[leftB] = 100;
motor[rightB] = 100; } if(joy1Btn(8) == 1) {
motor[leftF] = -100;
motor[rightF] = -100;
motor[leftB] = -100;
motor[rightB] = -100; } //If button 2 is pressed, the bridge pusher thingy will push the bridge. if(joy1Btn(5)== 1) {
servo[bridge] = 61; } //If button 3 is pressed, the bridge pusher thingy will go back to its original position. if(joy1Btn(6)== 1) { servo[bridge] = 255; } //If joystick 2 is moved left or right on the x axis on the second controller, then the baton dumper will tilt left or right. if (joy2Btn(2) == 1) { servo[dispenser] = 30; } if (joy2Btn(2) == 0) { servo[dispenser] = 5; } //If joystick 1 is moved forward or backward on the x axis on the second controller, then the baton collector tread thing will move forward or backwards. I'm thinking maybe we should disable the backwards part altogether. if (joystick.joy2_y1 > 20 || joystick.joy2_y1 < -20)
{ motor[collector] = .5*joystick.joy2_y1; }
else
{ motor[collector] = 0; }
if (joystick.joy2_y2 > 10 || joystick.joy2_y2 < -10)
{ motor[Rotator] = .2*joystick.joy2_y2; }
else
{ motor[Rotator] = 0; } }}
|
| Sun Mar 27, 2011 7:53 pm |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 Re: Servos Not Responding
First of all, it would be nice if you put your code in tags to make it more readable. Second, what do you mean that your servos aren't responding? what exactly do they do? Try this code and see if it works:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor) #pragma config(Sensor, S2, sonic, sensorSONAR) #pragma config(Sensor, S3, magnetic, sensorNone) #pragma config(Motor, motorA, , tmotorNormal, openLoop) #pragma config(Motor, motorB, , tmotorNormal, openLoop) #pragma config(Motor, motorC, , tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_1, leftF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, leftB, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, rightB, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_2, rightF, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_1, collector, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C4_2, Rotator, tmotorNormal, openLoop) #pragma config(Servo, srvo_S1_C3_3, dispenser, tServoStandard) #pragma config(Servo, srvo_S1_C3_4, bridge, tServoStandard) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main(){ while(true){ servo[dispenser] = 255; servo[bridge] = 255; wait1MSec(1500); servo[dispenser] = 0; servo[bridge] = 0; wait1MSec(1500); } }
|  |  |  |  |
I don't know how your robot is set up, so make sure that moving the servos back and forth at the same time as each other won't break it. If you run the program, do the servos move back and forth?
_________________ sudo rm -rf /
|
| Sun Mar 27, 2011 8:06 pm |
|
 |
|
rperera
Rookie
Joined: Sat Apr 02, 2011 3:15 pm Posts: 6
|
 Re: Servos Not Responding
I would suggest removing the servos so that they can rotate 360 degrees without interference before trying the code.
--Ryan
|
| Sat Apr 23, 2011 6:01 pm |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 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
|
|