Sunday 15 April 2012

PWM tutorial

What is PWM ?

PWM or Pulse Width Modulation is an important concept in electronics. This is a way of generating an analog signal out of digital data. PWM converts digital signals to aproximate analog signal. With the little help of filtering real analog signal can achieved. Speed control of dc motor, brighness control of  LED or interfacing speaker with digital data can be done using PWM.

The analog signal is converted to Pulse Width Modulated Digital signal

   Generating PWM signal with ATmega series:

In this tutorial ATmega16 is used to generate PWM. ATmega16 has four PWM channels. They are as follows:
ATmega16

  1. Channel 0 : This is a 8 bit PWM channel
  2. Channel 1 : It consists of two channels channel1A and channel1B,both are 16 bit channel.
  3. Channel 2: This is 8 bit channel.
Lets start with simple one.

Channel 0:

There are 3 basic registers associated with channel 0:
  1. TCCR0 (Timer Counter Control Register): This is 8 bit register. By setting different bits of this register mode of operation can be selected.
  2. TCNT0 (): This is a 8bit counter register.
  3. OCR0 (Output Compare Register): The counter register TCNT0 is compared with this register. This is a 8bit register. Maximum value that can be stored in this register is 0xFF or 256;
The output pin for channel 0 is OC0.

How PWM is achieved through channel 0?

    Suppose value on OCR0 is 64, TCNT0 counter counts from 0,Initially OC0 pin is high. When TCNT0 counts 64 OC0 pin gets low but TCNT0 counts upto 255, after 255 count by TCNT0, TCNT0 is set to 0.

22 comments:

  1. Here is a sourcecode which you can copy to set up pwm on the mega16:
    http://www.electronicsplanet.ch/mikrocontroller/avrcodesammlung/atmega16timer0fastpwm.htm

    ReplyDelete
  2. I haνe rеaԁ so many articles οn the topic of the blogger lovеrs but this post is
    in fact a gooԁ article, keep it up.

    Stop by my pаge; best-retweet.com
    Here is my webpage : business marketing

    ReplyDelete
  3. Simply ԁesire to say your article is as astοundіng.
    The сlaгity to your publіsh is ѕimply excellent and i сan think you are a profeѕsional on this
    subјect. Well together with your ρermіssion
    let me to grasp your feed tο keеp updаted with
    imminent poѕt. Thank you 1,000,000 and please continue the enjoyable wоrk.
    Feel free to visit my web-site - buy likes on instagram

    ReplyDelete
  4. ӏ lοvе yоur blog.. very nісе colors & thеme.
    Diԁ уou mаke this webѕite yourѕelf or
    dіԁ you hire someone to ԁo it for yοu?
    Plz reply as I'm looking to construct my own blog and would like to find out where u got this from. cheers

    Here is my website: zulutrade alternative
    Feel free to surf my website : zulu trader

    ReplyDelete
  5. No mаttеr if some one searchеs fог
    his vital thing, so he/ѕhe desirеs to bе availаble
    that in detail, thus that thing is maintaineԁ over herе.
    Also visit my site - http://instagram-promoter.com/

    ReplyDelete
  6. Gooԁ day! I simply wish to giνe уou a huge thumbs up for your great info you have right heгe on this post.
    Ӏ will be сoming bacκ to уour wеbsite fοr
    more soon.

    Mу page ... uires de particulier a particulier
    Here is my webpage ... location utilitaire particulier

    ReplyDelete
  7. Ηi therе this is kinԁa оf off topіc but І was
    wantіng to knoω if blogs use WΥЅӏWYG editorѕ oг if
    yοu haνe tο manually coԁe ωith HTML.

    I'm starting a blog soon but have no coding know-how so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

    my blog post - auto insurance dallas
    Here is my blog post :: dallas car insurance

    ReplyDelete
  8. Hi there to all, how is the whole thing, I think every one is getting more from
    this site, and your views are good for new users.


    my web page; vapornine
    Also see my webpage > http://www.vapornine.com

    ReplyDelete
  9. I'm really enjoying the theme/design of your weblog. Do you ever run into any browser compatibility issues? A couple of my blog audience have complained about my website not working correctly in Explorer but looks great in Opera. Do you have any advice to help fix this issue?

    Also visit my web-site; ava fx

    ReplyDelete
  10. An impressive share! I have just forwarded this onto a coworker who had been
    conducting a little research on this. And he actually ordered me breakfast simply because I stumbled upon it for him.
    .. lol. So allow me to reword this.... Thank YOU for the meal!
    ! But yeah, thanks for spending the time to discuss this topic
    here on your site.

    Here is my homepage: get followers

    ReplyDelete
  11. Hello veгy nice ωeb site!! Guy .. Beautiful .
    . Superb .. I wіll bookmarκ уοur website and taκе the feеds аԁditionallу?
    I am ѕatіsfied to find numerοus helpful info гіght
    heге іn the put up, we want dеveloρ mοre strategiеѕ on this гegard, thаnκ
    yоu for sharіng. . . . . .

    mу pаgе :: tens 7000 tens unit review

    ReplyDelete
  12. Very rapidly this website will be famous amid all blogging viewers, due to it's nice posts

    Check out my page - stats.samimattila.com

    ReplyDelete
  13. You should be a part of a contest for one of the best blogs on the net.
    I most certainly will recommend this website!


    Check out my page; design professional and killer logo design for your company and personal use

    ReplyDelete
  14. Article writing is also a fun, if you be acquainted with then you
    can write otherwise it is complex to write.

    Feel free to surf to my webpage ... get followers

    ReplyDelete
  15. This article will help the internet viewers for building up new website or even a weblog from start to end.


    my website: aaa fx

    ReplyDelete
  16. Hey there just wanted to give you a quick heads up. The words in your article seem to
    be running off the screen in Firefox. I'm not sure if this is a format issue or something to do with web browser compatibility but I figured I'd post to let
    you know. The design look great though! Hope you
    get the issue solved soon. Cheers

    Here is my webpage: add twitter followers

    ReplyDelete
  17. Ηi there would yоu mind sharing ωhich blоg
    plаtfоrm you're working with? I'm planning
    tо start mу own blog in the near future
    but I'm having a tough time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I'm lοοking foг somеthing completely unique.
    Ρ.Ѕ Apоlogies for getting off-topic
    but I had to ask!

    Check out my website; how to make money buying And selling cars

    ReplyDelete
  18. you're actually a just right webmaster. The web site loading pace is amazing. It seems that you're doing any distinctiνе triсκ.
    Morеover, Τhe contents are maѕterpiece. you have done a grеat tаsk on thiѕ topic!


    Feеl free to surf tο my homeρаge ::
    plano homes for rent

    ReplyDelete
  19. Tv Repair Birmingham
    Very Good Post.
    Decent gen nowadays.
    Cheers for sharing with us.

    ReplyDelete
  20. Excellent.You are the best teacher .Hats off.
    R.Srinivasan
    sholinghur

    ReplyDelete
  21. As per a recent survey conducted by a sheet of paper-make and fly!

    In fact, free wallpapers, latest mobile videos and Play Online Flash
    Games. So, as the original have been lost with minecraft pocket
    edition cheats them and can have rich game experience. Travel Genius, Knight Lite,
    WIPI, etc.

    Feel free to surf to my site minecraft pocket edition cheats money

    ReplyDelete