Problem with Lib PID Arduino

Hello all,
I am a newbie. Please help me! I have a problem when i use lib PID to control 2 DC motors. Code is ok. I send position + "X" to motorA and position + "Y" to motor B. But motor just receive PWM >0 in one time. And the others have pwm=0, I dont know how code can do that.
Please help me! Thanks in advance!

PID arduino.txt (6.34 KB)

char buf[4];
      inputString.toCharArray(buf, 5);

Your array can not hold 5 characters. Why would you lie to the toCharArray() method and say that it can?

Using PID with data input from the serial monitor does not make sense.

sorry, because i am a newbie. But my code, build is ok. I printed this char and this char was exactly position. And when inputString.toCharArray(buf, 4) and char buf just have 3 characters.
I dont use serial monitor, I use webcam and c++ to send position for arduino.
Thanks you, because reply

But my code, build is ok.

No, it isn't. You may not have experienced an issue yet, but your code is wrong. You can not write 5 elements into a 4 element array.

I dont use serial monitor, I use webcam and c++ to send position for arduino.

So, Input is a position. The position of what? Setpoint is never given a value, so the PID algorithm is computing Output to make Input converge on 0. Is that what you expect?

How does the motor speed relate to position?