I suppose that you are referring to a Wiley–McLaren time‐of‐flight mass spectrometer [Rev. Sci. Instr. 65, 3344 (1994)] which is basically a tube containing an electrode stack for accelerating the ions toward a detector. As mentioned in the comments, one can discriminate different masses if one uses a pulsed experiment, for instance using pulsed lasers or pulsed electric fields to extract the ions.
Another option is to add a magnetic field to the setup in order to bend the trajectory of the ions. The radius of the trajectory depends on the mass-to-charge ratio of the ion and one can record spectra as a functoin of the magnetic field to get a certain mass selected or use a position-sensitive detector to measure several masses simultaneously.
Yet another solution is to use quadrupole–time-of-flight mass
spectrometry, where radio frequencies are applied to four electrode rods placed on the circumference of a circle. Depending on the frequency that is applied to the rods, only ions of a certain mass-to-charge ratio make it out of the quadrupole and the qaudrupole thus serves as a mass filter.
Note that all these techniques are sensitive to the mass-to-charge ratio only and one cannot distinguish between, e.g., O$^+$ and S$^{2+}$.