PDA

View Full Version : Best way to shut down HPWM channel?



LetTheSmokeOut
- 26th January 2010, 20:07
Hi,

I am playing with a circuit that charges a capacitor and then dumps it into a battery (pulse charging). All I need to do is turn HPWM channel 1 on and charge cap, then turn HPWM channel 1 off and Turn HPWM channel 2 on to dump the charge back to the battery. Code is attached, but I am wondering if setting CCP1CON to disable is the best way to turn off channel 1 before I turn on channel 2?

Thanks in advance.

Gusse
- 26th January 2010, 20:25
I have used following to turn off HPWM.

<body><!--StartFragment--><pre><code><font color="#000000"> CCP1CON = %00000000
T2CON.2 = 0
</code>
Don't know if that is right way to do it, but it is working :eek:
It would be nice to hear if there is some better way to do that.

BR,
-Gusse-

Byte_Butcher
- 26th January 2010, 20:40
Why do you need to turn the channel off? Do you need to use that channel for something else also?

Can't you just set the PWM duty cycle to 0?

HPWM 1, 0, 3550


steve

LetTheSmokeOut
- 26th January 2010, 20:50
Hi,

Sure, I guess I could take the duty cycle to zero. I suppose I can test it.

I needed to shut the first channel off because this is a closed loop system, I.E. Battery, Mosfet > inductor > bridge > cap > mosfet > battery. Therefore I needed to isolate the input from the output to some degree. The goal was to see if lead acid desulfation can occur if a constant pulse is sent to the battery after charging a cap.

In theory it should work because we are forcing the lead sulfate back into solution in a brute force kind of method with a high voltage and high current pulse.

Thanks for the suggestions guys. I suppose either method will work equally well, I just wonder how many clock cycles it will take for either method or if it's even a concern. I'd surely like to use the fastest method.

Bruce
- 26th January 2010, 21:14
The fastest approach is probably just setting the pin to input. Then flipping it back to
output when you need PWM on again.

LetTheSmokeOut
- 26th January 2010, 22:01
Thanks Bruce, I will try that as well.

Tad