This paper investigates the control algorithm of an exoskeleton for hand rehabilitation, which accomplishes both active and passive control mode. A double closed loop control structure is developed, which consists of position control loop and compensation control loop. The position controller is based on impedance control. The compensation controller is used for compensating the position error caused by deflection of the cable and sheath in the mechanical transmission. To realize the compensation, the spring model is used to represent the elasticity of the cable and sheath. With the proposed method,