element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
The World in Motion
  • Challenges & Projects
  • Project14
  • The World in Motion
  • More
  • Cancel
The World in Motion
Blog Pulse Width Modulation a Speed Equalizer(5): The plan didn't survive first contact.
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join The World in Motion to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: colporteur
  • Date Created: 31 Jul 2022 9:55 PM Date Created
  • Views 1987 views
  • Likes 6 likes
  • Comments 10 comments
  • motor projects
  • worldinmotionch
  • pwm
Related
Recommended

Pulse Width Modulation a Speed Equalizer(5): The plan didn't survive first contact.

colporteur
colporteur
31 Jul 2022

I did the first field tests with a HO scale locomotive today with limited success. The locomotive speed was controllable by using PWM but the whine from the motor is not acceptable for operational use.

In 1871 Prussian Field Marshal Helmuth von Moltke the Elder wrote an essay about military strategy. The following is an English translation, "No plan of operations extends with any certainty beyond the first encounter with the main enemy forces. Only the layman believes that in the course of a campaign he sees the consistent implementation of an original thought that has been considered in advance in every detail and retained to the end."

It appears I am the layman in Moltke's quote. The motor used for bench testing was not a locomotive motor but rather a 12VDC surplus motor. It did produce a whine during testing but only at a lower speed. I never gave it much thought. The locomotive motor when powered from PWM whines at all speeds. In addition, the maximum speed is slower with PWM than with the train power supply. Looking online, there are some examples of PWM producing a whine when used to power a motor. 

My first thought was the PWM frequency. Could a higher PWM frequency eliminate the whine?

The default PWM frequency for pin 3 ( pin used for PWM) is 490 Hz. Pin 4 has a default frequency of 980Hz. Using the PWM signal from pin 4 eliminated the whine with a loss of speed control. Using a speed code value of 127 the locomotive didn't move. At a value of 128, the locomotive moved at maximum speed. On the lower PWM frequency, (I can't recall the speed values) there was a greater range of control. I could get a slow speed as well as a top speed but with the whine.

This first contact's poor success has given me cause to make some changes. For any further bench testing, I will be using a locomotive motor and not my bench surplus motor. Initial google search suggests PWM frequency changes from defaults are possible but don't appear to support a frequency between 490Hz and 980Hz. I have yet to garner an understanding of why using the 980Hz frequency results in a loss of speed control.

I thought my plan was sound but it appears to need some tuning. Maybe a different motor driver module is required? Would a filter cap on the module output help? I'm not sure at the moment. I'm open to suggestions as I bandage my wounds and prepare for another attempt.

  • Sign in to reply

Top Comments

  • robogary
    robogary over 2 years ago +1
    Industrial AC & DC motor drives have a similar issue. I can also hear the whine of an electric vehicle H bridge. Those controls have features to change the switching frequency to adjust audible noise,…
  • colporteur
    colporteur over 2 years ago +1
    Error on my part. The website that reference pin 4 as 980Hz is wrong! Looking at the spec sheet pin 4 doesn't support PWM it is pin 5 that is PWM at 980Hz. Something I will need to investigate.
  • colporteur
    colporteur over 2 years ago

    Progress on the motor front!

    I tried about a dozen different motors from maybe eight manufacturers, They all suffered from whine. More so at slow speeds than at higher speeds. I then changed the PWM frequency from 490Hz to 980Hz with little result. The whine was at a different pitch.

    I then tried a version of Shabaz solution, that is to use the highest PWM frequency available by inserting the following in the void setup

    TCCR2B = TCCR2B & B11111000 | B00000001; // for PWM frequency of 31372.55 Hz

    No human discernable whine. I suspect dogs might be shaking their head wondering what the noise is. The code change resolves the whine for all the different motors I am using.

    Friday is scheduled for scale speed trials. The plan is to determine values to determine speeds that are appropriate for the scale. My plan is to capture some video to complete the submission requirements.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 2 years ago in reply to shabaz

    (can't edit)

    Just saw @robogary response, that's a great idea to use a transformer winding as a test, if you don't have an inductor handy.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 2 years ago

    Hi Sean,

    If the software allows it, you could push the frequency up to (say) 10 kHz, if the rest of the circuit allows it. Ideally higher than 20 kHz would be possible, it depends on the circuit (some might not be able to switch power at this rate) and what the software is capable of. 490 / 980 Hz is extremely low, I'm surprised the PWM library defaults to that. The PWM is audible for a couple of reasons but they are related. One is the frequency, but that alone isn't the cause, because it's to do with the PWM being used directly for the motor, with no smoothing. The easiest way will be to find an inductor (perhaps 10 mH) and put it in series with the motor, and place a capacitor across the motor (perhaps 1 uF). It will look like an LC filter, The values are just guesstimates, but an OK starting point. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • robogary
    robogary over 2 years ago in reply to colporteur

    I wonder if the track platform acts like a piano soundboard   :-)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • colporteur
    colporteur over 2 years ago in reply to robogary

    Way above my formal education! I thought maybe there was a rule of thumb. I did scope the PCM pins of the Nano and determine what frequency is used by default. That led me to knowledge that fills some gaps in servo motor operation. I can take that memory post-it note down, now that I have the answer.

    As I expected, a response from a model railroader confirms whine in motors occurs but it is usually with older motors. He referred to three pole motor verse four and five poles. The railroad has a collection of motors. I'm going to do some comparisons to see what I can discover.

    I will try the alternate PWM frequency tomorrow at the site on the motor that whines. I'm curious if the whine differs.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube