PowerBroker2 / ArduPID

PID library for Arduinos with greater accuracy than the legacy Arduino PID library
MIT License
85 stars 23 forks source link

how to tune setOutputLimits for two different motor? #13

Open ghost opened 1 year ago

ghost commented 1 year ago

I am using this code to control the speed of two dc motors. But the output is not what I am expecting. I have set the bias to 0 as I only wish to get the PID value for my error. As I am using two motors and want them to work like differential, I plan to manually add and subtract the PID value with my motor's base speed (base speed = 200). But the problem is when I set output limits to (0, 255), after mycontroller.calculate() I am getting an output value of either 0 or 255 resulting in my ultimate motor speed1 = base speed + output = 455 and motor speed2 = base speed - output = -55. But I expect a value between 0 and 255 depending on the error. Any hints on how I can achieve that?

PowerBroker2 commented 1 year ago

I'm not sure I understand your approach/issue, but regardless: the bias is the output bias. Usually, this is set to the midpoint between your min and max output