+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Junior Member level 2
    Points: 496, Level: 4

    Join Date
    Nov 2010
    Posts
    22
    Helped
    0 / 0
    Points
    496
    Level
    4

    setting duty cycles using ccp1con

    How do I set the pwm module to use the 8 msbs of the ccp1rl bits and ignore the 2lsbs in ccp1con

    •   AltAdvertisement

        
       

  2. #2
    Administrator
    Points: 69,512, Level: 64
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    bigdogguru's Avatar
    Join Date
    Mar 2010
    Location
    Southwest, USA
    Posts
    9,832
    Helped
    2358 / 2358
    Points
    69,512
    Level
    64
    Blog Entries
    4

    Re: setting duty cycles using ccp1con

    In other words you want to take a 10-bit PWM duty cycle and turn it into an 8-bit PWM duty cycle?

    Why?



    •   AltAdvertisement

        
       

  3. #3
    Junior Member level 2
    Points: 496, Level: 4

    Join Date
    Nov 2010
    Posts
    22
    Helped
    0 / 0
    Points
    496
    Level
    4

    Re: setting duty cycles using ccp1con

    My program is varying duty cycles taking them from a lookup tgable therefore it is difficult to change ccp1rl at the same time changing ccp1con and the signal is at 200khz therefore the resolution is to be about 6 bits so how do I set these in my program.



    •   AltAdvertisement

        
       

  4. #4
    Administrator
    Points: 69,512, Level: 64
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    bigdogguru's Avatar
    Join Date
    Mar 2010
    Location
    Southwest, USA
    Posts
    9,832
    Helped
    2358 / 2358
    Points
    69,512
    Level
    64
    Blog Entries
    4

    Re: setting duty cycles using ccp1con

    One possibility is leaving the LSBs in CCP1CON set to zero, while changing only the eight MSBs in CCP1RL this would effectively reduce your PWM duty cycle resolution by a factor of 4.

    This means your changes to the PWM duty cycle will by coarser, larger changes.

    ---------- Post added at 09:00 ---------- Previous post was at 08:51 ----------

    Here's a thread discussing modification of PWM duty cycle:

    PWM Duty Cycle


    1 members found this post helpful.

  5. #5
    Junior Member level 2
    Points: 496, Level: 4

    Join Date
    Nov 2010
    Posts
    22
    Helped
    0 / 0
    Points
    496
    Level
    4

    Re: setting duty cycles using ccp1con

    CAN YOU PLEASE HELP ME ON SINUSOIDAL PWM .Is the value of ccpr1l loaded by an interrupt service routine of tmr2 or there is need to use another timer . I want to get a 50hz sine wave therefore should I use tmr2 to change the duty cycle.how am I going to determine the 50Hz frequency in my code most preferebly in asm.My switching frequency is 200khz .



  6. #6
    Administrator
    Points: 69,512, Level: 64
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    bigdogguru's Avatar
    Join Date
    Mar 2010
    Location
    Southwest, USA
    Posts
    9,832
    Helped
    2358 / 2358
    Points
    69,512
    Level
    64
    Blog Entries
    4

    Re: setting duty cycles using ccp1con

    Hi gedzak,

    I'm working on a ASM program using interrupts to generate PWM.

    Actually, I found some code from a previous project using PWM sinusoidal generation, so I modifying it to fit your needs. I'll also physically test the algorithm.

    Quick question, by "...switching frequency is 200kHz", you mean the sampling frequency of PWM, correct?



    •   AltAdvertisement

        
       

  7. #7
    Junior Member level 2
    Points: 496, Level: 4

    Join Date
    Nov 2010
    Posts
    22
    Helped
    0 / 0
    Points
    496
    Level
    4

    Re: setting duty cycles using ccp1con

    Yes it is the frequencyis the sampling frequency.thanks



--[[ ]]--