A high temperature superconducting magnetic energy storage system (HT-SMES) is constructed using YBCO coated conductor and is integrated with a cryogenic system using sub-cooled LN2. A closed loop control algorithm, based on the digital signal processor (DSP) TMS320F2812, is proposed using the 2G HT-SMES to compensate dynamic voltage sag in power systems. A dynamic simulation experiment for compensation of instantaneous voltage sag is achieved. The experiment circuit is built using a signal conditioning circuit, a DSP controlling circuit, a power conversion circuit and a SMES unit. Analysis of the voltage waveforms before and after compensation validates that this SMES system is able to compensate instantaneous voltage sag.