A vibrating system with impacts, which can be applied to model the cantilever beam with a mass at its end and two-sided impacts against a harmonically moving frame, is investigated. The objective of this study is to determine in which regions of parameters characterizing system, the motion of the oscillator is periodic and stable. An analytical method to obtain stable periodic solutions to the equations of motion on the basis of Peterka's approach is presented. The results of analytical investigations have been compared to the results of numerical simulations. The ranges of stable periodic solutions determined analytically and numerically with bifurcation diagrams of spectra of Lyapunov exponents show a very good conformity. The locations of stable periodic solution regions of the system with a movable frame and two-sided impacts differ substantially from the locations of stable periodic solution regions for the system: (i) with a movable frame and one-sided impacts and (ii) with an immovable frame and two-sided impacts.