View unanswered posts | View active topics It is currently Fri Aug 01, 2014 8:07 pm






Reply to topic  [ 12 posts ] 
Tetrix servos not working. 
Author Message
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Tetrix servos not working.
This is one of many iterations of my code that refuses to function on anyone's bot in my entire class. We're all using direct drive mantis with encoders. any input at all would be appreciated. Similar code worked once on my friends bot then never worked again. even with identical code.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S2,     sonar,          sensorSONAR)
#pragma config(Sensor, S3,     light,          sensorLightActive)
#pragma config(Sensor, S4,     touch,          sensorTouch)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoStandard)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main(){

while(true){
  nxtDisplayCenteredBigTextLine(3,"%d",SensorValue[touch]);
  while(SensorValue[touch]==1)
      servo[servo1]=200;
}
}


Tue Oct 29, 2013 11:19 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Tetrix servos not working.
What is the expected behavior? With your current code, if you started off with the servo turned to the zero position, when you press the touch sensor, it will turn the motor to the 200 position and then that's it. It will not move ever again. Try the following code, change it and play with it. You will learn how servo works.
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S2,     sonar,          sensorSONAR)
#pragma config(Sensor, S3,     light,          sensorLightActive)
#pragma config(Sensor, S4,     touch,          sensorTouch)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Servo,  srvo_S1_C2_1,    servo1,               tServoStandard)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
    int pos;

    while (true)
    {
        for (pos = 0; pos <= 255; pos += 10)
        {
            servo[servo1] = pos;
            wait1Msec(500);
        }

        for (pos = 255; pos >= 0; pos -= 10)
        {
            servo[servo1] = pos;
            wait1Msec(500);
        }
    }
}


Tue Oct 29, 2013 3:02 pm
Profile
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Re: Tetrix servos not working.
I tried that program and it causes no movement in the servos.


Wed Oct 30, 2013 9:59 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Tetrix servos not working.
If that's the case, there are two possibilities:
1. The servo is not wired correctly.
2. The servo is defective.

First, check the wiring. Make sure the servo controller is connected to the motor controller and then connected to the NXT sensor port 1. Also make sure both controllers have power (i.e. the red lights are ON). Also make sure the servo is connected to channel 1. If the wiring looks ok, you may want to plug in another servo in channel two and change the code to run the servo on channel two. If it is still not working, you may want to component test things separately to establish a working baseline. It means setting up another NXT brick with only the servo controller on sensor port 1, wire the servo controller with power, connect a servo in channel 1. Make sure the power switch is ON and run the program (make sure the program is changed to reflect only one servo controller). If that works, you have a working baseline. Then add a motor controller to the baseline configuration and test it again (change the code again to reflect one motor controller and one servo controller). If it is still working, you have a baseline that's equivalent to the robot and working. Then you replace the components on the robot with the components on the base line one at a time. First the servo, then the servo controller, then the motor controller and finally the brick. With this debug methodology, you should be able to pinpoint what's the culprit.


Wed Oct 30, 2013 12:14 pm
Profile
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Re: Tetrix servos not working.
I hate to do this to you, but I went through each step and i had no luck. Another student in my class also went through each step with no luck.


Fri Nov 01, 2013 10:41 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Tetrix servos not working.
Would you give me more info on what you did in each step and what was the result? "It doesn't work" doesn't give me any additional info.


Fri Nov 01, 2013 2:59 pm
Profile
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Re: Tetrix servos not working.
well i checked the wiring:
1. servo is connected
2. red lights are on
3. connected to channel 1
4. attempted channel 2 (no luck)
5. attempted a baseline with no luck

Image
picture of the baseline.


servo doesnt react at all.
Code:
#pragma config(Hubs,  S1, HTServo,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     sonar,          sensorNone)
#pragma config(Sensor, S3,     light,          sensorNone)
#pragma config(Sensor, S4,     touch,          sensorNone)
#pragma config(Motor,  motorA,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  motorB,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  motorC,           ,             tmotorNXT, openLoop)
#pragma config(Servo,  srvo_S1_C1_1,    servo1,               tServoStandard)
#pragma config(Servo,  srvo_S1_C1_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C1_6,    servo6,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
    int pos;

    while (true)
    {
        for (pos = 0; pos <= 255; pos += 10)
        {
            servo[servo1] = pos;
            wait1Msec(500);
        }

        for (pos = 255; pos >= 0; pos -= 10)
        {
            servo[servo1] = pos;
            wait1Msec(500);
        }
    }
}


Mon Nov 04, 2013 12:37 pm
Profile
Rookie
User avatar

Joined: Wed Dec 01, 2010 5:15 pm
Posts: 30
Post Re: Tetrix servos not working.
Have you tried rotating the servo plug 180 degrees?


Mon Nov 04, 2013 1:39 pm
Profile
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Re: Tetrix servos not working.
I have. No luck.


Mon Nov 04, 2013 2:24 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Tetrix servos not working.
In that picture, the servo plug appears to be plugged in backwards. I'm not sure if the servo has protection against such a scenario, but it could have fried your servo. While it's less likely, plugging the servo in backwards also may have damaged the HiTechnic servo controller (which is should be protected against).

_________________
Matt


Mon Nov 04, 2013 2:52 pm
Profile WWW
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Tetrix servos not working.
Yes, your picture showed the servo is connected backward. The yellow wire should be closer to the "Chan. 1" label. BTW, just for your reference, the servo controller has a label at the bottom close to chan. 6 saying "YRB" which means "Yellow Red Black". That's the order the colored wires are supposed to be. If it still not working after correcting the servo wires, you may want to get a different servo controller in case it was somehow damaged. You may also try a different servo motor. In general, I don't believe plugging it backward will damage the servo controller because our students did that a few times and they survived. But who knows, anything could have happened.


Mon Nov 04, 2013 3:49 pm
Profile
Rookie

Joined: Tue Oct 29, 2013 11:13 am
Posts: 12
Post Re: Tetrix servos not working.
So I doublechecked every aspect of the baseline and ran it again and it worked! :lol:

I then slowly tried integrating the parts on my bot until it stopped working to try and figure out the problem, and it just kept working. now I have replaced all of the baseline with my bot and it works perfectly. go figure. no clue what I changed. Thank you for your help my brothers, I would have been lost without ya.


Wed Nov 06, 2013 11:28 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 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.