Quote Originally Posted by peterdeco1 View Post
Hi Lerameur. Good news. As I知 writing this, I知 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
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.