Abstract. The apparent mass of haptic device end-effector depends on its position inside the workspace. This paper presents a recursive algorithm to detect effective direction of gravity force, and to automatically estimate the apparent mass of the end-effector when placed at the vertices of a cubic grid contained into the device workspace. Then an on-line technique is proposed to actively compensate gravity, exploiting trilinear interpolation to compute an estimate of end-effector apparent mass in any position of the workspace. Experiments have been performed with three different haptic devices, and results shown that the apparent mass of the end-effector is compensated almost homogeneously with respect to its position in the workspace.