My first foray into PWM


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    You might, if you have one laying around, use a clock divider chip... or a counter... Here's a link that explains my thinking better than I can.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,705


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    You might be able to achieve something using compare mode and the external clock pin for timer1. if you have enough spare pins and if you were really clever
    use the hpwm output to drive tmr1ck then you could change the flash rate on the fly

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Euh, I think I'll just get back to finishing my Charlie-plexing work for now. LOL

    Thanks though, I will have to jump into PWM one day, hopefully next summer.

    Robert

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


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Hi Robert,
    In your first post you say LED ON for 500uS, OFF for 500uS but then you say you want a period of 1s - that's a difference of $03E8 times.
    I know you didn't want to do it with an normal interrupts but I'm going to suggest a simple timer interrupt anyway.... At such low frequencies (even though you're probably not going to get 500ms interrupt period in "on go") the interrupt processing will have very little impact on the overall performance.

    /Henrik.

  5. #5
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Hi Robert;

    An HeartBeat Led should be do it with a timer interrupt like Henrik sujested....
    If you cannot achieve tht time that you want, you do for instance, a 100ms interrupt and with a counter you can achieve the time that you want counting in 100ms spaces.
    You can count 5 x 100ms and then toogle the led.
    Thanks and Regards;
    Gadelhas

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Quote Originally Posted by HenrikOlsson View Post
    Hi Robert,
    In your first post you say LED ON for 500uS, OFF for 500uS but then you say you want a period of 1s - that's a difference of $03E8 times.
    ...

    (without considering oscillator speed and PWM range limitations)

    Then there's something about PWM that I didn't understand. HIGH/LOW using PAUSE for 500uS is not the same as a 1000uS period with 50% duty cycle?

    Name:  PAUSE vs PWM.PNG
Views: 749
Size:  2.2 KB
    Ooop, uS, not Us.

    Robert

  7. #7
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Quote Originally Posted by Demon View Post
    (without considering oscillator speed and PWM range limitations)

    Then there's something about PWM that I didn't understand. HIGH/LOW using PAUSE for 500uS is not the same as a 1000uS period with 50% duty cycle?

    Attachment 7531
    Ooop, uS, not Us.

    Robert
    Yes, from that point of view, it is the same thing! (without considering oscillator speed and PWM range limitations)
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: My first foray into PWM

    Then there's something about PWM that I didn't understand. HIGH/LOW using PAUSE for 500uS is not the same as a 1000uS period with 50% duty cycle?
    Yes of course, 500us ON and 500us OFF is 50% dutycyle. But the period is 500us+500us = 1000us = 1ms = 0.001s - NOT 1s which you later wrote.

    In your first post you indicated you wanted a PWM period of 1000us (a frequency of 1000Hz). In your second post you said you wanted a period of 1s (a frequency of 1Hz). It doesn't add up - that's all I was trying to say.

    /Henrik.

Similar Threads

  1. Replies: 1
    Last Post: - 4th March 2013, 22:57
  2. PWM to 0-5V
    By tallen in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th April 2010, 09:03
  3. help with pwm
    By babatundeawe in forum Schematics
    Replies: 6
    Last Post: - 30th October 2008, 13:35
  4. Pwm
    By xobx in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 11th February 2008, 07:33
  5. Pwm
    By JARI NETWORKS in forum mel PIC BASIC
    Replies: 4
    Last Post: - 1st September 2006, 07:03

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