What is a PWM signal?
The easiest way to control a brushed motor is feeding it with a variable voltage, in order to regulate the current. This kind of control needs an analog output going into the motor through an amplifier. The microcontrollers have no analog output, but they own some ports which can generate high frequency modulated logic signals (PWM): they consist of periodic signals depending on a percent value called duty cycle (DC). The signal is a logic 1 for that percent of the period, while it is 0 for the rest of the time: With this kind of signal, the power of the motor is regulated with the continuous opening and closing of the feeding circuit (the driver), with the same voltage. The higher the DC, the stronger is the current in the motor. The image below shows the behaviour of the current in the motor for some values of DC’s; negative values mean that the motor is feed in the reversed direction.