View previous topic :: View next topic |
Author |
Message |
marcusayoung
Joined: 03 Jun 2009 Posts: 28
|
ECCP Half-Bridge PWM (Hardware Issue) |
Posted: Sun Aug 28, 2011 11:01 am |
|
|
Hi All,
I'm using a 16F1823 and i'm also seeing this issue with a 16F684.
I've been working with the ECCP/PWM module to generate a sine wave with some external RC filtering. The method is straight forward: I use an 8-bit LUT containing the sine wave pulse width values at a ~38kHz PWM rate. End sine wave frequency is set by how fast i index the LUT. Furthermore, the PWM is set for half-bridge mode with zero dead band delay. The code works great, i get all the functionality i expect.
The issue is that I see different DC offsets for the different polarities of P1A and P1B as set by CCP1CON[1:0] (see oscilloscope measurements below). Ideally i want the same DC offset for both pins when they are either both active high (180 degrees out of phase) or one is active high and the other active low (same phase).
CCP1CON[1:0] | Pin5 DC Offset (V) | Pin6 DC Offset (V)
0,0 | 1.43 | 3.31
0,1 | 1.43 | 1.43
1,0 | 3.31 | 3.31
1,1 | 3.31 | 1.43
PIC supply is 5V, and the PWM signaling levels also measure this. Post-filtered sine wave measures 2.86Vpp.
The method for generating this sine wave is the same for all cases, so i can only imagine that the 'output controller' (as labeled on Figure 24-5 of the PIC16F1823/PIC12F1822 datasheet) is introducing these offsets. I definitely can't have these DC offsets because it affects the gate bias of the FETs for the different polarity settings.
Any ideas? Hopefully this is just some funky register setting that i missed. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 28, 2011 1:41 pm |
|
|
If you have a DC offset, one possible reason is that your positive and
negative half-cycles are not equal in amplitude and/or duration. Are you
doing something in your code, maybe with your lookup table, that could
cause this ? |
|
|
marcusayoung
Joined: 03 Jun 2009 Posts: 28
|
|
Posted: Sun Aug 28, 2011 2:19 pm |
|
|
Ah yes!
The LUT has 256 samples, but the PWM register is 10-bits. Looks like i need more values if i want perfect compliments. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 31, 2011 2:13 am |
|
|
What is your output sine wave frequency?
You're not giving me enough information to work on.
Can you post a short compilable program which shows the problem.
Mike |
|
|
|