The main goal of this investigation is to improve the tracking accuracy of the stage of a linear motor. A DC brushless linear motor is used to actuate a gantry stage to perform printing. To compensate for the tracking error of the gantry stage that is associated with nonlinear friction, the dynamics of the nonlinear static friction are formulated using the Hsieh-Pan model. Particle swarm optimization (PSO), genetic algorithm, and real-coded genetic algorithm-based optimization problems are investigated to evaluate the parameters of the nonlinear friction model. The use of PSO-based optimization to tune the parameters of a disturbance-observer-based variable structure controller is also discussed to improve the tracking response. To check the consistency of the proposed controller, it is implemented in real time and an improved positional accuracy better than 0.1 μm is readily achieved.