Design and control of a multilevel inverter for electric vehicles