Swiching Mode Charger / PWM questions


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Swiching Mode Charger / PWM questions

    Hi,
    CCP1 is fine, I just used CCP2 because that's what you used in your previous post.
    The fact that you're getting 31.25kHz indicates that the PLL isn't active. You should get 125kHz which is 4 times (ie the PLL ratio) of what you're actually getting. I'm not SURE that's what's happening and I'm not sure WHY - if that's case.

    One thing, which isn't related to the problem: You should always tell the compiler which oscillator speed you intend to run at so that it can calculate the correct values for things like PAUSE and so on. In this case
    Code:
    DEFINE OSC 32
    This does in no way SET the frequency, it just tells the compiler how fast you INTEND to run.

    Next thing, your program doesn't end anywhere, it'll continue to execute thru blank program memory until it reaches the end at which point it'll start over. Maby that's got something to do with it. Put some infinity loop at the end like
    Code:
    DoItForever:
    TOGGLE PortB.0
    Pause 10
    Goto DoItForever
    Using the above infinity loop will also allow you to verify if the PIC is actually running at the intended 32MHz by looking at the signal comming out of PortB.0, or whichever pin you like.

    Apart from that I can't really see what might be wrong.

    /Henrik.

  2. #2
    Join Date
    Sep 2013
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Swiching Mode Charger / PWM questions

    I figgured it out!!! Or at least I think I did.... none the less it is working now.

    I was taking a stab at different things to see what may be causing the PLL not to run.

    If you notice, my OSCCON register is set to 11110010.

    I changed the OSCCON to = 11110000 and the output on pin 13 is now 125k (actually 124.8k according to the scope)

    And thank you for pointing out my lack of defining the oscillator and my lack of any program.

    Like I mentioned, I was taking stabs at things I thought might be inhibiting my progress, so I was stripping back everything I could. I guess I went a little too far.

    Thank you once again for your assistance. Higher PWM frequencies were a major hurdle in my next design stage and I had to figgure it out. It will allow my project to use much smaller components and be more efficient.

    -Albert

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Swiching Mode Charger / PWM questions

    Great, I'm glad that it works!
    I can't say I understand WHY though.... Setting the lower two bits of OSCCON to 00 selects the primary oscillator as the source while setting it to 10 selects the INTOSC, I thought the PIC should be run by the internal oscillator.... Oh, wait, NOW I think I see what's going on...

    Look at the figure 2.8 in the datasheet. When we select INTOSC by setting the lower two bits in OSCCON to 10 we're driving the chip directly from the internal oscillator with whatever frequency we set it to. The signal comming out of the "OSCCON MUX" in the diagram is selected to drive the PIC via "Clock Control MUX".

    But when we enable the PLL we have the switch the clock source from INTOSC to the Main Oscillator block (even though that's what we use with EXTERNAL crystal) so that we get the signal from the PLL (which is now driven by the internal oscillator). The "real" primary oscillator is disabled though because we've selected the INTIO67 mode via the CONFIG bits.

    Anyway, I'm glad you figured it out, good luck with the rest of the project!

    /Henrik.

Similar Threads

  1. 18F4431 - Complementary mode PWM
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 15th December 2011, 12:23
  2. 18F2331 Advanced PWM Questions
    By JDM160 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2010, 00:04
  3. 9V NiMH charger
    By bogdan in forum Schematics
    Replies: 0
    Last Post: - 10th September 2009, 04:43
  4. switch mode power supply with PWM
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 14th July 2009, 21:51
  5. Adcin charger
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th November 2008, 22:49

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