Self regulating pwm

Hi,

I have a project that I want to control the voltage applyed to a motor via pwm, I understand the part of controling the pwm, but I didn't find a way to mesure the output voltage sent by the pwm. Can some bady help me with a code or circuit that can do that?

PS. I need to read the voltage of the pwm after the mosfet

Thaks in advance

I have to read between quite a few lines to give a rational answer to this.
But I am guessing you have a dc motor fed from a fixed voltage dc power source with a series MOSFET to control the voltage applied to the motor and the PWM controls the MOSFET. You will need an opto isolator between the PWM output and the MOSFET gate.
Normally the MOSFET is between the motor and ground so you need an isolator of some sort to connect across the motor terminals and to give an output proportional to motor terminal volts which can be connected to the Arduino ground and an Arduino analog input.
We had a discussion of this under the "voltage isolator" thread and a review of this might give you a few ideas.
I'm currently working on using an opto isolator in the active mode rather than digital as a voltage isolator. This may or may not work out and even if it does it will probably require some sort of software linearization.

Phoxx

You can't easily measure the voltage produced by PWM because it is either ON or OFF - have a look with an oscilloscope. It is the average that is seen by the motor.

If your Arduino is doing analogWrite(128) it is fair to assume that the motor is getting power for half of the time. I don't see that measuring is going to tell you different.

Of course you may want to measure the speed of the motor and use that in a feedback loop to adust the PWM so as to hold the speed constant when the load varies.

...R

Robin2

It's not quite that simple. Sure enough the PWM will generate pulses with the commanded on/off time ratio but the motor is also a generator and generates a voltage proportional to its speed and this voltage (counter emf or CEMF) will fill in the spaces in which the PWM is turned off. In addition to this, if the dc supply is rectified ac the CEMF will fill in the spaces where the applied voltage is below the CEMF. So it's not easy to infer the motor terminal volts from the PWM time ratio and then to use this as a proxy for the speed. Using speed feedback without a motor terminal voltage regulator is ok if you are don't ask too much of the speed regulator response. In other words it's ok if you can put up with slow response to a change in speed reference or to a change in load.

Phoxx

Unless you are using synchronous rectification mode, the effective voltage of a motor driver is not
a linear function of the duty cycle, due to current falling to zero at some point in the waveform
(learn about slow and fast decay modes if you want the gory details).

With synchronous rectification the motor terminals are driven all the time, so that the actual PWM
waveform is mirrored at the terminals of the motor - however you need a high enough freq. to avoid
large current excursions with this mode, and in general its less efficient.

So given you use synchronous rectification mode, then you can assume the effective voltage is given
by the duty cycle times the power supply voltage. Then you can compensate for variations in the
supply voltage by varying the duty cycle.

However if the ultimate aim is to run the motor at a constant speed its better to use a feedback
control loop derived from the measured speed - this will work for any mode as well, and compensate
for changes in mechanical load as well.

MarkT
Could you describe "synchronous rectification". It's a term I haven't met before. And are we talking ac or dc motors

Phoxx

phoxx:
It's not quite that simple.

I realize that. But without hearing from the OP I strongly suspect my answer is an appropriate response to the question.

...R

I wonder if there is a better phrase, but synchronous rectification means always having one
switch of a half-H-bridge closed - never floating. It comes from rectifier bridges where you
switch switching devices rather than use diodes to automatically switch (to reduce
losses in SMPS). Its basically class-D amplification.

The other H-bridge modes all expect one switch in the half-H-bridge to PWM and the other be open,
meaning the current then flows through one of the body diodes until the next cycle or until it
falls to zero. The current waveform is complex.

With synchronous mode both switches of the half-H-bridge are PWM'd in antiphase.

I've also seen this described as synchronous decay, but its not a decay, the current ramps
constantly till the next cycle, passing zero and reversing and increasing if necessary. The
current waveform is a sawtooth and current never flows through a body diode.

OK that's some help; I've done some chasing too--- The term was first used for mechanical rectifiers 100 years or so ago. In this scheme rectification was done by commutators and slip rings on a rotating shaft driven by a synchronous motor. I vaguely remember reading of it when I was a kid 70 years or so ago. The makers of rectifiers then hi-jacked the term for converters with fully controlled "diodes" in each leg. The big advantage of them is much reduced losses when MOSFETS, FETs or other low resistance rectifying devices are used; this is not trivial in a large converter where many kw of heat must be removed from the converter.
It would be interesting to see the strategy used when controlling the current in a large inductance. Once the current is flowing in an inductance if you try to stop it quickly it will develop any voltage necessary to keep flowing as it slowly dies down.
One advantage, I expect is the opportunity to improve the power factor by controlling the turn-off and turn on time of the rectifier.

Re the matter of CEMF, the type of rectifier used is irrelevant. It must develop a voltage greater than the CEMF to force current through the motor to develop torque. You can play around with the waveshape per cycle and probably (almost certainly) get some improvement in efficiency but the principle remains the same.

Interesting discussion.
Phoxx