<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Pulse Width Modulation a Speed Equalizer(5): The plan didn&amp;#39;t survive first contact.</title><link>/challenges-projects/project14/theworldinmotion/b/blog/posts/pulse-width-modulation-a-speed-equalizer-5-will-the-plan-survive-first-contact</link><description>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 Moltk</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Pulse Width Modulation a Speed Equalizer(5): The plan didn&amp;#39;t survive first contact.</title><link>https://community.element14.com/challenges-projects/project14/theworldinmotion/b/blog/posts/pulse-width-modulation-a-speed-equalizer-5-will-the-plan-survive-first-contact</link><pubDate>Mon, 01 Aug 2022 22:26:06 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:18690101-5ade-443e-98f5-ba51dcb7a545</guid><dc:creator>colporteur</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Progress on the motor front!&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:ede0d0be-84f9-4095-be5e-2d2954fb022c:type=text&amp;text=TCCR2B%20%3D%20TCCR2B%20%26%20B11111000%20%7C%20B00000001%3B%20%2F%2F%20for%20PWM%20frequency%20of%2031372.55%20Hz]&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24093&amp;AppID=386&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Pulse Width Modulation a Speed Equalizer(5): The plan didn&amp;#39;t survive first contact.</title><link>https://community.element14.com/challenges-projects/project14/theworldinmotion/b/blog/posts/pulse-width-modulation-a-speed-equalizer-5-will-the-plan-survive-first-contact</link><pubDate>Mon, 01 Aug 2022 13:49:51 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:18690101-5ade-443e-98f5-ba51dcb7a545</guid><dc:creator>shabaz</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Hi Sean,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If the software allows it, you could&amp;nbsp;push the frequency up to (say) 10 kHz, if the rest of the circuit allows it.&amp;nbsp;Ideally&amp;nbsp;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.&amp;nbsp;490 / 980 Hz is&amp;nbsp;extremely low, I&amp;#39;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&amp;#39;t the cause, because it&amp;#39;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.&amp;nbsp;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24093&amp;AppID=386&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Pulse Width Modulation a Speed Equalizer(5): The plan didn&amp;#39;t survive first contact.</title><link>https://community.element14.com/challenges-projects/project14/theworldinmotion/b/blog/posts/pulse-width-modulation-a-speed-equalizer-5-will-the-plan-survive-first-contact</link><pubDate>Mon, 01 Aug 2022 00:49:53 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:18690101-5ade-443e-98f5-ba51dcb7a545</guid><dc:creator>colporteur</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Error on my part. The website that reference pin 4 as 980Hz is wrong! Looking at the spec sheet pin 4 doesn&amp;#39;t support PWM it is pin 5 that is PWM at 980Hz. Something I will need to investigate.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24093&amp;AppID=386&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Pulse Width Modulation a Speed Equalizer(5): The plan didn&amp;#39;t survive first contact.</title><link>https://community.element14.com/challenges-projects/project14/theworldinmotion/b/blog/posts/pulse-width-modulation-a-speed-equalizer-5-will-the-plan-survive-first-contact</link><pubDate>Sun, 31 Jul 2022 23:57:57 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:18690101-5ade-443e-98f5-ba51dcb7a545</guid><dc:creator>robogary</dc:creator><slash:comments>2</slash:comments><description>&lt;p&gt;Industrial AC &amp;amp; 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, and also putting a slight ramp on the H bridge switch when it fires to get rid of that nasty switch on step.AC output filters also help with that issue.There are also possibilities to hit some electrical resonance frequency of the switching and inductance/capacitance. A couple ideas:&amp;nbsp; &amp;nbsp;1) A Raspberry Pi Pico has more flexibility for setting PWM frequency, some projects are a good fit to leverage that flexibility.. 2) I will &amp;quot;cheat&amp;quot; sometimes by doing a digitalWrite = true or false with the timing of a duty cycle desired rather than implementing PWM. It does a good job of wasting compute power but it can be used to experiment and study behaviors..&amp;nbsp; 3) You could try adding a clamp on ferrite core to the H bridge + output lead&amp;nbsp;&lt;a href="https://en.wikipedia.org/wiki/Ferrite_core"&gt;https://en.wikipedia.org/wiki/Ferrite_core&lt;/a&gt;&amp;nbsp;and an RC filter on the output to smooth out the current zipping thru the motor. If you have a spare transformer laying around, run the DC output thru one of the low impedance windings in series just to see if adding inductance helps the problem.&amp;nbsp;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=24093&amp;AppID=386&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>