Autonomous Troubles

In our Programming Skills program, our 6 bar linkage barely raises at all. We use Integrated Motor Encoders on the two 393’s powering the claw. In Driver Control, it works fine, but not in Autonomous. I’m suspecting this is a problem with our code. Here is our library: www.vexforum.com/local_links.php?action=jump&catid=26&id=256 and here is our programming skills program: www.vexforum.com/local_links.php?action=jump&catid=26&id=259. It was working before, but now it simply doesn’t raise up at all. I’ve checked, and the encoders are working fine. The values are reversed for some reason (they shrink into negative numbers when the arm raises) but that shouldn’t influence the program. Any ideas? If needed, I can post a video. I really have no idea why this would be happening.

So in autonomous you start this task first.

StartTask(armTurnPos);

This task is as follows (I post for other to look at)

task armTurnPos
{
  nMotorEncoder[rightArm]=0;
  nMotorEncoder[leftArm]=0;
  while(true)
  {
    if(nMotorEncoder[rightArm]<200)
     {
     motor[rightArm]=60;
     }
    else if(nMotorEncoder[rightArm]>200)
     {
     motor[rightArm]=-60;
     }
    else
     {
     motor[rightArm]=0;
     }
     
    if(nMotorEncoder[leftArm]<200)
     {
     motor[leftArm]=60;
     }
    else if(nMotorEncoder[leftArm]>200)
     {
     motor[leftArm]=-60;
     }
    else 
     {
     motor[leftArm]=0;
     }
   }
}

I wonder if “60” is enough power for the motors to raise the arm, I suspect not. Where did you determine that “200” was a good limit for the encoder to reach? In other arm tasks such as below you use larger numbers but again where did the number “700” for the encoder count come from? The IME for a 393 has 627.2 ticks per revolution (in torque mode, according to the product page) so you are only going to turn the motor about once, depending on your gearing that’s not very much. I will try the code tonight and see what’s happening.

task arm11
{
  LCDinit();
  nMotorEncoder[rightArm]=0;
  nMotorEncoder[leftArm]=0;
  
  while(true)
    {
    clearLCDLine(1);
    LCDdisplayn(nMotorEncoder[leftArm], 1);
    
    if(nMotorEncoder[rightArm]<700)
     {
     motor[rightArm]=120;
     }
    else
     {
     motor[rightArm]=10;
     }
    
    if(nMotorEncoder[leftArm]<700)
     {
     motor[leftArm]=120;
     }
    else
     {
     motor[leftArm]=10;
     }
   }
}

Well, armTurnPos just needs to raise the arm a little bit. What we are having problems with is the arm11 part. When testing, I saw that 1200 was full height for the encoders, so I thought 700 would be good for 11 inches. We have a lot of gearing, so the motor doesn’t need to turn much. Any idea what is happening?

Why do you say this? You expect the value to count up for a raising arm.

I notice that leftArm and rightArm motors are setup the same (no reversal), that’s unusual to me. The IME’s are setup to always count up when the motor turns forward, that is, a positive control value sent to it (even if reverse bit is set). If you have reversed a motor by swapping the 2 wire cable polarity then the IME may count down. Is there a picture of your robot posted somewhere so we can all see how it works.

Here are some photos: photos

It looks like you have 1:5 gearing on the arm. If the arm moves through say 120 deg then the change in encoder count would be 5 x (120/360) x 627 = 1045, so the 1200 count change you observed is about right.

First thing I would check is that the two encoders count the same, use the ROBOTC debugger and look at the sensors window. I would expect that perhaps they count in opposite directions. If they do then fix the wiring on the left arm so red wire matches red wire between motor controller and motor, it looks reversed. Then change the motors and sensors setup so left arm is reversed. Now check the encoders again and they should both count forwards. See if that helps first. This does not fully explain what you are seeing, if things are like I described then the left motor may not stop as the encoder count would decrease rather than increase.

Thank you! I checked the encoder values and sure enough, they were reversed. I reversed the wire and now it works! Thanks again!