The mechanical systems were modeled using various combinations of mass-damper-spring elements to analyze the system dynamics and improve the system stability. Due to the marginal stability property of the mass-damper rectilinear system, a proper control law is required to control the mass position accurately, improve the relative stability, and enhance the dynamical response. In this paper, a mathematical model of the electromechanical system was first derived and analyzed. Next, a digital PID controller was developed based on the root locus technique, and a systematic design procedure is presented in detail. The proposed digital control system was simulated in MATLAB and compared with other control schemes to check their tracking performance and transient response characteristics. In addition, the digital PID control algorithm of the mass-damper rectilinear system was implemented via dSPACE platform to investigate the real-time control system performance and validate the control design methodology. It has been shown that the digital PID controller yields zero percentage overshoot, fast transient response, adequate stability margins, and zero steady-state error.