I think your speeds are way too optimistic, try milliseconds instead of microseconds. I would also calculate a proper time interval, it's only a division (t=1/f).
Also you change direction in places that doesn't make sense. If you want to do a speed ramp, you need to ramp up and down to zero speed before changing direction.
Also you change direction in places that doesn't make sense. If you want to do a speed ramp, you need to ramp up and down to zero speed before changing direction.