The encoder includes a scale including first and second periodic patterns, and a detector relatively movable with respect to the scale and whose detection state is switchable between a first detection state to read the first periodic pattern and output a first signal and a second detection state to read the second periodic pattern and output a second signal. A spatial domain infinite impulse response filter is adapted to generate an output value of the spatial domain infinite impulse response filter related to an input signal. The insulating film is a multiple layer insulating film including a first insulating layer and a second insulating layer provided on the first insulating layer.