I spoke too soon. I had tested the axis from Stepconf, and it ran back and forward for a few hours without changing position.
But now it's doing the same as before, i.e. not consistently going in the right direction.
It also doesn't always respond to changes of direction from the keyboard
The same thing happens if I connect the stepper to a different driver. And the other steppers connected to the X driver run fine. So there is no problem with the driver, or the BOB. The only thing I can think of is that there is something wrong with the motor, or the wiring from the motor to the drivers. But I have checked and rechecked the wiring.
I know which the pairs are, and if I switch the polarity of one pair, the motor goes in the other direction. (If I switch the polarity of both pairs, it goes in the original direction)
The motor moves with no abormal sound or vibration, and at the right speed. It just doesn't always go in the right direction.
The cables from the drivers to the motor are shielded (and connected to ground at the motor end).
I am stumped.