br3ttb / Arduino-PID-AutoTune-Library

416 stars 225 forks source link

possible lastInputs overrun #4

Closed br3ttb closed 11 years ago

br3ttb commented 12 years ago

Question: Wont the following code run off the end of the lastInputs Array?

nLookBack could potentially be 100, in which case 'i' starts at 99, the end of the array, only for lastInputs[100] to eventually be updated. I would think the array should be declared of size 101 to fix this, yes?

for(int8_t i=nLookBack-1;i>=0;i--) { double val = lastInputs[i]; if(isMax) isMax = refVal>val; if(isMin) isMin = refVal<val; lastInputs[i+1] = lastInputs[i]; }

t0mpr1c3 commented 12 years ago

yes... looks like

br3ttb commented 11 years ago

changed the size to 101.

olewolf commented 8 years ago

Thanks for your PID library and the autotuner. Two questions:

Looking at the code, it appears that the PID should be set to MANUAL while the autotuner is running, and that the autotuner controls the output in the meantime. Is this correct?

I assume the autotuner doesn't support the PID's REVERSE mode, right?