There's got to be a way... I'm controlling a DC motor with PWM on a 16F877. I
need to take an analog reading just before the PWM output goes high. The
results of this analog reading are used to adjust the PWM duty cycle.
I'm using the CCS compiler, and not using any other timers.
I'm supposed to show this to a customer tomorrow. I suppose I could go back to
the bit banging (which worked sort of OK), but it seems like a terrible waste
not to use the PWM module.
Any help gladly accepted. :-)
Phillip M. Vogel, President | "It's not what you've been taught,
Bartal Design Group, Inc. | it's what you've learned." (me)
318 Marlboro Road | +1-201-567-1343 FAX:+1-201-568-2891
Englewood, NJ 07631 USA | bartal.comphillip
Indeed, you must bit bang it. But if you are running timer0 at a fairly brisk
pace already, then you are not wasting that much time. I did it your way, and
yes, you realy must read it just before firing the FET. If wasting too much time
is a concern, remember that DC motors work at relatively low PWM rates. As a
matter of fact, I resigned trying to use the PWM because it did not go SLOW enough
for the job. Anything over 30-60 Hz is actually somewhat of a waste for simple
By the way, the 8 bit word that I used for the bit banged PWM created a 1/256
error, and the customer measured it on their meter. They promptly turned their
nose up, handed me an old analog only motor controller (SCR style) and told me to
do it over. The new one works like a charm.
Pioneer Microsystems, Inc.
Phillip Vogel wrote:
> There's got to be a way... I'm controlling a DC motor with PWM on a 16F877. I
> need to take an analog reading just before the PWM output goes high. The
> results of this analog reading are used to adjust the PWM duty cycle.
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- New search...