Alternators and generators are devices that convert mechanical energy into electrical energy. Alternators are used in vehicles and powered by the engine's crankshaft to charge the battery and power electrical systems. Generators function similarly but are usually larger stationary devices that produce power for buildings and the electric grid.