A controller for a relay (R) controls the pull-in time of the armature of the relay by controlling the power applied to the relay coil (1). To determine the actual pull-in time, the time of closure of the contacts is sensed (37, 39) and the time at which power is applied to the coil (6) is subtracted from it (38). The actual pull-in time (at 40) is then compared (42) with a stored value (at 44) of ideal pull-in time to produce an error signal (46). The error signal corrects (14, 13) the level of power applied to the relay coil upon the next actuation of the relay, to make the actual pull-in time approximately equal to the ideal pull-in time.; In some embodiments, to control the level of power on the coil, a Grey-code counter (20) samples a duty-cycle register (14) in a microcomputer (4'') and produces a train of pulses (at 8'') that is filtered (53'', 55'') to provide a DC control signal (51''). The DC control signal controls the duty cycle of a pulse-width-modulated oscillator (9) that rapidly switches (modulates) the power to the relay coil.