Count Pulses and duration


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Count Pulses and duration

    if the two inputs start and stop together ... the length of ch1 is the sum of all pulses @ ch2 ... ( M. de La Pallice )

    so, no need to care of ch1 ...

    aaaaa.......

    just need to log pulses @ ch 2 ...

    one "pulsin" followed by enough "RC Time"s will do it ...

    Alain
    Last edited by Acetronics2; - 12th February 2014 at 19:33.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Count Pulses and duration

    Hi there,

    @Henrik

    I was thinking of using a 12F615. The MCu will only have a tight loop where it's just waiting for the inputs to start.
    After stopping it will analise the results and can go back to wait for signals again or move forward.

    @Alain

    Yes... both start and stop together...the problem is that the pulses ( 35ms ) may vary in quantity in the same period of time.

    Regards
    Rui

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


    Did you find this post helpful? Yes | No

    Default Re: Count Pulses and duration

    Hi,
    OK, so the 12F615 has the TMR1 Gate feature, I'd say you're good to go for an all hardware solution - and since there's no pulses on second line when the first line isn't high then it gets even easier.

    Set up TMR1 as a timer with the gate control enabled, clear it and feed the "long" pulse to the gate control pin, this will measure the duration of the long pulse. Set TMR0 up as a counter, clear it and feed the pulses to the counter input, this will count the number of pulses.

    If you use the comparator as the gate control for TMR1 you might be able to set an interrupt up to trip when the duration of the long pulse ends.

    /Henrik.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Count Pulses and duration

    Quote Originally Posted by ruijc View Post
    @Alain

    Yes... both start and stop together...the problem is that the pulses ( 35ms ) may vary in quantity in the same period of time.

    Regards
    Rui
    and ... Where's the problem ???

    the RCTime timeout feature will take care of that for you ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Count Pulses and duration

    Thanks guys,

    I still have some doubts on how to code this but i will use your tips, study them a bit and try some lines of code.

    Regards
    Rui

Similar Threads

  1. Can I use PWM and count pulses for feedback?
    By queenidog in forum General
    Replies: 1
    Last Post: - 30th January 2012, 17:31
  2. Replies: 1
    Last Post: - 11th June 2011, 08:22
  3. Pin max current - short duration?
    By kevj in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd January 2008, 12:53
  4. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  5. SOUND Command (duration is too long)
    By martarse in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th August 2004, 02:18

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