pimoroni / ioe-python

Python library for the Nuvoton MS51 Pimoroni IO Expander Breakout
https://shop.pimoroni.com/products/io-expander
MIT License
8 stars 13 forks source link

PID Calculation #24

Closed metanav closed 1 year ago

metanav commented 1 year ago

Can you explain why the PID calculation includes a minus sign before the differential component?

https://github.com/pimoroni/ioe-python/blob/cebb0eaac32b0982ea054113900df43ab3e8969e/ioexpander/common.py#L33

I think the PID equation should be as follows.

image

metanav commented 1 year ago

I just realized that the rate_error is calculated using the previous and current process values, resulting in a negative error value, so the equation is correct. But we need to be careful while passing the value_change params.