Author Topic: Tuning BEMF by changing PWM freq?  (Read 442 times)

0 Members and 1 Guest are viewing this topic.

sizemore

  • The Pitt
  • Crew
  • *
  • Posts: 2778
  • Respect: +143
Tuning BEMF by changing PWM freq?
« on: January 08, 2026, 11:02:48 PM »
0
Installed a modern high-quality decoder in a good locomotive (released in 2006). It has a 3-pole can motor. I spent hours (and hours) trying to tune BEMF, and could not get it to run well. Tweaks for low speed steps affected the tweaks for the high steps, vice versa. In a last ditch effort I decided to change PWM dropping the frequency in half, almost day and night difference in performance through the full range. Decided to take the “W” and save the fine-tune for tomorrow, but wonder “why” it made such a difference? Would lowering the sampling rates for BEMF have the same effect?

The S.

Thompson Sub: Instagram | Youtube | Website

mmagliaro

  • Crew
  • *
  • Posts: 6487
  • Gender: Male
  • Respect: +2011
    • Maxcow Online
Re: Tuning BEMF by changing PWM freq?
« Reply #1 on: January 17, 2026, 02:49:24 PM »
+3
Well, I'll take a whack at this.
When you drive a motor with PWM, the motor is acting like a filter.  Think about how a low-pass filter works with a resistor and  inductor.  As each pulse turns on, the inductor "resists" the flow of current temporarily, and the current ramps up, and then shuts off rapidly, wherein the field collapses when the pulse ends. 

This creates an overall averaging effect on the current flow, and the motor turns at a speed proportional to this average current as long as the pulses come along quickly enough to turn the motor back on before it completely collapses, and not so quickly that the current is constantly ramping up and down before it has a chance to reach the point where the motor can actually move.   How long it takes for the current flow to ramp up on each pulse depends on the motor's time constant
- If the frequency is too high, the current through the motor may change too fast for that "inductor" to ever stablize at a current high enough to turn the motor. 
- At lower speeds, the PWM duty cycle is so short, that this only exacerbates the problem. 
- High frequency = lots of pulses in a period of time, and low duty cycle = each pulse is on for a very short time.   

We seem to have settled on frequencies anywhere from 12kHz to 20 kHz, from what I've seen, in PWM controllers for model train motors.  But that might be too high for this motor.

So by reducing the frequency, you have gotten the current into a good zone, especially at lower speeds, where that 3-pole motor can start moving.  At higher speeds, the PWM duty cycle more and more approximates DC and it probably doesn't even matter what the frequency is, so you are getting good overall running.

Here's a great discussion of this, including graphs:
https://cdn-learn.adafruit.com/downloads/pdf/improve-brushed-dc-motor-performance.pdf
Particularly note the part on page 14 titled "PWM Frequency" for a discussion of what happens at low speeds if the frequency is too high.
------

sizemore

  • The Pitt
  • Crew
  • *
  • Posts: 2778
  • Respect: +143
Re: Tuning BEMF by changing PWM freq?
« Reply #2 on: January 20, 2026, 03:50:42 PM »
0
Thanks Max. The frequency was set OOTB to 40Khz which works fine on Kato, Atlas and Wally-World (LL/Walthers) 5-pole/coreless motors. What I was trying to determine, if I left PWM unchanged, and instead changed the BEMF sampling rate would have the same effect. Based on your response and shared documentation I don't think changing sampling rate would have the same effect, since the "sweet spot" would still be to high.

Thanks!
The S.

Thompson Sub: Instagram | Youtube | Website

peteski

  • Crew
  • *
  • Posts: 35201
  • Gender: Male
  • Honorary Resident Curmudgeon
  • Respect: +6606
    • Coming (not so) soon...
Re: Tuning BEMF by changing PWM freq?
« Reply #3 on: January 21, 2026, 01:17:03 AM »
0
Thanks Max. The frequency was set OOTB to 40Khz which works fine on Kato, Atlas and Wally-World (LL/Walthers) 5-pole/coreless motors. What I was trying to determine, if I left PWM unchanged, and instead changed the BEMF sampling rate would have the same effect. Based on your response and shared documentation I don't think changing sampling rate would have the same effect, since the "sweet spot" would still be to high.

Thanks!
The S.

Sampling rate and the PMW frequency are not really related.  There is nifty drawing in the ESU decoder manual (in section 11.1.3 EMF measurement principle) which shows you the PWM pulses supplying power to the motor are briefly turned off to measure the (B)EMF voltage from the motor's spinning armature).  The PMW pulses are much higher frequency than the (B)EMF sampling frequency.
. . . 42 . . .

Maletrain

  • Crew
  • *
  • Posts: 4192
  • Respect: +873
Re: Tuning BEMF by changing PWM freq?
« Reply #4 on: January 21, 2026, 09:29:27 AM »
0
Sampling rate and the PMW frequency are not really related.  There is nifty drawing in the ESU decoder manual (in section 11.1.3 EMF measurement principle) which shows you the PWM pulses supplying power to the motor are briefly turned off to measure the (B)EMF voltage from the motor's spinning armature).  The PMW pulses are much higher frequency than the (B)EMF sampling frequency.

It seems that both parameters could be optimized to achieve the best possible low-speed crawl.  Although the parameters are independently changeable, it is not clear to me that the effects on minimum crawl speed are independent.  So, I would be interested in seeing the results of optimizing one, then the other, then redoing the first to see if the changes in the second affected the optimum value of the first.

That said, I am amazed at the crawl performance of an old Bachmann GP7 that I just acquired.  The decoder is extremely basic, with CV2, but no CV5 or 6 and no speed table.  Yet, it crawls extremely well - with an odd speed curve that is very low for the first half, then goes up more rapidly and tops out near 95 smph (on a 13.8 volt DCC system).

So, I am guessing that manufacturers could do the tuning of BEMF and PWM for their specific combinations of motors and drive mechanisms, if they wanted to do that.  For after-market installs, I know some decoders now have an "autotune" feature, but what I hear about that is that it is not overwhelmingly successful.

peteski

  • Crew
  • *
  • Posts: 35201
  • Gender: Male
  • Honorary Resident Curmudgeon
  • Respect: +6606
    • Coming (not so) soon...
Re: Tuning BEMF by changing PWM freq?
« Reply #5 on: January 21, 2026, 11:23:44 AM »
0
You say "old Bachmann".  If has factory installed DCC then it is not old (at least to me). Is it their standard bare-bones decode.  Those are not known for best performance or features.  I don't believe it even uses BEMF  to control motor speed. I can also pretty much guarantee that it is not specifically tuned to the motor used in that model. You are giving manufacturers too much credit.  :D

It probably uses a very low frequency PWM which ends up acting like the old DC "pulse power" which shakes the motor armature overcoming any mechanical binding allowing it to rotate at very low rpms.  If the mechanism does not have a lot of friction that results in smooth low speeds.
. . . 42 . . .

Maletrain

  • Crew
  • *
  • Posts: 4192
  • Respect: +873
Re: Tuning BEMF by changing PWM freq?
« Reply #6 on: January 22, 2026, 09:02:08 AM »
0
I was not suggesting that the "old Bachmann" loco had all of the tunable features of modern decoders.  But, it does seem to run much more smoothly than most Bachmann locos of similar vintage.  And has much lower top speed.  So, it does seem to me that Bachmann made some sort of effort on this model to produce those effects.  See Spookshow review here  https://www.spookshow.net/loco/bachgp7.html