Overlook a short pulse???


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    92

    Default Overlook a short pulse???

    Hi,

    I've been trying to figure out the correct code to overlook a short pulse (~50ms) and only activate the program when it senses a longer pulse (500 ms).

    It doesn't look like Pulsin will work. I've tried the following in various forms:

    If PortB.1=1>500 then
    High PortB.2
    Endif

    This may be completely wrong,but I had to try and it does compile without errors.

    I haven't figured out "count" yet,I thought some version of that might work.

    If someone could just "steer" me in the right direction,I think I could get it. Still learning.

    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Pulsin should work, but you need to specify if your pulse is a high or a low... let's it's assume it's a positive-going 'High'. Pulsin measures in 10uS increments (at 4MHz PIC clock), and we'll set our threshold at 450mS (that's a count of 45,000 ticks at 10us)

    PulsePin var PortB.2
    PulseData var WORD

    PulseLoop:
    Pulsin PulsePin,1,PulseData
    If PulseData<45000 then goto Pulseloop

    If your code is trapped in the loop then you have either a Pulse that's too short, or greater than 655.35mS (WORD limit for Pulsin). So you can see that Pulsin will give you a 'window' to work within. It won't catch very long pulses that exceed it's max limit.

    Now let's rehash this giving us an unlimited upper Pulse width window...

    PulseLoop:
    PulseData=0 ' zero count
    While PulsePin=0:Wend ' wait here for a pulse to start
    While PulsePin=1 ' Loop here counting Pulse Length in 1mS steps
    Pause 1
    PulseData=PulseData+1
    If PulseData>450 then goto GotLongPulse
    Wend
    Goto PulseLoop

    Now, in this example, if your Pulse LOW is less than 1mS you may not catch the start of the next pulse if it follows on too fast, so just change Pause1 to PauseUS 100 and increase >450 to >4500 and you now have a 100uS count window. And pro rata etc etc...

    Melanie

  3. #3
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    Thanks much for your reply. It is a positive-going 'High' with alot of low time between the high pulses. I will do as you state and repost.

    Again, much thanks as I didn't know what else to try.

    Best regards

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. Pulse generation help required
    By Muzza in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd November 2005, 22:50
  5. Pulse Frequency Multiplication
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st August 2005, 10:39

Members who have read this thread : 1

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