View unanswered posts | View active topics It is currently Thu Jul 24, 2014 10:42 am






Reply to topic  [ 3 posts ] 
Problem with Servo Motors? 
Author Message
Rookie

Joined: Thu Mar 25, 2010 10:07 am
Posts: 2
Post Problem with Servo Motors?
I'm using the vex servo motors with a robot I'm building. The problem is, (a) They don't work, (b) They seem to corrupt the robot, so after I plug them in, I have to redownload the firmware to upload a new software. I'm on RobotC 1.7 beta (It's for school and the admins haven't let me update yet) Here's my source code
Code:
#pragma config(Sensor, in4,    rightLight,          sensorReflection)
#pragma config(Sensor, in5,    leftLight,           sensorReflection)
#pragma config(Sensor, in9,    Ultrasonic,          sensorSONAR, int1)
#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  port8,           servo,         tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

//Directions:
//    1: Forward
//    2: Left
//    1: Right
//    1: Backward

int move(int timeMoving,int direction);
void turn_off();

task main () {
   
    // Starting Values
    int darkValue = 180;
    int robotMaxDistance = 20; //Robot sensed with 60"
    //Wait Seven Seconds after turned on
    turn_off();
    wait1Msec(3000);
    //Continuously Loop
    while (true) {
//Detect for Robot
if (SensorValue(Ultrasonic) < robotMaxDistance) {
//turn servo motor left
motor[port8] = -127;
} else {
//turn servo motor right
motor[port8] = 127;
}
//Detect edges of Ring
if(SensorValue[rightLight] >= darkValue || SensorValue[leftLight] >= darkValue)  {
move(80, 90);
//if both sensors are black move away
if (SensorValue[rightLight] >= darkValue && SensorValue[leftLight] >= darkValue){
turn_off();
move(600, 4);
move(800, 3);
}
//if right sensor is black move away
if(SensorValue[rightLight]  >= darkValue) {
turn_off();
move(600, 4);
move(800, 2);
}
//if left sensor is black move away
if(SensorValue[leftLight] >= darkValue) {
turn_off();
move(600, 4);
move(800, 3);
}
//// if the sonar pointed toward the left, turn right,
} else if (motor[port8] >= 50) {
move(1, 3);
//if the sonar pointed toward the left, turn left,
} else if (motor[port8] <= -50) {
move(1, 2);
//else if it's not right or left, move forward
} else {
move(1, 1);
}
    }       
}

int move(int timeMoving,int direction) {
    //beginning variables set
    int left_speed;
    int right_speed;
    int leftMotorValue = 127;
    int rightMotorValue = 100;
//if forward
    if (direction == 1) {
left_speed = leftMotorValue;
right_speed = rightMotorValue;
//if left
} else if (direction == 2) {
left_speed = leftMotorValue;
right_speed = -rightMotorValue;
//if right
} else if (direction == 3) {
left_speed = -leftMotorValue;
right_speed = rightMotorValue;
//if backward
} else if (direction == 4) {
left_speed = -leftMotorValue;
right_speed = -rightMotorValue;
}
    //move
motor[port2] = left_speed;
motor[port3] = right_speed;
    //stay moving
wait1Msec(timeMoving);
return 0;
}

void turn_off() {
    //Shut down
    motor[port3]= 0;
    motor[port2]= 0;
    //wait
    wait1Msec(100);
}


Thu Mar 25, 2010 10:11 am
Profile
Rookie

Joined: Sat Nov 22, 2008 8:06 pm
Posts: 48
Post Re: Problem with Servo Motors?
I don't know what you've tried so far, but your battery could be low. If you have another Vex around you could try the motors on it, and try other motors.

Is this a problem that you have had since you started programming, or did it just start?

Tell the admins that I said you could upgrade. Tell them I'm from the RobotC forum, but don't tell them I'm just a member.


Thu Mar 25, 2010 9:03 pm
Profile
Rookie

Joined: Thu Mar 25, 2010 10:07 am
Posts: 2
Post Re: Problem with Servo Motors?
bluesaberist wrote:
I don't know what you've tried so far, but your battery could be low. If you have another Vex around you could try the motors on it, and try other motors.

Is this a problem that you have had since you started programming, or did it just start?

Tell the admins that I said you could upgrade. Tell them I'm from the RobotC forum, but don't tell them I'm just a member.


Thanks good advice. I've tried charging the battery, as well as using different batteries. Once I can get my hands on the robot again, I'll try

1) Using the servo with a different robot

2) Using a different servo (maybe this one just doesn't work)

3) Using a normal motor to see if it is the servo's problem.

I noticed that when I define the servo motor, it is defined in the same way as the other motors:
Code:
#pragma config(Motor,  port8,           servo,         tmotorNormal, openLoop)

Shouldn't it be defined as closedLoop, or something of that sort?


Fri Mar 26, 2010 3:16 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.