PDA

View Full Version : HPWM confusion



rossfree
- 3rd November 2005, 13:50
Ok... please forgive. I've read the posts. I've seen the code and still I just don't get it.

Using the PWM command requires the output pin, the duty, and the cycle... cycle being the length of time that it is running right?

So:

pwm portb.1,127,200 '4mhz clock

would produce pulses on portb.1 at an approximate 50% duty cycle for 1 second right? Then you'd bounce to the next line of code.

When you use HPWM, it runs in the background until it is stopped. So why do you need to put a cycle time? Doesn't it just run until you tell it not to?

I know this is simple but my brain just won't allow entrance!!!

Thanks for holding my hand!

Ross

CocaColaKid
- 3rd November 2005, 14:15
Ross, there isn't a cycle in the HPWM command.

HPWM Channel,Dutycycle,Frequency

Channel is the output you want to use.

Dutycycle is the on/off ratio.

Frequency is how many times it does it per second.

rossfree
- 3rd November 2005, 16:35
Thanks CocaColaKid,

That helps a lot.

How is a frequency chosen for a given application? I suspect it will depend on what is being driven.

Can someone give pros and cons of high and low frequencies for the HPWM command? Rules of thumb? Anybody?

Thanks,

Ross

CocaColaKid
- 3rd November 2005, 16:50
That's a good question. I'm not really sure, I usually just use 1kHz.