**IMPORTANT** IME and Quadratic Encoders fighting?

Hello, we are trying to set up an autonomous for our robot. We have a Quadratic encoder on the arm and an Integrated Motor Encoder on a claw motor. Whenever I program the autonomous to run both together, the Quadratic Encoder does not stop at the appropriate mark. Any help would be appreciated since we have a competition today. Thank you.

Have you verified both sensors are returning values that change when the sensor moves?

Yes. Both encoders are returning values, so I know they are reading.

Here is the current program I am using. Hopefully I have not done something wrong in the code.

You specified that there is problem when you run both together. Have you tried the autonomous with each individually to ensure that it works alone?

Yes, I have done that multiple times, and every time I test them alone, they work great, doing exactly what I expect them to do.

My first guess would be to try swapping the comparator on your while loop condition. Positive rotation for the motor has not always been positive rotation for the encoder for us. Or you can add code to measure the absolute value of the encoder, which would eliminate the problem entirely.

I may be wrong, but it appears they aren’t running concurrently. You have one while loop then another, so the second won’t even run until the first finishes. Have you tried using tasks?

Can you post your code? I think you are using two ‘if’ statements that cannot be ran simultaneously.
EDIT//: I may be wrong, but seeing the code will help.

Here is the code.

You also don’t seem to have code to stop the motors after the moves either. Except for your claw.

To be honest, I feel like that’s the derp I made. Let me check on that.

Edit “No, that didn’t help. It only makes the arm stay still.”

Okay, so what you are currently doing is that you are having a while loop for the code. What this means is that only one while loop can be ran at once(practically). If one while loop is going, then the other can’t run.
Try replacing “while” to “if” instead on all the while loops.
Hopefully this helps :slight_smile:
After that, put the whole code inside of “Task main()” in a “while(1==1)” loop to consistently run.
Another side note: Is this autonomous or driver control? I think you are also having an issue with brackets too…

I had the “while” statements changed to “if” statements, but that is what caused the are not to move.

It also doesn’t help that RobotC likes to crash if I go to a different window

You have this:

#pragma config(Motor, port6, leftclawMotor, tmotorVex393_MC29, openLoop, reversed, driveLeft, encoderPort, I2C_1)

and this:

mapEncoderToMotor(leftclawMotor, I2C_1);

Doesn’t seem right. Along with the other issues mentioned above.

Oh, didn’t read the main post. In my opinion I prefer doing a multitasking method in order to obtain more accuracy for your arm and claw, if you are trying to do autonomous.
EDIT//: When I have time, I will post my robot’s autonomous and I will show you how I did it.

What you want to do is enclose both


if

statements in a


while

loop, like this:

while(arm needs to move && claw needs to move){ //Prevent autonomous from moving on if either mechanism is in the wrong position
  if(arm needs to move){
    moveArm();
  }
  if(claw needs to move){
    moveClaw();
  }
}

Obviously this is not actual code.

Okay, so idk what exactly helped me the most, so I am just going to say that everyone here helped equally because NOW IT WORKS! Thank you to everyone who assisted me.