How to make HPWM slower with 16F887?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: How to make HPWM slower with 16F887?

    Quote Originally Posted by HenrikOlsson View Post
    It's not 100% clear what it is you want to do but I THINK that it's not the PWM frequency you want slower (especially NOT a period of 3-4 seconds because then the LED WILL "blink" and not dim/fade) - it's the time between updating the duty cycle you want to change to increase/decrease the total time it takes for the LED to fade. Again, that's what I THINK you mean - which may be wrong of course.

    If you really DO mean you want a PWM period in the region of several seconds then, to be practical, I think you need to do the PWM "manually" using something like a 100Hz interrupt in the background.

    Finally, using HPWM like you're doing isn't ideal because it actually "restarts" the CCP module each time the command executes and this creates "glitches" in the outout, This may or may not matter in this case but be aware of it, Another drawback is that it only gives you 8 bit of resolution which can be on the low side for nice smooth LED dimming, especially at the lower end. Again, may or may ot matter.

    /Henrik.
    You are correct. I want to make the LED fade from 0% supply voltage to 100% supply voltage and then back down again. Does the 16F887 (or some other PIC) have a the ability to modulate an analog output? Or do I need to use some sort of peripheral device?

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


    Did you find this post helpful? Yes | No

    Default Re: How to make HPWM slower with 16F887?

    Then you ARE using the correct peripheral module. I just don't undersand why you think you need (or even WANT) to have the PWM period in the seconds range. The PWM frequency needs to be at least 20-25Hz or you WILL see that the LED is actually blinking.

    If you want to slow down the time it takes to fade up/down it is not the PWM frequency you need changing, it's how often you update the dutycycle. Just insert a PAUSE 10 in your FOR-NEXT loop and the fade will take 2.5 seconds.

    But again, managing the (E)CCP module "manually" is better for this. There are plenty of examples around for that but by all means, go ahead with HPWM to get started, its drawbacks may not affect you.

    /Henrik.

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: How to make HPWM slower with 16F887?

    Quote Originally Posted by HenrikOlsson View Post
    The PWM frequency needs to be at least 20-25Hz or you WILL see that the LED is actually blinking.
    Hi Henrik,

    I agree with your comment however it should be noted that a lot of people can still see the LED blinking at these rates. In fact, a small percentage of the population can still see LEDs blinking at 100Hz and higher!

    Cheers
    Barry

Similar Threads

  1. Can't make RA1 a digital Input on (10 out of 20) 16F887.
    By paulgrut in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 11th October 2013, 06:53
  2. USB HID is slower than often using PIC18f2550
    By Ahmadabuomar in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th November 2010, 14:05
  3. Mibam at 20mhz runs slower than at 4 mhz
    By Homerclese in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st October 2010, 18:41
  4. Code running 19 times slower than intended
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th April 2010, 12:20
  5. Servo Slower?
    By actionplus in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 4th September 2004, 13:56

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