You Are Here: Home » AVR ATmega Projects » PWM Projects » Introduction to AVR Microcontroller Pulse Width Modulation (PWM)

Introduction to AVR Microcontroller Pulse Width Modulation (PWM)




PWM is used in many industrial mostly for controlling the motor speed. The PWM is used because it’s the most efficient method comparing to the analog one. That’s why most of the modern microcontrollers today have this features build in. How does this PWM works will be described on the following circuits:Schematic Introduction to AVR Microcontroller Pulse Width Modulation (PWM)

On the figure 1A the motor is controlled by applying continues current through transistor base lead and this will cause the continues current flow through transistor’s collector lead by the factor of transistor’s gain (Ic = gain x Ib); the more current we put on the transistor’s base lead the more current Ic will flow through the transistor’s collector lead; this also mean the motor speed is depend on the current we put on transistor’s base lead. Using this kind of method, make the transistor always in the working stage and as a result the power dissipation (power lost as heat) on the transistor become very high.

On the other circuit figure 1B the motor is controlled by applying pulse current through the transistor’s base lead and this will cause the Ic pulse current flow through transistor’s collector lead. By varying the pulse width and using the right frequency, we could control the motor speed. Using the pulse current make the transistor on and off very quickly, this will reduce much of the power dissipation on the transistor. This kind of method is known as pulse width modulation or PWM for short.

The disadvantage of using the PWM method is the electronics circuit to produce this signal tend to be complex, but thanks to today’s technology; even the most cheapest and tiny microcontroller such as AVR Tiny13 (only have 8 pins) could produce this PWM easily. For the purpose of this tutorial I will use Atmel AVR Tiny2313 microcontroller for playing with the PWM, but you could apply the principal to almost all AVR microcontroller family.

The following is the list of hardware and software I use in this tutorial:

  1. AVRJazz Tiny2313 learning board from ermicro
  2. JazzMate AVR-ISP STK200/300 programmer board from ermicro
  3. WinAVR for the GNU’s C compiler
  4. Atmel AVR Studio 4 for the coding, compiling and debugging environment
  5. Kanda AVRISP STK200/300 for the programmer software; nicely plug in to the Atmel AVR Studio 4.14

Introduction to AVR Microcontroller Pulse Width Modulation (PWM)

The AVRJazz Tiny2313 has four LEDs attached to the PORT B0 through PORT B3 and we will use the LED on PORT B3 for outputting the PWM signal. Ok let’s start the coding now !

For more detail: Introduction to AVR Microcontroller Pulse Width Modulation (PWM)

Leave a Comment

You must be logged in to post a comment.

Read previous post:
Public Release of ESP32 SoC The Big Brother Of ESP8266
Public Release of ESP32 SoC The Big Brother Of ESP8266

It has been about one year since the announcement of ESP32 SoC and the beginning of its beta testing for...

Close
Scroll to top