The so-called PWM or Witdh modulation is a technique often used to control a load, for example, is the control of DC motor speed PWM techniques are used frequently.
Usually to make a simple PWM (for practice or the introduction PWM) fans to use some of the facts of the op-amp circuit, which consists of Schmitt Trigger circuit, the integrator and comparator.
Schmitt Trigger function that produces a square wave will become the sawtooth wave or integrator is also called common rail and the ramp compared to a reference voltage that can change a lot of stress. So the result is a PWM output.
These two schemes are variations of different circuit PWM. The diagrams are for 12V operation and there are upper (ground) and low side (+12 V common) versions. The version of the lower circuit uses an N-channel FET, the high-side version of the circuit uses a P-channel FET. N channel devices tend to handle more current P-channel devices, which are also less expensive. The version of the high side of the circuit is useful when a portion of the load must be grounded.
This circuit can change a fairly high amount of current, a MOSFET IRFZ34N can handle over 35 Amps if connected to an adequate heat sink. Higher power FETs, such as IRF1010Z IRFZ48N or can be substituted if even larger currents are required. It is also possible to connect multiple FETs in parallel even more current capacity. Always use thermally conductive grease between the FET and the heat sink, and remember that the heatsink is under stress.
Inductive loads (motors) may require special care because it can generate large voltage spikes that can damage the MOSFET. Replacing a 1N4002 fast recovery diode can help absorb the recoil reverse voltage when driving an inductive load like a motor. If you use these circuits to experiment with electric vehicles, be sure to install a circuit breaker in series with the battery, the switch should be easy to reach by the driver. This is especially important given the fact that when non-MOSFETs, is often cut, leaving the engine running at full speed