This work deals with the design of a emulator of power quality events complying the IEEE 1159 standard. A multilevel converter is simulated using a Matlab graphical user interface. Its allows the update of the rated operating parameters and the magnitude of the power quality event. A PSO (Particle Swarm Optimization) algorithm was used with the RMS voltage equations to generate the harmonic content as a function of the switching angles, which was determined by the convergence of the PSO algorithm. Finally, the algorithms and results of specific tests to generate the events were discuss.