1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Using a PIC to generate radio freq. PWM

Discussion in 'Microcontrollers' started by Mosaic, Aug 12, 2017.

  1. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,620
    Likes:
    129
    Location:
    Caribbean
    I am doing an experiment to build a 400W RF class E amplifier at about 4Mhz.
    This means controlling the duty cycle of the pulses governs the amplifier efficiency.

    I am considering the 48Mhz 18F25J50
    http://ww1.microchip.com/downloads/en/DeviceDoc/39931d.pdf

    Given the PWM Period:
    PWM Period = [(PR2) + 1] • 4 • TOSC•(TMR2 Prescale Value)
    It seems that a PR2 of 2 is the max I can get for a 4Mhz PWM drive.
    Which just gives 0,25,50,100% PWM settings. Not much control.

    The alternative is to make a one shot timer which is driven by a 4Mhz click line and then alter PWM by altering the one shot duration.

    Any suggestions on this?
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    You may get a better resolution using compare but the interrupt will need to be coded cleverly..

    Have a look at it as it kinda is the one shot solution.. BUT!! the CCP pin is toggled for you.. You need to reset the timer it the interrupt though!
     
  3. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,620
    Likes:
    129
    Location:
    Caribbean
    I didn't see a link in your post:

    But I did up this spice sim to allow for duty cycle mgmt over the range of interest. For the feedback control I'm thinking about averaging the miller current spikes (not sure how yet) thru the FET source and also the current coming thru the class E RFC then creating a ratio from the RFC current pulse of perhaps 80% as a control ref for an opamp to adjust the DC% via biasing the PNP in the sim.
    xtal osc.png
    class E amp.png

    Note the 'loss' current spike where the FET switches while there's still charge in the output capacitance.
    class E amp-miller.png
     

    Attached Files:

    Last edited: Aug 13, 2017
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia

    Although timer 2 is clocked at 1/4 of the 48MHz, the PWM module uses 2 extra bits for PWM so you will have 12 different values to work with.

    Edit, A value of 2 in PR2 only gives you 3 values not four. The two extra bits make it 12.

    Mike.
     
  6. Mosaic

    Mosaic Well-Known Member

    Joined:
    Jun 3, 2010
    Messages:
    2,620
    Likes:
    129
    Location:
    Caribbean

Share This Page