1. Field of the Invention
The present invention relates to a controller and a machining apparatus having the same.
2. Description of the Related Art
There has been known a technique of detecting the position of an object based on two periodic signals having a phase difference of 90° which are generated by an encoder for encoding an object position. A count value obtained by counting the periods of one of the two periodic signals indicates an object position in periods. On the other hand, the arctangent value of the ratio of the two periodic signal values indicates an object position during one period. A signal representing the final object position can be obtained by combining the count value and the arctangent value. Unless the period count operation and the arctangent value processing operation completely synchronize, periodic errors occur in the value obtained upon combining the count value and the arctangent value. Conventionally, processing of compensating the periodic errors is done based on only the current values of the two periodic signals.
However, as the movement of the object speeds up with respect to the sampling period, it becomes more difficult to compensate the above-described periodic errors caused by the lack of synchronism between the period count operation and the arctangent value processing operation.