HPWM on second half


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default HPWM on second half

    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

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6


    Did you find this post helpful? Yes | No

    Default

    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)

  7. #7
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by peterdeco1 View Post
    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
    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.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Great suggestion. Quite honestly, I never asked lerameur what his intended frequency was.

Similar Threads

  1. Bit Angle Modulation (BAM) in a PIC
    By Bronx68 in forum mel PIC BASIC Pro
    Replies: 150
    Last Post: - 24th February 2015, 13:41
  2. 18F4620 HPWM Half Bridge Mod problem
    By showtime in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd November 2007, 12:55
  3. Using HPWM in half bridge mode on 16f690
    By Chris Barron in forum mel PIC BASIC
    Replies: 0
    Last Post: - 29th December 2006, 11:18
  4. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts