Method and device for controlling the power supply of an electromagnetic actuator