# Voltage v. PWM values nonlinear, why?

We're driving a small 12v pump with a MOSFET circuit driven by an Arduino pwm output.

Here you see the pwm values up to 255 (flow doesn't start until around 80 or 90), and voltage read from a VOM across the output.

The flow from the pump also shows a very similar curve (pump output v. voltage is quite linear).

It seems to me that voltage out versus pwm values should be quite linear, but it's not. Why?

thanks!

Sorry, better image here.

Here you see the pwm values up to 255 (flow doesn't start until around 80 or 90), and voltage read from a VOM across the output.

There will always be a minimum voltage required before the motor can operate to overcome friction and load. This will be dependent on the specific motor.

The flow from the pump also shows a very similar curve (pump output v. voltage is quite linear).

I suspect this is mostly a shortcoming of the meter being used to make the measurement. Unless it is capable of and includes circuitry/firmware to perform 'True RMS' measurement I wouldn'd put too much faith in the accuracy of your data points. A basic DVM is designed to read pure DC which a PWM signal is not. See if you can borrow someones DVM with true rms capablity and see what the data points look like with it.

It seems to me that voltage out versus pwm values should be quite linear, but it's not. Why?

Lefty

Retrolefty, I always appreciate your comments, thanks.

First, the DVM is a good one, with RMS.

Second, as I mentioned, the actual flow (we measure in ml/s) from the pump follows the curve very much the same, so it's a real distortion -- I'm pretty sure that pwm v voltage really is non linear.

And if this helps, the pumps running quite well way before flow starts, we have about three feet of vertical lift between pump and the outlet, so it has to overcome that before flow starts, and you can see water level slowly climb up the clear pipe as pwm/voltage increase.

Second, as I mentioned, the actual flow (we measure in ml/s) from the pump follows the curve very much the same, so it's a real distortion -- I'm pretty sure that pwm v voltage really is non linear.

Or could the pump performance curve account for what you are seeing? At the refinery I worked at before I retired there were machinery experts that spent a lot of time looking at 'pump curves' datasheets when sizing pumps for applications.

Lefty

Indeed pumping is hideously complicated, but in this case I am sure that the voltage v. pump output curve is very close to linear; we have done much work on that aspect. In this case we have a very simple, low pressure system that has a pretty flat response (in your refinery the pumps were operating under much higher/varied pressure probably and that creates more complexity and non-linearity.)

Part of why I ask is that we're developing a digital flowmeter, and having to use complex (sometimes third order poly) equations to describe curves in software is a real pain. Linear much easier, especially when you throw in real-time feedback and calibration, which we are.

I will scope the pwm tomorrow, I suspect the square wave is changing shape as pwm values go up or that the MOSFET response is somehow changing with increase in pwm (and those things are beyond my understanding

Have a diode across a motor? I'd expect that current via flyback diode , probably, would create non-linearity.

Yep Magician; it's a first class circuit designed by a pro (not me :-); we'll check that out, thanks.

What sort of mosfet is it, and how are you driving it? Please provide a schematic, with part numbers for the mosfet and diode, and any other active components.

I'll get that schematic soon; here's the scope trace in meantime; pretty much what I expected, and keeps this shape through all duty cycles.

I find that negative-going spike rather disturbing, and the high level of noise during 50% of the cycle is odd.

I'll get that schematic soon;

You need to that trace is not at all correct.

dc42:
I find that negative-going spike rather disturbing, and the high level of noise during 50% of the cycle is odd.

The negative going spike looks like what I would expect to see with an inductive load without a reversed biased diode across the winding. Do you have such a diode in place?

Lefty

Grumpy Mike has warned me the scope lies about things like this. This trace looks very much like others I've seen on this scope of similar circuits. The only perfect square waves I've seen come from Critical Velocity PWM controllers.

Here's the circuit. MPWM_D3 is pin 3 on the Arduino.

I think that MOSFET has its own flyback diode, but I don't see that on the datasheet, and there isn't one in the circuit; the MSENSE conection is unused.

Thanks!

I can see two things wrong with that circuit:

1. No flyback diode across the motor. The mosfet will be avalanching to absorb the energy stored in the motor when the mosfet turns off. Although that mosfet is avalanche rated, you are probably exceeding its repetitive avalanche rating, and this is likely to lead cause the mosfet to fail after a while. The diode in the mosfet does not help in this instance. The lack of a flyback diode probably explains some of the non-linearity, because the stored energy in the motor induictance is being wasted, except when the PWM is 100%.

2. The mosfet isn't a logic-level one, so unless the current taken by the pump is small (less than about 1A), the mosfet won't be turning fully on. You can get a logic level mosfet such as the STP40NF10L (and several others) that is pin-compatible with the IRF540.

I strongly recommend you correct both of these. I also recommend connecting a large capacitor (say 1000uF) between the line marked +12v where it feeds the motor and the ground connection at the bottom of R4. I would reduce R1 to 150 ohms to help the mosfet switch quickly.

It would be a little easier to understand the trace if you used the scope to show the voltage from the mosfet drain to ground, rather than the voltage across the motor, which is what I think you did.

Grumpy Mike has warned me the scope lies about things like this

Not sure I recall that but I do think in this case it is telling you the truth because of you lack of flyback diode.
I am not sure I would go as high as 1000uF bulk decoupling I am sure 470uF would be good enough. I would also put a 0.1uF ceramic across it as well to get rid of the high frequency stuff.
dc42 is right you need to look at the trace with the scope ground connected to the system ground. Some scopes have the scope ground connected to the earth pin and you can get shorts measuring across components. An old trick to get round this was to disconnect the earth lead from the scope and have it poking out of the mains socket to remind you, but in these days of sealed plugs and ground political correctness it is frowned upon.

Looking at your graph again, I think you're losing nearly 10% 5% of the maximum pump power as avalanche energy in the mosfet, except when you are at 100% PWM and the mosfet is always on. I expect the mosfet is getting warm if not hot. You haven't said what the current rating of the pump is, although I see you're using a 4A fuse.

[EDIT: I now think you are likely to be within the repetitive avalanche energy of the mosfet, although adding a flyback diode is kinder to the mosfet and the motor, and should remove the kink in the graph.]

Grumpy_Mike:
I am not sure I would go as high as 1000uF bulk decoupling I am sure 470uF would be good enough.

Very likely true, however the ripple current rating should be considered too. It would be interesting to see a scope trace of the signal across R4 so that we can tell what the current is doing.

Grumpy_Mike:
An old trick to get round this was to disconnect the earth lead from the scope and have it poking out of the mains socket to remind you, but in these days of sealed plugs and ground political correctness it is frowned upon.

A modern alternative to this trick is to use one of the USB-powered digital storage scopes that uses a PC as a display (e.g. PicoScope for around GBP300 for a good one, or a similar spec one from Hong Kong for around GBP100), and use it with a laptop running on battery power.

Many thanks everybody, will look into all this and let you know what we do.

One thing I should mention is that the small centrifugal pump is drawing 1.6A at most, and of course it's very highly damped by water on the impeller.

Well, you guys did it again, the pro who designed the circuit says "I'm eating crow...." He thought the MOSFET had built-in flyback diode and it does not. Fortunately we can easily add that, we did, and here' s the new trace.

Thanks very much!

I'm glad you got it sorted. Power mosfets do have built-in diodes, and when you connect 2 mosfets in a half-bridge configuration, or 4 mosfets in a full-bridge configuration, those diodes act as flyback diodes. However, a single mosfet driving a highly inductive load needs an external flyback diode.