Video: PWM On The ATmega328p

This week we continue on with another video in our series about how to program for the ATmega328p processor using C. The ATmega328p is at the heart of many Arduino boards. If you have been using them but want to add some more horsepower to your projects, this series of videos is for you. In this video, [Jack] talks about various types of pulse width modulation (PWM). You can use PWM to control the speed of a motor, the brightness of a LED, or to generate analog waveforms. [Jack] shows how to set up the processor to do locked anti-phase PWM to drive the wheels of the 3pi robot and then demos a short program that shows the code in action.

If you missed the previous posts in this series and would like to check them out…
Intro and how to set up the development environment : Click Here
Working with I/O pins: Click Here

Video is after the break…

5 thoughts on “Video: PWM On The ATmega328p

  1. I would use graph paper next time, so that you can show how the pulse width/frequency compares with respect to time, easier.

    Also, I have to disagree when you say that pre-calculating the values of registers (i.e REG = 92) is ‘just as good’ as OR’ing each bit together. OR’ing each bit, as you do in the tutorial should be recommended for all developers, as it is _much_ more descriptive, easier to understand and much easier to modify at a later date, if necessary. It is just good practise.

    Also, that high pitched whining is god-awful annoying but you don’t mention if it is actually bad for the motors or any of the components driving the motors? Are there any repurcussions to doing it this way? Will it burn out motors if you run it for long periods at 128/128?

    Thanks for the tutorial, it’s fun to see how fast that thing can zip around!

Leave a Reply to KirillCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.