Hello all! Sorry, my electronics skills are very limited so I need a help or directions to research.
I'm building a basic locomotive controller (for railway modelling) using an Arduino Uno card to control a L298N H bridge through PWM outputs. It works fine except for an annoying buzz sound on the dc motor due to the default Arduino's PWM frequency of 498Hz. So I changed the frequency to a value beyond the audible spectrum and set it to 20KHz. The annoying buzz sound was eliminated but the response of the dc motor is quite different. With the default frequency of 498Hz the locomotive starts to moving when I input a value of ~ 16, in a range of 0 to 255 to define the duty cycle variable. But at 20KHz, the locomotive only starts to moving with a value of ~ 128 and with 32KHz the value raises to ~200.
I would like to know if there is a way to have the same smooth response of the motor at those higher frequencies as when using 498Hz. Increasing frequencies, the controller range becomes narrower causing a more "nervous" reaction of the motor. Do I need another type of transistor that support high frequency switching? I am using a L298N H Bridge and have also used TIP120 with same results.
Thanks in advance for any direction.

The problem is that the motor has considerable inductance which means that as the PWM frequency increases so does the impedance and, therefore, current and power fall. I don't think it is possible to move the switching frequency out of the audible range and still drive the motor efficiently.

I'm not sure that the motor inductance can be ignored; one of the advantages of PWM motor speed control is that it makes it possible to maintain high torque at low speeds and for this to be the case the frequency must be low enough for peak current to be achieved, so, the requirement is rather different to that of a SMPS. All battery operated power tools I have ever owned or used have very audible PWM motor speed control and I assume for this reason.

I'm not sure that the motor inductance can be ignored; one of the advantages of PWM motor speed control is that it is possible to maintain high torque at low speeds and for this to be the case the frequency must be low enough for peak current to be achieved, so, the requirement is rather different to that of a SMPS. All battery operated power tools I have ever owned or used have very audible PWM motor speed control and I assume for this reason.

Click to expand...

Thanks blocco a spirale for your input!
I'm a hobbist only and, unfortunatelly , my electronic knowledge is very very basic so when terms like "inductance", "SMPS", ..., comes to the scene, I'm just a passenger watching for the best direction. What you said about high torque at low speeds I could see that it is true. With low frequencies on PWM, the locomotive can start moving with very low values for the duty cycle variable. We can hear the "hammer" beating sound of PWM acting to pull the locomotive. I could input so low values that pull the locomotive on an almost imperceptible movement such as moving across 8 milimeters in 30 seconds.
I don't know yet if it is on lower or higher band beyond of the audible spectrum, but I've heard of commercial decoders for locomotives (DCC system with PWM) with "silent driver" feature on its marketing. I'll try to get some info about them.

The problem at the higher frequencies may be due to the circuit delays of the L298. The TIP120 could experience similar delays, depending upon how you drive it.

Either go to a lower frequency or get a faster bridge circuit.
Lower the frequency to just above the point where it is audible.

Edit: The motor inductance should not be a factor since that just filters the ripple from the PWM waveform to give an average DC current through the motor.
It acts the same as the inductor in a SMPS.

Click to expand...

Thanks crutschow for your input!
Yes, I have tried a lower frequency. I've set a 20Hz for PWM frequency and the buzz sound is also inaudible, as in 20KHz. The motor response is efficient and smooth but the led lightnings of the loco becomes flickering at this very low frequencies. Currently, I'm using 40Hz for PWM. The leds has no flickering and the buzz sound is much more bearable than at the default 498Hz.
I have to go with your second advice and get a faster bridge circuit so that's I'm looking for.
If you have some info, it would be very appreciated ;-)

I would imagine that the "silent drive" controllers use a softer pulse shape which would reduce the more noticeable high frequency content of the sound and provide a smoother drive at the expense of increased dissipation in the output transistors.

Can you share your locomotive motor specs (voltage, amperage, wattage, etc.) and your wiring setup when using the TIP120?

I've been playing with PWM control of a solenoid lately with a TIP120 at 1000Hz with great results so far. Curious to see if the difference in our results is how we're driving the TIP120 or the differences between my solenoid and your motor, or both.

I'm still kind of a beginner with all this, so no promises on being able to help - I'm asking for the sake of my own learning just as much as anything.

It should be noted that most commercial PWM servo drives and VFD's run at or above 20kHz PWM frequency.
Picmicro recommend 4Khz minimum.
The current wave form is a mean level with slight sawtooth, very different from the voltage waveform.
Max.

Thank you very much for sharing this link. It's very useful for understanding the operation of a dc motor under dc regulated source and PWM source.
From what I could understand, the limiting factor is the time-constant, the time the voltage reaches its full value after crossing the circuits of the device and, in PWM, this is repeated on every pulse of PWM. So the kind of device and its particularities directly affects this time-constant and there is a limit frequency that if overpassed causes the loss of energy efficiency, therefore, the loss of linearity response, is it right? It seems there is no escape from this phenomenon so we have to give enough time for the loads reach their full value on each PWM pulse and beyond certain frequencies this is no possible.
About the "silent driver" decoder I mentioned on earlier reply, it is mounted inside every locomotive (DCC system) so I think the decoder supllies a 20Hz, or lower, PWM frequency for the motor and a higher frequency to feed the leds, so that the motor doesn't create a buzz hum sound and the leds doesn't flicker.
As I am currently playing on DC system (the voltage control is on the tracks), when using 20Hz (or lower) frequency the locomotive runs silently, but its leds become flickering, so this is why I was trying to drive the motor on the higher band beyond the audible spectrum (20KHz+).

Can you share your locomotive motor specs (voltage, amperage, wattage, etc.) and your wiring setup when using the TIP120?

I've been playing with PWM control of a solenoid lately with a TIP120 at 1000Hz with great results so far. Curious to see if the difference in our results is how we're driving the TIP120 or the differences between my solenoid and your motor, or both.

I'm still kind of a beginner with all this, so no promises on being able to help - I'm asking for the sake of my own learning just as much as anything.

I'd be curious to see if cutting that in half to increase the base current would make any difference, but it's mostly speculation and wishful thinking on my part. Can't find a whole lot of info on TIP120 switching speeds, but what little I found looked reasonable, and was based on Ic/Ib of 250. Hard to know without better motor specs, but I think you might be running higher than that now, which is what made me wonder.

That resistor is for an extra protection of Arduino from sparks coming from DC motor. The main protection is provide by diode.
I'll be researching now for a model of a mosfet and make just a experiment. If the results were somewhat significant, I'll post them here. Thank you!

That resistor is for an extra protection of Arduino from sparks coming from DC motor. The main protection is provide by diode.
I'll be researching now for a model of a mosfet and make just a experiment. If the results were somewhat significant, I'll post them here. Thank you!

Click to expand...

No, that resistor controls the current that runs from your Arduino out through the base and then the emitter of your transistor when the Arduino pin is high. There are limits to how much current each of these can handle, although in this case the Arduino would be the limiting factor (IIRC it's good for max of 30mA per pin.) You're limiting it at around 5mA right now, and could easily raise that to 10 safely (it might or might not help your high frequency performance - that's a different question entirely, but it wouldn't be a risk to any of your components!)