Are you using the stepmoveabs command? If that is the case the PLC needs to know where its current location is and it will then move in the direction to go to where stepcountabs=0. If the current location is lost then it could be moving in different direction from where you think it should go. Perhaps it will be good to put a limit switch at one end of the travel so that the motor will always move in the direction that goes to the correct end. If your homing sensor is somewhere in the middle then it is hard for the PLC to know which direction to turn if it loses its current location for whatever reason (power down, manual move etc).