Virtual batteries play an important role in the development of batteries. In this paper, a hardware-in-the-loop simulation platform for virtual batteries is presented, which is composed of dSPACE, virtual battery, charge and discharge equipment, and data acquisition equipment. According to the actual usage scenarios of the virtual battery, the battery equivalent model is established and the battery model calculation process of series connection is matrixed. Finally, considering the variation of the battery in the module, the parameters of battery model are varied based on the normal distribution, and simulated using MATLAB. The results show that the proposed method can simulate the dynamic performance and the variation of the batteries in the module well.