Thank you all for reply this post. I already solve the problem.
Here are the details:
The machine calibrate a Overload switch, to do this the machine has 3 stepper motor to move the screws in the switch. It has a analog sensor to measure the height of the bimetal and a load celll to measure the force needed to make the overload trip. So the machine its feeded it with a overload switch each time and do the calibration according the manufacture metrics.
When the machine detect a overload switch that can not be calibreated, the machine turn on an alarm and the operator need to press the stop bottom. With this the program reset all the registers and flags. The problem was that one of the flags wasnt reset when this happens. So the solution was reseting this flag.
This is one of my first project as a programmer, so I´m sure in going to find this forum very usefull.