A constant power supply is a basic need for each consumer due to the increase in sensitive equipment day by day. As per IEEE standards, a 10% reduction in voltage from the supply voltage is not acceptable and may cause the failure of equipment. Previously, different techniques have been used to alleviate the voltage sag, such as STATCOM, DSTATCOM, SVC, and shunt capacitors, but these devices are connected in parallel, which compensates for the low value of voltage sag, and they have high maintenance costs involved. Compensation for the low and high values of voltage sag is possible through a series-connected device such as a dynamic voltage restorer. In this paper, a matrix converter is presented for DVR to convert AC to AC voltage directly and free from batteries, capacitors, and multiple conversions as needed in a voltage source inverter, resulting in a reduced cost of DVR topology. The DVR is meaningless in the absence of a controller, so it is necessary to select a suitable controller for the satisfactory operation of the DVR under a variation of system parameters. In this paper, the performance of a linear PID controller is analyzed and compared with a nonlinear controller, such as a sliding-mode controller, under variation of power system parameters inorder to select a robust controller that performs satisfactorily for DVR. Earlier trial-and-error methods were used to obtain the parameters of PID gains, but they require a large time to obtain the parameters of the PID gains and there is a chance of inaccuracy. A genetic algorithm was used to obtain the gain parameters, but it has more convergence time and the particle swarm optimization technique has involves less reliability. In this research paper, the sliding surface coefficient parameters such as and Ki for the PI sliding surface of SMC and PID gains are taken through an ant colony algorithm to obtain the robustness of the controllers. The purpose of this paper is to introduce the best DVR topology with reduced cost. MATLAB simulation software was utilized to analyze the performance of the DVR with PID and SMC controllers under different fault conditions and also the THD% of proposed controllers was analyzed through FFT.