Go Down

Topic: PID does not sense negative values. (Read 1 time) previous topic - next topic

dvl12

I managed to solve this problem by introducing two PIDs in the code and multiplying input for one of them by (-1), however, it is not an elegant solution and I am still looking for a solution using single PID?

PeterH

I don't think it's related to your problem, but I think the call to SetOutputLimits() should be in setup(), not in loop().

I can't see any reason why that wouldn't work for negative input values. Can you post some examples of the trace output with positive and negative input values?
I only provide help via the forum - please do not contact me for private consultancy.

dvl12

For example:

Angle    Amplitude
10        10
20        20
80        80
0          0
-10       0
-30       0
-80       0

I made it up myself, but this is what I see is going on when reading a serial monitor.

PeterH

Well, you've set the output limits to 0, 180, so it can't go negative. What do you expect it to do in that case?
I only provide help via the forum - please do not contact me for private consultancy.

dvl12

I did not want getting any negative amplitudes. I was expecting it to increase amplitude when angle is not zero.

Go Up