need audible pulse out that varies "on time"


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    So from what I feel, you'll need to use HPWM. Look in your datasheet to spot the CCP1, CCP2 pins, see if they're free, and If so, well, it's just a matter of few lines of code then.

    Play around this one
    Code:
    if Strenght= 0 then
            HPWM Channel, DutyCycle, Frequency
            PAUSE 500
            CCP1CON = 0 ' turn of PWM
            LOW YourBuzzerOut (or high depending)
            PAUSE 500
            endif
    
    if Strenght= 64 then
            HPWM Channel, DutyCycle, Frequency
            endif
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    thanks Steve,

    So this would require a pause of 1 second if the reading is zero? I can't afford that kind of delay. Is there another way?

    Mark

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yes, you could start an endless timer interrupt (let's say few milliseconds) in which you check your value, then start the HPWM and keep track of the required delay.

    OR, enable the timer interrupt in your code, and assign a duration or flags for the HPWM.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default

    The way I would do it is to implement a soft PWM. I think it's been covered on this site already. Let a timer run in the background every mS. Give it a value for on time of the buzzer (0-1000mS) Every time the timer ticks, you can verify if the buzzer needs to be on or off. Now, all you have to do is give it a value from your mainline code.

  5. #5
    Join Date
    Feb 2005
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    jerson,

    why soft and not HPWM? Honestly I'm not fully getting this...

    Mark

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    974


    Did you find this post helpful? Yes | No

    Default

    MUC

    Frankly simply because I'm so used to it by now, I've never had to do the HPWM. I do a lot of temperature controllers with cycle times in the range of 1 to 30 seconds. So, ..... It's more a matter of personal taste.

    Jerson

Similar Threads

  1. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 01:59
  2. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  3. Replies: 3
    Last Post: - 13th September 2008, 17:40
  4. Unwanted output signal jitter
    By LinkMTech in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 18th January 2008, 02:31

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