Book Image

Arduino Development Cookbook

By : Cornel M Amariei
Book Image

Arduino Development Cookbook

By: Cornel M Amariei

Overview of this book

Table of Contents (16 chapters)
Arduino Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Faster PWM


This is an exotic procedure! The standard PWM frequency on the Arduino is around 490 Hz. While it can get most jobs done, it is not really that fast. However, we can change that.

Faster PWM is especially useful when controlling motors. At low PWM, the torque is greatly affected, and it can also create audible noise. The best way to test this is to implement the Controlling speed with PWM recipe from Chapter 5, Motor Control, and increase the PWM frequency.

Note

A note to remember: this might interfere with other functions, such as delay(). We have to be extra careful when this happens.

Getting ready

Following are the ingredients required to implement this recipe:

  • An Arduino board connected to a computer via USB

  • A DC motor

  • A resistor between 220 ohm and 4,700 ohm

  • A standard NPN transistor (BC547, 2N3904, N2222A, TIP120) or a logic level-compatible MOSFET (IRF510, IRF520)

  • A standard diode (1N4148, 1N4001, 1N4007)

How to do it…

After we implement the same circuit as in the Controlling speed...