If the I coefficient is negative, then the expression maxError=maxIOutput/I will be negative, resulting in the later expression errorSum=clamp(errorSum+error,-maxError,maxError) always returning maxError or largest possible negative value. The very next tick this will bump against the minOutput and get reset, with the result that any negative I coefficient will cause the output to continuously alternate between a small value and a large negative value every other tick.
I think the maxError expression needs to divide by abs(I).