Popping Out Of Gear
When a tractor pops out of gear there are really three main things that can be happening.
1)- The gears are beveled.
This is typically caused by shifting while the tractor is moving. The Yanmar transmissions (except for the powershift models) are not synchronized. That grinding you hear when you are trying to shift is the gears slowly grinding each others teeth down until they will no longer lock into place correctly.
2)- The detent ball is damaged or the detent spring is weak or damaged.
When you shift normally you can feel a gear snap into place. This is because there is a spring loaded ball inside the shifter fork snapping into a a dent in the shifter rail. When the ball gets wore down or the spring gets weak or broken the ball will not snap into the dent and there is noting really locking the gear in place. This wear is just due to normal usage and can not usually be prevented. Replacing the detent ball or springs will fix the problem.
3)- A shifter Fork Is Bent
The way this normally happens is the shifter is pushed too hard and the fork gets bent. If the fork is bent it may not move the gear far enough to allow it to snap into the detent position. If it does not snap into the detent then there is nothing to hold it in gear and it will pop back out. Replacing the fork or trying to straighten the fork is the only way to fix this.