Did you see this post from grabik and also the next posts from him?
PID.ino
PID calculation:
*//Proportional
pValue = steerSettings.Kp * steerAngleError *steerSettings.Ko;
/* //Derivative
dError = steerAngleError - lastLastError;
dValue = Kd * (dError) * Ko;
//save history of errors
lastLastError = lastError;
lastError = steerAngleError;
*/
drive = pValue;// + dValue;
pwmDrive = (constrain(drive, -255, 255));
//add throttle factor so no delay from motor resistance.
if (pwmDrive < 0 ) pwmDrive -= steerSettings.minPWMValue;
else if (pwmDrive > 0 ) pwmDrive += steerSettings.minPWMValue;
if (pwmDrive > 255) pwmDrive = 255;
if (pwmDrive < -255) pwmDrive = -255;
*
8 byte PWM resolution on arduino nano(255) , for driver direction DIR pin, and PWM ,DIR pin LOW left side -255 max write to PWM 255 , right side DIR pin HIGH 255 max write to PWM 255 for max duty cycle.
For Danfoss valve not need DIR pin for change direction.