As shown in the circuit, the 230V, 50Hz AC mains is stepped down by transformer X1 to deliver a secondary output of 12V, 1A. The transformer output is rectified by bridge rectifier BR1, filtered by capacitor C1 and regulated by IC 78S08 (IC1). Capacitor C2 bypasses the ripples present in the regulated supply. When mains is available, the battery charges through resistor R1. It provides power to the circuit when mains fails.
PWM is done using timer 555, whose pin 7 is used as the output and connected to the gate of MOSFET T1. Potentiometer VR1 controls the charge and discharging time of capacitor C3 and thus decides the duty cycle of PWM. In other words, using VR1 you can control the speed of the DC motor. The DC motor is connected between the positive and drain terminals of MOSFET T1.
Working of the circuit is simple. Connect the DC motor as shown in the circuit. Now vary potmeter VR1 slowly. The speed of the motor will vary accordingly, provided mains or the battery is providing power to the circuit.
Assemble the complete circuit on a general-purpose PCB and house in a small cabinet. Fix switch S1 on the front panel of the cabinet. Fix a two-pin connector at the rear side of the panel for connecting the motor to be controlled and also connect the mains power cord for input mains supply.