With the rapid development of smart grid and green energy technologies, Bidirectional charger is paid more and more attention.This paper mainly studies the voltage stability of Bidirectional charger in the process of charging and the grid current waveform distortion rate of the discharge process. Put forward a control method based on RTW matlab/simulink. Build the simulink model and control model in the simulink environment.Then the code will be burned into the DSP processor complied from control model to the corresponding simulink model which achieved the desired effect.This method can guarantee the stability the current and voltage in the two pattern of the constant current source and the constant voltage source.In the process of discharge,the Grid-connected total harmonic current distortion rate less than 5%,the power factor is basic to 1.The simulation results and hardware platform experiment of DSP2812 all proved that this method is effective.