You are on page 1of 2

We talked about how higher PWM frequencies eventually lead to switching losses and cross-conduction, so what is a good PWM

frequency to use? If you leave your Arduino alone and dont change anything, the PWM out uts will run at !k"# $ ins % and &' and %(("# $ ins !!, ), *, and !('+ ,his is considered a relatively low PWM frequency for -otor-controllers because at this frequency, there is an audible .whine/ that you can hear fro- the -otor coils being switched+ 0ecause -ost -otor-controllers can easily handle a !k"# PWM signal, you -ight want to leave the Arduino at its default values+ If however, you want your -otors to be silent during o eration, you -ust use a PWM frequency that is above the audible hu-an-hearing range, ty ically around 12,((("# $12k"#'+ A roble- arises because so-e -otor-controllers are not ca able of switching at such high frequency3switching losses increase as the PWM frequency increases+ 0ecause it is a difficult design task, -otor-controllers that can o erate at silent switching s eeds $12k"# or higher' are usually -ore e4 ensive and well built+ ,he frequency of each PWM out ut in on the Arduino is controlled by one of three syste- ti-ers that are built into the Arduino+ ,hink of each syste- ti-er in the Arduino as a digital -etrono-e, that deter-ines how -any beats will be in each second+ ,he value of each ti-er can be changed using one line of code and a s ecific setting selected fro- ,able )-!+ ,o change the frequency of a PWM in, select an available frequency fro- ,able )-! and re lace the 5setting6 in the following code with the a ro riate setting fro- the chart+ ,hen add the following line of code into the setu $' function of your sketch, de ending on the ti-er you want to change7

,889(0 : ,889(0 ; (b!!!!!((( < 5setting6= >>,i-er ( $PWM ins % ; &' ,889!0 : ,889!0 ; (b!!!!!((( < 5setting6= >>,i-er ! $PWM ins * ; !(' ,88910 : ,88910 ; (b!!!!!((( < 5setting6= >>,i-er 1 $PWM ins ) ; !!' ,able )-!+ Available PWM ?requency @ettings for Aach Arduino @yste- ,i-er Arduino ,i-er 5setting6 Bivisor ?requency $"ert#' ( $ ins % and &' (4(! ! &1%(( ( $ ins % and &' (4(1 C DC!1+% ( $ ins % and &' (4() &2 *D&+%& ( $ ins % and &' (4(2 1%& 122+!2 ( $ ins % and &' (4(% !(12 &!+(2 ! $ ins * and !(' (4(! ! )!1%( ! $ ins * and !(' (4(1 C )*(&+1% ! $ ins * and !(' (4() &2 2CC+1C ! $ ins * and !(' (4(2 1%& !11+(D

! $ ins * and !(' (4(% !(12 )(+%1 1 $ ins ) and !!' (4(! ! )!1%( 1 $ ins ) and !!' (4(1 C )*(&+1% 1 $ ins ) and !!' (4() )1 *D&+%& 1 $ ins ) and !!' (4(2 &2 2CC+1C 1 $ ins ) and !!' (4(% !1C 122+!2 1 $ ins ) and !!' (4(& 1%& !11+(D 1 $ ins ) and !!' (4(D !(12 )(+%1 ,his table,able )-! shows the available frequencies with their corres onding settings3 you -ight notice that so-e frequencies are available only on certain ti-ers, -aking each PWM in unique+ ?or e4a- le, to change the frequency on PWM ins * and !( fro- the default %(("# to an ultra-sonic

switching s eed of )1k"#, change the setting for syste- ti-er ! in the setu $' function, as shown in the following7 void setu $'E ,889!0 : ,889!0 ; (b!!!!!((( < (4(!= F 0y changing ti-er ! to a setting of .(4(!/, PWM ins * and !( will now o erate at )1k"# frequency anyti-e the analogWrite$' co--and is used on either in+ Alternatively, you can set these sa-e PWM ins to o erate at their lowest available frequency $)("#' by changing the 5setting6 to .(4(%/+ If you o erate the PWM out ut at a too low of a frequency $below !(("#', it will significantly decrease the resolution of the control3that is, a s-all change in the in ut will cause a drastic change in out ut and changes will a ear cho y and not s-ooth as they do at higher frequencies+ If in doubt, si- ly stay with the Arduino default PWM frequencies because they are sufficient for -ost robotics roGects, even if you can hear your -otors+ Hote 8hanging the Arduino syste- ti-er ( affects the out ut of certain Arduino ti-ing functions that rely on ti-er (, such as the delay$', -illis$', and -icros$' functions+ 0ack

You might also like