still don't have solution!!!


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    45

    Default still don't have solution!!!

    hi.please help me.i still can't generate my 120khz pwm using pic16f877a.the maximum that i can get is 50khz using hpwm.and 80khz using my own modification pwm(high--puase---low---pause).pleaseeeeeee....help me....

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Hi,

    ... use a 40 Mhz clock !!! ... Pic 18 F xxxx !!!

    or a dedicated chip ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by texas5 View Post
    hi.please help me.i still can't generate my 120khz pwm using pic16f877a.the maximum that i can get is 50khz using hpwm.and 80khz using my own modification pwm(high--puase---low---pause).pleaseeeeeee....help me....
    With what code are you trying to generate this 120khz?
    I don't see anything either...

  4. #4


    Did you find this post helpful? Yes | No

    Talking

    Why not just use an LM324 quad opamp. Set up a couple in a feedback oscillator at the frequency of your choice. Run the output of the oscillator (triangle wave) into a third gate as a comparator. From the pic all you need is a couple of resistors to set your DC level at the right place to slice a 50% duty cycle. Easy....you can turn it on and off when ever you want.

    Nick

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    You will not get 120KHz - the closest is 125KHz. Assuming a clock of 8MHz, this will give you 125KHz on CCP1 (RC2) with a PIC1F877A.

    Code:
    TRISC = 0  'PORTC all outputs
    PR2 = 15  'Load Period Register
    CCPR1L = 8  'Set 50% duty cycle
    CCP1CON = %1100  'PWM mode
    T2CON.2 = 1  'Start TIMER2

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by texas5 View Post
    hi.please help me.i still can't generate my 120khz pwm using pic16f877a.the maximum that i can get is 50khz using hpwm.and 80khz using my own modification pwm(high--puase---low---pause).pleaseeeeeee....help me....
    Come to think of it...we've already been over this!!!
    If you check one of your other threads, I've already shown that you can generate 120khz using a 'non-standard' crystal.

  7. #7
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Right, as Skimask says. Check up TipsTricks_41214A.pdf on the Microchip site and scroll down to the X10 carrier generation bit.

    Regards,

    Anand

  8. #8
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Yes, he can get 120KHz with a standard 12MHz crystal and setting PR2 = 24. I think his problem is that he does not seem to be able to get more than 50KHz with HPWM. It may be a PBP thing, I don't know, that is why I suggested setting up the HPWM manually. With a 8Mhz clock, you can get up to 500MHz PWM, albeit with little to no resolution on the duty cycle.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rmteo View Post
    Yes, he can get 120KHz with a standard 12MHz crystal and setting PR2 = 24.
    I don't remember the PR2 value, but I got the same thing using a 9.6Mhz crystal.
    Your solution is better though...standard crystal and supported by PBP.

    I think his problem is that he does not seem to be able to get more than 50KHz with HPWM. It may be a PBP thing, I don't know
    PBP itself won't allow over 32Khz unless using LONG variables (PBPL 2.50), then you can (in theory) get 2Ghz out it...obviously won't happen...or will it? (see below or above whichever)
    He's trying to do a square wave manually (bit high, wait, bit low, wait, repeat), bit bang the pins.

    that is why I suggested setting up the HPWM manually. With a 8Mhz clock, you can get up to 500MHz PWM, albeit with little to no resolution on the duty cycle.
    WOW! 500MHZ from 8MHZ! I want your chip!

  10. #10
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Here is a scope trace of 500KHz HPWM using a 8MHz clock:

    Horizontal is 500ns/division, Vertical is 2V/division.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rmteo View Post
    With a 8Mhz clock, you can get up to 500MHz PWM, albeit with little to no resolution on the duty cycle.
    post #8

  12. #12
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    OK, here is a brain teaser for you. With an 8MHz clock on a PIC16/18, what is the maximum frequency HPWM that can be achieved, and how would you do it (in terms of register values for CCPR1L and PR2)?
    Hint: the answer is in the scope trace above.

  13. #13
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    post #8
    mea culpa. Should have been 500KHz.

Similar Threads

  1. Strange I2C problem (and solution)
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2008, 19:14
  2. Replies: 6
    Last Post: - 20th September 2008, 12:28
  3. The Best Solution
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 28th May 2007, 05:25
  4. Need PC software solution
    By mister_e in forum Off Topic
    Replies: 9
    Last Post: - 27th November 2005, 02:18
  5. Battery Solution
    By Keith in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd July 2005, 06:07

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