A generalized approach to the analysis and control of modular multilevel converters