Hi,
Is it possible to have a HWPM but turning ON on the second half and it is set at 50%.
I would like to create alternating devices work at 50%.
thanks
K
Hi,
Is it possible to have a HWPM but turning ON on the second half and it is set at 50%.
I would like to create alternating devices work at 50%.
thanks
K
Why not just invert the HPWM signal with a transistor then you will have two outputs of opposite phase.
Keith
www.diyha.co.uk
www.kat5.tv
that the way I am doing it now, with a pull down mosfet, I wanted to know if there was a software solution. like adding an argument in the HPWM command.
k
Hi Lerameur. Good news. As I’m writing this, I’m looking at my scope. Portb.7 is exactly 180 degrees out of phase with HPWM 1, which is portb.2 on a 16F819.
START:
HPwm 1,127,100 'OUTPUT 100HZ SQUARE WAVE ON PORTB.2
SPLITPHASE:
IF PORTB.2 = 1 THEN LOW PORTB.7 'IF RB2 IS HIGH MAKE RB7 LOW
IF PORTB.2 = 0 THEN HIGH PORTB.7 'IF RB2 IS LOW MAKE RB7 HIGH
GOTO SPLITPHASE
Pete,
thanks, but
Is it intended to be 180 degrees out of phase with HPWM 1 ? is this normal, how would I know which port is 180 degrees out of phase in another pic, 16f88 for example... beside trying them all![]()
You need to read the datasheet for the particular PIC you want to use. On the 16F88, the HPWM 1 module (shown in the pinout as CCP1) is on RB0 instead of RB2. The pin that is 180 degrees out of phase is specified by you in the code. In "SPLITPHASE" I used RB7. You can use any port you want to duplicate and invert the HPWM output by specifying the pin you want.
START:
HPwm 1,127,100 'OUTPUT 100HZ SQUARE WAVE ON PORTB.0 ON 16F88
NEWSPLITPHASE: 'FOR 16F88
IF PORTB.0 = 1 THEN LOW PORTB.X 'IF RB0 IS HIGH MAKE YOUR PORTB PIN LOW
IF PORTB.0 = 0 THEN HIGH PORTB.X 'IF RB0 IS LOW MAKE YOUR PORTB PIN HIGH
GOTO NEWSPLITPHASE
You now have an inverted duplicate of the HPWM output on RB0 on your choice of portb. (In the code as PORTB.X)
2 issues with this method. First, while the signals may appear to be 180 degrees out-of-phase , this appears to be true only at very low frequencies. Try this at a higher frequency - say 10kHZ up and you will see that the complementary phase will be more than 180 degrees out (due to the processing time of the "splitphase" loop). The higher the frequency, the more pronounced this effect will be.
Second, while the code is running, the processor cannot be doing anything else.
A better solution would be to use a PIC with an ECCP (Enhanced Compare Capture) module. Many of the newer PIC's have this feature. Set it up to operate in Half-Bridge mode and you will get a PWM signal on the P1A pin and a complementary signal on P1B. Plus you can control the programmable dead-band delay which is used to prevent shoot-through current in half-bridge devices.
Great suggestion. Quite honestly, I never asked lerameur what his intended frequency was.
Bookmarks