HPWM10 Frequency Updating


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    A PIC can't do 10 bit PWM to 500Khz, since it would need a counter running at 500KHz * 1024 = 512MHz.
    Charles Linquist

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    A PIC can't do 10 bit PWM to 500Khz, since it would need a counter running at 500KHz * 1024 = 512MHz.
    Absolutely Correct!
    As the frequency increases, the resolution decreases.

    Follow that all the way to the highest frequency, and with OSC=16, you should have 2mhz PWM at 1-bit resolution (essentially on or off).

    @ 500 khz, you should have 4-bits. And if all you ever want is 50% dutycycle, then it's a piece of cake.
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default 10 bit HPWM at 32767 Hz

    Hi Darrel & Charles.

    I need 50% duty cycle at 32767 Hz on CCP2 to drive an Intersema pressure sensor - easy - even I can do that with 8 bit HPWM.

    I also need a variable duty cycle to drive an AGC circuit. With 8 bit HPWM, my AGC is sudden death and one count goes from not quite enough to a little bit too much. 10 bit HPWM would be much less sensitive. The frequency must stay at 32767 Hz to suit the Intersema sensor.

    Can I get 10 bit HPWM at 32767 Hz?

    Cheers
    Brian
    Last edited by BrianT; - 8th January 2008 at 09:20.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    As long as your OSC is 20 or more, then Yes.
    @ 4mhz OSC you only get 8-bit resolution with that freq.

    HPWM10 should work fine with it.
    <br>
    DT

  5. #5
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Thanks everyone,

    I have had to be away for a couple of days, I did have to manipulate and condition the frequency values several times to obtain suitable results from the DIV32 operation, to provide a usable value for PR2.

    But it is very messy, maybe now not so bad after all.

    will follow up when I am back

    I should also try again to get PBL to compile, from memory I could not immediately find any solution to the error codes and did not wish to be sidetracked, considering LONGS was one of the features that prompted me to upgrade I should review.


    Thanks again

    Duncan

  6. #6
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi Back again

    I have changed from 16F648A to a 18F1320 to allow the use of PBPL, the pin allocations are different for the CCP and the USUART but that is now sorted.

    I am looking now at Darrel Taylor’s macro HPWM10, there are two uses of DIV32 the first calculating the value of PR2. The DIV32 multiply is within the PR2 ASM routine

    With Darrels' permission.. could the next lines be something like?

    HP_Long = (resultant of Multiplication) / HP_Freq
    HP_Temp = HP_Long.WORD0

    in which R register does the resultant reside?
    or remove the PR2 ASM altogether and just use PBPL.


    and the second use of DIV32 for the CCP section

    HP_Long = HP_Temp * HP_Duty
    HP_Long = HP_Long / 1023
    HP_Duty = HP_Long.WORD0

    long winded and compiles into 1624

    I would very much wish to contribute but I find it very difficult when there are so many people who know soooooo much more than I.

    Thanks also for the help Charles, I do not have any PICs hooked up to a 108 type keyboard, I presume that it is easier on is the older type rather than the newer PS2 type. Actually I have a couple of old magnetic swipe card readers and some old keyboard inline barcode readers as well in the same box, trouble is I could not begin to remember where the box might be

    I am also reminded that I used to know all the barcode symbologies once.......... now I regret all gone................ come to think of it quite glad really. maybe it made space for something more exciting


    Duncan

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Actually,

    My code does not connect directly to a keyboard. It receives data from the PICs serial port which is connected to a PC. The PC is running HyperTerm or TerraTerm. When you press the "UP" and "DOWN" arrow on a PC keyboard, HyperTerm actually sends out 3 ASCII characters (the first one being an <ESC>).

    So, on a HyperTerm session, when the program starts, the PIC asks what frequency you want the PWM to be -
    312Khz,156Khz,78Khz or 39Khz. It uses a table to set PR2 to the correct value, and then writes the desired PWM Value into CCPR1L and CCP1CON. You increment or decrement the
    PWM value by pressing the UP and DOWN arrow keys.
    Charles Linquist

Similar Threads

  1. Advice on frequency measurement to 30MHz
    By Andy Wood in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th March 2009, 04:23
  2. HPWM command and oscillator frequency
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th March 2009, 22:41
  3. inaccurate frequency using TMR1 PI18F452
    By nkarpovich in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 14th October 2006, 16:22
  4. frequency measurement
    By big-x in forum General
    Replies: 2
    Last Post: - 25th November 2005, 00:53
  5. Low frequency output
    By barkerben in forum General
    Replies: 5
    Last Post: - 16th November 2004, 15:25

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