# Ensuring acurate turns

Hello all, our autonomous is very acurate(using. An integrated encoder) without stars, however whenever we pick up stars, our drive doesnt always make the turn, its short somtimes, however others it does fine, but sometimes it turns too short, is there any way to make this more acurate?

You can use a gyroscope to measure your turning instead of an encoder. It probably turns short because the weight of your robot increases with stars and the motors need more power to turn the same amount.

Yes, there are plenty of ways. A gyro can help as well, but you can do it with just the IME’s.

What are you using in your code to control the turn distance? Are you using a P or PID control or something like that? How far are your encoders off from what you want in your turns?

Are you slowly turning so the acceleration does not throw the stars off?

@Tesla_321 our other teams stole both of our gyros, so we dont have any for use, so that wont be an option
Thanks though

Really the code that you use to turn will change how to adjust it. What do you have now?

i dont have access to the actual code but this is the pretty much what i have

``````
motor[motor1]=-80
motor[motor2]=-80
motor[motor3]=80
motor[motor4]=80
waitUntil(sensorvalue[encoder]<-3850) //this is the value of the turn

``````

ill post the acutal code later, but thats the gist of it

Okay so that means before you were coasting a portion of the turn and that with extra weight you can no longer coast as far. So you need to set the goal encoder value to be higher.

no, the way we found the value is we turned it by hand, until we got the value we wanted, there was no caosting involved, the code acts like it ignores that, and just ignores thoes lines of code

Well that is the problem with Physics. There’s no breaking those rules!

The mass of your robot and stars in rotational momentum is keeping your robot moving. You say stop, but momentum carries it more.

The IME distance is correct, but you will notice in the debugger, that you will be different distances away from that target once you are done. Do this 10 different runs and see what you get each time. The distance away from the target is the error.

What you need is a control loop. This is going to manage your robot turning exactly to that target value. It reduces the error to minimal levels and you then stop on a dime.

Go through this example but do it for rotation. Proportional control on turning works well and is not that hard using this code as a baseline.
https://vexforum.com/t/simple-p-controller-for-arm-position/23699/1

@9065_parker
Turning is messy as far as encoders on powered wheels goes. Sometimes the wheels slip, sometimes they don’t, sometimes you slip more with a higher battery or especially if the star is dragging on the ground. If our robot turns while dragging a cube it’s crazy how much the wheels slip. Our solution is to have a free spinning wheel as far from the center of rotation as possible that is hooked up to an encoder and it works pretty well.