This project discusses a comprehensive control of a wind turbine system linked to a pid-enabled industrial plant; an algorithm was developed to enable a control structure that employs a four-leg inverter linked to the grid side; this inverter injects the available energy and acts as an active power filter; this reduces load current disturbances and improves power quality. Nonlinear and linear loads in three-phase and single-phase configurations are addressed in a four-wire system. During the connection of the wind turbine, the utility side controller is designed to adjust the disturbances created in presence of reactive, non-linear and/or unbalanced single- and intra-phase loads, in addition to supplying active and reactive power as required. The controller's DC-link capacitor and grid-connected power converter are designed to enhance power quality when wind power is unavailable. The key difference of the suggested methodology with respect to others in the literature is that the proposed control structure is based on the Conservative Power Theory decompositions. This option gives power and current references for the inverter control that are decoupled, allowing for a wide range of customization, granular control, and robust performance. Software benchmarking in real time has been used to assess how well the suggested control algorithm would do in a production setting. The control strategy is developed in Opal-RT and proven in hardware-in-the-loop (HIL) using a TI DSP. MATLAB/SIMULINK is used to realize the control strategy and verify its accuracy. The findings validated our power quality enhancement control and enabled us to forego the use of passive filters, paving the way for a smaller, more versatile, and more reliable electronic implementation of a control system that is based on a smart grid.