I have a 16F877 (20 MHz) that I want to control the speed of a
2-3amp DC motor using a MOSFET and PWM. I am using PIC Basic Pro. I
can control the speed of the motor by HPWM 0,16383,15000. I can change
the speed of the motor by changing the 15000 up or down. The problem is
that the motor has no torque. I can use a 555 PWM circuit and my
motor/mosfet works fine. It seems the 16F877 produces to high of a
frequency. Any suggestions? Thanks....imma roadrunner
You aren't giving it what it wants. You either control the voltage and allow
it to take all the current it wants, or, you get some feedback so you can
turn the power on when it isn't going fast enough for you.
Robin G Hewitt
So far as the motor is concerned, if it behaves differently in each of
the two scenarios you describe, then there are only a few possible
(I am assuming that a) the power source is the same in each case, b)
the switching waveform is the same shape, ie square)
1) The frequency is different in each case or
2) The switching waveform isnt as expected, ie a variable width square
The best way forward here is to put a scope across the motor leads in
each scenario and see how they differ. (Dont expect a "perfect" sqaure
wave across the motor terminals, it's inductance will effect the shape
of what you see).
I have seen what looks like solid firmware on paper, behave
unexpectedly at runtime (ie the code was buggy, this was out of a ref
How do you "know" that the MCU system and code you have, is producing
a true, simple PWM waveform? if you havent measured it with a scope,
then it is really an assumption.
If you replace the motor with a pure resistor (of a suitable value and
power rating) then you should see a perfect square wave on a scope,
this is a good way of testing the firmware.
The frequency of the square wave is of some importance. The motor has
its own inductance, and an inductor "opposes" a rapidly changing
current (by generating a "back EMF").
I imagine that if the square wave is of a very high frequency, then
the "on" pulses are very short (even at 99% max duty cycle) and the
current in the motor is never reaching a significant value, even by
the time the pulse ends.
I dont know what the optimal frequency is, but try for around a 100Hz,
I guess that will be low enough for a DC perm-mag motor's inductance
to be of negligible impact.
If you drive a DC motor by PWM on to a MOSFET with no feedback surely you
achieve a constant torque and it won't hold it's speed when you apply a
load. Which is what I read for "no torque"
I don't see what frequency has got to do with it?
Robin G Hewitt
Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here.
All logos and trade names are the property of their respective owners.