Grid adaptation in two-point boundary value problems is usually based on mapping a uniform auxiliary grid to the desired nonuniform grid. Here we combine this approach with a new control system for constructing a grid density function φ(x). The local mesh width ∆x j+1/2 = x j+1 − x j with 0 = x 0 < x 1 < · · · < x N = 1 is computed as ∆x j+1/2 = ǫ N /ϕ j+1/2 , where {ϕ j+1/2 } N −1 0 is a discrete approximation to the continuous density function φ(x), representing mesh width variation. The parameter ǫ N = 1/N controls accuracy via the choice of N . For any given grid, a solver provides an error estimate. Taking this as its input, the feedback control law then adjusts the grid, and the interaction continues until the error has been equidistributed. Digital filters may be employed to process the error estimate as well as the density to ensure the regularity of the grid. Once φ(x) is determined, another control law determines N based on the prescribed tolerance tol. The paper focuses on the interaction between control system and solver, and the controller's ability to produce a nearoptimal grid in a stable manner as well as correctly predict how many grid points are needed. Numerical tests demonstrate the advantages of the new control system within the bvpsuite solver, ceteris paribus, for a selection of problems and over a wide range of tolerances. The control system is modular and can be adapted to other solvers and error criteria.