potentiometer

We are programming the arm with a window motor in java. We are using the potentiometer as reference for the joystick. When the degrees of the potentiometer is greater than the degres of the joystick, the motor will spin until both are in the same degree, and When lower, it will spin to the other position. Always watching the same degrees of the joystick.

we are using this code:

Joystick joystick = new Joystick(1);
Jaguar Motor = new Jaguar(1);
AnalogChannel potentiometer = new AnalogChannel(1);
PIDController controling = new PIDController(0.1, 0.001,0.0, potentiometer, Motor);
}
controling.enable();
while (isOperatorControl()) {
controling.setSetpoint((joystick.getX() + 1.0) * 2.5);
Timer.delay(0.10);

Is not working, we think that may be the potentiometer or the code, so my question is, is this code right? if we change the potentiometer it will work?

sorry for bad English, and if we don’t leave everything clear is because we are not familiar with forum.

The X axis of a joystick is the left-right axis. Is that what you wanted to use?

Get a multimeter and check the voltage the potentiometer is giving you. for different arm positions.

Also, the potentiometer is plugged into the Analog Breakout board, right?

Yes, but when we run the program, the motor does not stop when the joystick and potentiometer are equal, he keeps turning and stopping and going back to spinning the opposite side.

How did you determine your PID constants? Sounds like you need to do some tuning.

Do some debugging. Look at the error term when “the joystick and potentiometer are equal”. If the error is not zero, you’ve got a scaling or offset problem between your setpoint and your process variable.