Methods and systems for controlling a turbocharger associated with an engine. The turbocharger is operated in a region of operation creating potential surge conditions, but surge is avoided by varying the speed of the turbocharger in accordance with speed parameters determined by observing a resonant frequency of surge in the system.