Grid impedance affects the stability and control performance of grid-connected power electronic devices such as inverters used to integrate wind and solar energy. Adaptive control of such inverters to guarantee stability under different grid conditions requires real-time measurement of the grid impedance performed online by the inverters themselves. Existing online measurement methods based on broadband excitations such as maximum-length binary sequence (MLBS) require relatively high injection that may interfere with normal grid control functions, or degrade inverter output current quality, especially when the grid impedance is low and a high current needs to be injected in order to produce sufficient voltage perturbation. This paper proposes the use of a discrete-interval binary sequence (DIBS) for such cases. The DIBS is a computer-optimized binary sequence where the energy is maximized at specified harmonic frequencies to minimize the required level of signal injection. Experimental results based on a three-phase grid-connected inverter are presented to demonstrate the effectiveness of the proposed methods.