the pulseDuration cant be less than 1000

Why can't it?

Just for the sake of argument, though, since you've show not output to show what average values you are getting for pulseDuration, lets assume that pulseDuration has a value of 3500.

3500/1000 is 3.5, but, since pulseDuration is an int, the result is 3.

0.057 / 3 = 0.019

As in int

`int speedVal = 0;`

that is 0.

As pulseDuration goes up, the dividend gets larger. Therefore, the result of the division operation gets smaller. It will never be greater than 1, so the speedVal will never be other than 0.

If pulseDuration exceeds 32767, it actually becomes negative, since 32767 is the maximum value of an int.

If pulseDuration is ever less than 1000, the division operation will result in a value of 0. Dividing 0.057 by 0 is not a good idea.