I have setup an "electric miter box" based on your tutorial. Works great. However, if you enter a value that is too high, it will work in reverse instead of moving forward.
I have a screw jack that moves 8mm on a single turn. I modified your formula to 'z * 1600 / 8' to care for this problem... works fantastic and accurate, but again, if you enter a value too high (such as 170 'mm'), instead of running from 0 - 170, it runs from 0 to -170.
I can't find anything in your code that corresponds to this error.
Please point me in the right direction.