125KHz HW PWM Output


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    I found this:

    https://www.micro-examples.com/publi...alculator.html

    Which produces this:

    PR2 = 0b00001001 ;
    T2CON = 0b00000101 ;
    CCPR1L = 0b00000100 ;
    CCP1CON = 0b00111100 ;

    Running that results in 3.8 / (3.8 +5.2) = 47.5% which is much closer.

    FYI: This is for a RFID application wherein the center frequency is important to the resonate gain of the attached antenna.

    Wondering if this is an 8, 10 or 16Bit computation?
    Wondering if this makes any difference consideration the even value of 125.0KHz?

    Thanks,

    Jay Zebryk, W1JRZ

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    totally missing the point

    CCPR1L = $14 not 14 ; its hex 14 or dec 20

    Warning I'm not a teacher

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    It is a 10bit PWM system but the resolution of the PWM signal depends on the PWM period or frequency. Higher the frequency, the lower the resolution.

    So, at 20MHz and a frequency signal of 125KHz, the resolution will be 7 bits only, even though the control register is 10bit wide.

    Ioannis

  4. #4
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    Ioannis,

    Thanks for the feedback!

    I have been using the attached calculator from Mister E.

    Name:  Mr_E.png
Views: 657
Size:  8.3 KB



    Is the Duty Step % (0.625) X 50% = 31.25% the problem?
    (I am measuring 3.8uS On / 4.2uS Off)
    How can I set it for 4mS On / 4mS exactly?

    (FYI, I am headed towards filtering the Square wave into a Sine wave and want it to be symetrical.)

    Is this even doable with the ancient 16F628?
    I am only using this because I had the Dev Boards handy.
    Do you remember Bruce Reynolds?
    What would you recommend for a 8PIN Dip?

    Peace,

    Jay Zebryk


    Attached Files Attached Files

  5. #5
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    Referencing the Mister e Calculator, it looks like the best resolution you can get is 0 to 160, where 160 will be 100% Duty Cycle.

  6. #6
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    Hi,

    That implies one needs to set the Duty Cycle to 80 to get a 4uS On / 4uS Off square wave?
    (This does not make sense to me.)

    Thanks,

    Jay Zebryk

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    Richard already covered it but it seems to have been overlooked.

    The duty cycle register is 10bit wide but, as Ioannis says, the usable number of bits differs depending on the PWM period. The calculator tells you that for 125kHz (with PR2=39) varying the duty cycle register from 0 to 160 will give you a duty cycle of 0-100%.

    For 50% duty cycle you obviously want to set the register to 80.

    Now, remember that the register is 10bit wide and that two low order bits are in CCP1CON so what goes in CCPR1L is the top 8 bits of the 10bit value. Or, in this case 80/4=20 which, as Richard rightly points out is $14.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: 125KHz HW PWM Output

    Is the Duty Step % (0.625) X 50% = 31.25% the problem?(I am measuring 3.8uS On / 4.2uS Off)
    How can I set it for 4mS On / 4mS exactly?
    your understanding is flawed and math is incorrect

    Duty is Steps x 0.625% // steps = CCPR1L x4 + CCP1CON<5:4>

    so:
    80x0.625% = 50% <=> steps = 20x4 + 0
    56x0.625% = 35% <=> steps = 14x4 + 0
    Warning I'm not a teacher

Similar Threads

  1. 18f4431 pwm output
    By prits068 in forum mel PIC BASIC
    Replies: 0
    Last Post: - 5th April 2010, 21:41
  2. 4 PWM output
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th September 2008, 06:19
  3. 4-20mA output using PWM
    By gavo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th December 2007, 09:45
  4. 2 PWM output
    By Md.Shah in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th October 2006, 22:38
  5. 18F6585, PWM Output, which Pin?
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th April 2005, 21:37

Members who have read this thread : 2

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

Tags for this Thread

Posting Permissions

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