Hey kwakisaki. Thanks for your response. I would have shared the full code but our company policies do not allow it.
We are actually using the main to only execute the motion commands in a while loop, and these commands are taken from a command queue. The queue is filled by the TCP/IP communication program, which runs on a parallel PC Program. We have implemented semaphores to protect the queue. We had extensively tested these.
I'm very sure that no motion commands are being run when we put the robot in TEACH mode. It is true that we do not stop the CYCLE nor turn OFF the MOTORS before switching to TEACH mode. But it sounds very strange to me that when back to REPEAT (and MOTOR ON and CYCLE START) the robot has to move to the state in which it was before being put in TEACH.
Kawasaki support will come tomorrow but we fear they might not give us a good idea of why this is happening.