In: Electrical Engineering
How can we implement PWM with another processor such as the Intel i7.
what are some methods to achieve PWM with the Arduino?
How can we implement PWM with another processor such as the Intel
i7. what are some methods to achieve PWM with the Arduino?
Implementation of PWM in processor
The full form of PWM is Pulse-Width-Modulation. In this modulation
approach, voltages are generated using digital pulse. In any analog
circuitry, different voltages range can be possible to achieve,
whereas in digital voltages are in the range either 1 or 0. ‘1’
means any analog voltage range such as 5v, 3.3v etc.
Now, if you continuously on and off a particular switch, you will
be able to generate two static voltage either 5V or 0V (i.e.
digital 1 and 0) for the duration of the switch on and off
duration. If you need to ON a switch for a certain deration and OFF
for a certain duration, manually it is not possible, hence we need
to code for that particular switch. This operation is mainly known
as PWM operation of any microcontroller.
PWM has many requirements and specifications which are very
important to assure that the generated PWM signal will be received
by the other device. Hence, the receiver device needs to be
activated for certain duration in order to activate. The period of
PWM creates a frequency. During this period, the digital pulse is
producing ON and OFF consecutive bits. The frequency can be
calculated as the number of such period in 1 sec. Assuming the
length of period is 1ms. Then the frequency of operation of that
particular PWM channel is 1/1ms = 1kHz.
There are two types of PWM generation principles: PWM can be
generated at the middle or it can be generated at the end of the
period. Based on that information, the duty cycle of the specific
pulse has been achieved. The duty cycle can be defined as the
percentage of time duration of the period in which the pulse is in
ON state. Therefore, 10% duty cycle means 10% time of the period of
the pulse is ON and rest of the time that means 90% amount of time
it is in the OFF state.
In any kind of processor such as intel i7, such PWM signal are
mainly generated by the clock source and the build-in timer
mechanism. One can control the internal timer to count up and then
set back to 0 after a specific count, so that the timer will count
up and again back to 0 over and over again which creates the
period. While you are controlling the pulse, we can turn on the
switch for a specific count and again off it for a specific count
thus creating the PWM signal. In all of present scenarios, PWM
signal inside the processor is generated using the above
principle.
Methods to achieve PWM in Arduino
In Arduino, the ATmega 168 microcontroller chip has been employed.
There are several ways by which the PWM in Arduino can be
generated.
1. Simple PWM generation using analogWrite
function
In this mode, the user only needs to call the analogWrite function.
The pin no and duty cycle information’s are required to be passed.
Where, the pin no is basicaaly 3.5.9.10 or 11 and the duty cycle
defined the % of period of the ON time of the pulse.
2. Bit-banging PWM
In this mode, PWM can be generated manually by turning the pin on
and off for the desired amount of time. Here, the Arduino digital
pins can be utilized however the main drawback is that any
interrupts can affect the timing.
3. PWM generation by ATmega registers
The ATmega168 chip has 3 PWM timer pin which can control 6 PWM
outputs. While manipulating the chip timer value, the PWM signal
can be directly generated.
4. Fast PWM mode
In this mode, the timer counts 0 to 255. Output is turned on when
the counter counts 0. With increasing count the timer will on/off
the pulse based on the requirement. This mode is called as fast PWM
mode.