Using RC filter with transistor

Hi! I have a project where i want to control the speed of a motor by controlling the input voltage. I have posted about this project before, but i think this is a seperate question so i'm creating a new post.

Since i need a low ripple variable supply voltage for the motor, i got the suggestion to use a RC filter to smooth out the PWM signal. I have searched for information on how to choose a suitable transistor and the right values for R1 and C1 but i'm a bit stuck.

I found this formula:
frequency cutoff = 1 / 2πRC.

But how do i know what cutoff frequency i want?
Also how do i chose a transistor where i get a linear relationship between my PWM signal and the supply voltage. In this case a PWM signal of 127 should be 6V and 255 should be 12V.

I think this is how the circuit should look?

Thanks in advance!

No, that's totally the wrong approach, you'll fry the transistor.

The PWM signal must not be low-pass filtered or will be in the analog
region where lots of power is dumped in the transistor. Besides that
circuit topology is controlling current, not voltage, so it couldn't work
anyway.

If you want linear response to a PWM signal you must use a half-H-bridge (aka
push-pull), not a single transistor.

With a half-H-bridge you clamp the motor voltage to 0V or 12V at all times, and
the average voltage depends purely on the duty-ratio of the PWM.

Its vital the half-H-bridge is driven all the time(*), not left to float (aka decay mode).

For instance an IRS2004 driving two n-channel MOSFETs would work, checkout the
datasheet: https://www.infineon.com/dgdl/Infineon-IRS2004-DataSheet-v01_00-EN.pdf?fileId=5546d462533600a401535675b86b2782
This chip has shoot-through prevention built-in which is useful, and requires a single PWM
signal.

(*) except for the required dead-time during transitions needed to prevent shoot-through
currents.

First and most importantly, you almost certainly don't want to filter the PWM signal for the reasons given by "MarkT" above.

In an application where one does want to filter a PWM signal to get a true analog output, the cutoff frequency of the filter should be "much lower" than the PWM frequency (which is typically 490 Hz or 980 Hz on 8-bit Arduino by default). The lower the cutoff frequency, the less residual ripple in the analog signal, but the less quickly it will respond to changes in set point.

For brushed DC motors, generally one just applies a PWM signal to the motor and the rotational inertia of the motor is effectively the low pass filter.

MarkT:
No, that's totally the wrong approach, you'll fry the transistor.

The PWM signal must not be low-pass filtered or will be in the analog
region where lots of power is dumped in the transistor. Besides that
circuit topology is controlling current, not voltage, so it couldn't work
anyway.

If you want linear response to a PWM signal you must use a half-H-bridge (aka
push-pull), not a single transistor.

With a half-H-bridge you clamp the motor voltage to 0V or 12V at all times, and
the average voltage depends purely on the duty-ratio of the PWM.

Its vital the half-H-bridge is driven all the time(*), not left to float (aka decay mode).

For instance an IRS2004 driving two n-channel MOSFETs would work, checkout the
datasheet: https://www.infineon.com/dgdl/Infineon-IRS2004-DataSheet-v01_00-EN.pdf?fileId=5546d462533600a401535675b86b2782
This chip has shoot-through prevention built-in which is useful, and requires a single PWM
signal.

(*) except for the required dead-time during transitions needed to prevent shoot-through
currents.

Oh, OK! I will need to read a bit more to make sure i understad fully. But i want to make sure: this method will give the motor a constant low ripple voltage?

MrMark:
First and most importantly, you almost certainly don't want to filter the PWM signal for the reasons given by "MarkT" above.

In an application where one does want to filter a PWM signal to get a true analog output, the cutoff frequency of the filter should be "much lower" than the PWM frequency (which is typically 490 Hz or 980 Hz on 8-bit Arduino by default). The lower the cutoff frequency, the less residual ripple in the analog signal, but the less quickly it will respond to changes in set point.

For brushed DC motors, generally one just applies a PWM signal to the motor and the rotational inertia of the motor is effectively the low pass filter.

I forgot to mention that the motor is a brushless DC motor and that is why i can't simply send the PWM signal to the gate of the transistor. Is there some other component i can use instead of a transistor? I simply want the arduino to act as a potentiometer. Is the answer the half-H-bridge mentioned above?

jremington:
How to Power and Control Brushless DC Motors | DigiKey

I can only find examples with three phase BLDC in that article?
I can manually control the speed by increasing/decreasing the voltage from my power supply. So i really only need a method to increase/decrease the voltage from an external 12V source with the arduino.

A 3-phase BLDC motor means you have an external BLDC motor controller. That motor controller may indeed be able to work with an analog control voltage, but many such controllers work perfectly well with a PWM input.

So for actually useful and informed answers: do disclose which exact motor controller you're using - and do post its datasheet here. Without that information any further discussion is a total waste of time.

wvmarle:
A 3-phase BLDC motor means you have an external BLDC motor controller. That motor controller may indeed be able to work with an analog control voltage, but many such controllers work perfectly well with a PWM input.

So for actually useful and informed answers: do disclose which exact motor controller you're using - and do post its datasheet here. Without that information any further discussion is a total waste of time.

I think you misunderstand. A motor controller is what i'm looking for. As i shown in the schematic it is a single phase motor. All i want to do is control its speed. Since a PWM on the supply voltage is not an option i am looking for another solution. Whatever it may be.

DrJanItor:
But i want to make sure: this method will give the motor a constant low ripple voltage?

Motors are a big hunk of rotating metal. Ripple is literally the last thing that worries them since their inertia acts as a mechanical low-pass filter, averaging out all the quick and tiny little fluctuations of the supply voltage. That is the entire reason why PWM works.

I forgot to mention that the motor is a brushless DC motor and that is why i can't simply send the PWM signal to the gate of the transistor.

Who has told you you can't PWM a brushless motor? Sure you can't do it "simply", but they are definitely controlled through PWM. Does the motor have an integrated controller? If so it should have it's own control input.

DrJanItor:
I think you misunderstand. A motor controller is what i'm looking for. As i shown in the schematic it is a single phase motor. All i want to do is control its speed. Since a PWM on the supply voltage is not an option i am looking for another solution. Whatever it may be.

If your motor is a BLDC and only has PWR and GND wires, it has a motor controller built into it. That is why people are asking for exactly what motor you are using. The details matter. Link to the product page.

Misunderstanding is mostly as you don't provide sufficient information. That this motor is not a generic brushed motor but a brushless one should have been mentioned in the first post of this thread.

Brushless motors that do not have a speed control function built in are very hard to speed control. Indeed they hate PWM, and will not behave well. A brushless motor may respond more or less to changes in supply voltage, the most efficient way of which would be by having some kind of buck or boost converter that in turn can be controlled through the Arduino. However I doubt this will give you particularly good results, for the simple reason that such motors are not meant to be speed controlled.

The buck and boost converters that I have encountered so far all have a fixed voltage output, which is great as that's what they're supposed to deliver: a stable voltage.

Typically speed control with brushless motors is done through an ESC, which controls the phases of the motor and takes a speed control signal. Such motors are designed to be speed controlled. In your case, those control electronics are built into the motor, and will just do their thing.

As i shown in the schematic it is a single phase motor.

Not if it is brushless.

Post a link to the data sheet.

Jiggy-Ninja:
Motors are a big hunk of rotating metal. Ripple is literally the last thing that worries them since their inertia acts as a mechanical low-pass filter, averaging out all the quick and tiny little fluctuations of the supply voltage. That is the entire reason why PWM works.Who has told you you can't PWM a brushless motor? Sure you can't do it "simply", but they are definitely controlled through PWM. Does the motor have an integrated controller? If so it should have it's own control input.If your motor is a BLDC and only has PWR and GND wires, it has a motor controller built into it. That is why people are asking for exactly what motor you are using. The details matter. Link to the product page.

Ok i think i framed the question the wrong way. I really just want a way to control voltage from an external power supply and get a stable output using an arduino, no matter what motor or device.

wvmarle:
Misunderstanding is mostly as you don't provide sufficient information. That this motor is not a generic brushed motor but a brushless one should have been mentioned in the first post of this thread.

Brushless motors that do not have a speed control function built in are very hard to speed control. Indeed they hate PWM, and will not behave well. A brushless motor may respond more or less to changes in supply voltage, the most efficient way of which would be by having some kind of buck or boost converter that in turn can be controlled through the Arduino. However I doubt this will give you particularly good results, for the simple reason that such motors are not meant to be speed controlled.

The buck and boost converters that I have encountered so far all have a fixed voltage output, which is great as that's what they're supposed to deliver: a stable voltage.

Typically speed control with brushless motors is done through an ESC, which controls the phases of the motor and takes a speed control signal. Such motors are designed to be speed controlled. In your case, those control electronics are built into the motor, and will just do their thing.

Ok, maybe what i want to do is just not possible.

jremington:
Not if it is brushless.

Post a link to the data sheet.

https://www.velleman.eu/products/view/?id=439200

That pump is specified to run on 5 to 12V, so it is definitely possible to control the speed. The manufacturer almost certainly expects that voltage to be provided by a well filtered power supply.

Whether the internal driver will tolerate PWM modulation is a completely different question, and since it is doubtful that the manufacturer would respond to inquiries, you would have to try the experiment.

To control the flow of a water pump to a given destination, most people run the pump at full speed and use an adjustable diversion or bypass valve on the output, which reduces the output pressure without stressing the pump motor.

The max current should be 0.35 A @ 12 V, less at lower voltage. Even transistor in linear mode should be able to handle this with some reasonable heat sink. It is difficult to get linear relationship PWM -> voltage this way. I would measure the voltage and adjust PWM to get the required voltage drop.

I can't read the number on that pump unfortunately. I have some identical looking ones here. They're cheap, a few USD each when bought from China, and work pretty well.

They will run slower - how much slower depends very much on the resistance offered by the water, and how high it has to be pumped. As I normally need height rather than volume I never really tried to lower the voltage, a lower voltage will result in a much lower head.

The additional complication for the OP is of course that the pump runs at 5-12V, and filtered unadulterated PWM gives 0-5V which is useless in itself, as only the high end would get the pump to even move.

Now, almost a page in, the OP finally revealed at least part of what they're actually trying to do, and maybe we can come up with a more useful solution, even without knowing WHY they'd want to change the speed of the pump (or the water flow). An electronic valve throttling the output comes in mind. Then at least you can still get the full head.

jremington:
Whether the internal driver will tolerate PWM modulation is a completely different question...

2-pin or 3-pin brushless computer fans and pumps for watercooling are AFAIK PWM-ed with a low frequency.
Something like 30Hz, to minimize that problem.
Leo..

You are not understanding that if you use a transistor to reduce motor voltage, the transistor will have to absorb the power that you relieved the motor of. If the motor draws 2 amps at 12V (24 Watts) and the transistor drops it to 6V, current would fall to about 1 amp, 1 * 6V = 6W, the transistor now has to drop 6V @ 1 Amp = 6 Watts. A huge heat sink would be needed and 6 Watts wasted as heat.
I believe you were advised in an earlier post to investigate a variable buck converter.
BTW: Did you ever say the motor current? OOPS! Found it. :-[

max. load current: 0.35 A at 12 VDC

One way to find out :slight_smile: I got one of my cheap BLDC pumps and set up a simple "blink" sketch. Value for cycle chose to give a 30 Hz PWM. Pump is marked NC35-1230, 12V, 4.2W. I used a Nano with retrofitted ATmega328PB on a screw shield to run this thing. The MOSFET all soldered up the regular way for controlling a motor (10k between gate and source; 120Ω between pin and gate - a bit low of a value but it's what I happened to have on my desk and is good enough).

#define LED A3

void setup() {
  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
}

uint32_t onTime = 15000;
uint32_t cycle = 33000;

void loop() {
  digitalWrite(LED, HIGH);
  delayMicroseconds(onTime);
  digitalWrite(LED, LOW);
  delayMicroseconds(cycle - onTime);
}

12V pump switched using a IRLB8721 MOSFET. No flow meter attached; I just looked at the flow coming out of the hose that I attached to it, so it's not particularly scientific.

onTime values & results:
2,000: not running.
5,000: running gently with good pressure when you get it started, won't start by itself.
7,000: does start by itself. Similar flow as 5,000.
10,000: running well, much faster flow.
12,500: faster again.
15,000: roughly full speed now (45% duty cycle!)
17,500: not running at all.
20,000: not running at all.
22,500: running about as slow as at 5,000, but does start by itself.
25,000: running a bit faster than at 22,500.
27,500: running a bit faster than at 25,000. Estimate: about half of full speed.
30,000: running at pretty much full speed.
32,500: pretty much full speed.

So, well... doesn't sound like a very good result to me. I'm not too surprised with the pump reaching full speed at low duty cycle (it probably has some good capacitance built in), but I am surprised by it basically switching off again at about 50%, before starting all over again with its speed.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.