finding missing pulses


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838

    Default finding missing pulses

    HI guys , i am stumbling a little on how to do this in the code using pulsin , rctime to determine which pulse is missing in the stream

    thought using pulsing to find the 1ms low header then grabbing the next 10 pulses but thats not going to work if some are missing , so need to stop when the next 1ms low is there ???
    and then how to find which pulse was missing ??



    i have pulse stream that has

    1. 1ms low header followed by 10 pulses when all is ok then the 1ms low header for next stream , the duration between first 1ms header and next header pulse is close to constant of about 7ms

    The 10 pulses , when all there have a @300us high , with a either a @300us low or @450us low depending on flag set 0 or 1
    each pulse position low 1 - 10 relates to a input .

    so when the input 6 is not there ( missing ) the signal remains high in the stream for that position
    i need to know which pulse input went missing in the stream ( eg did not go low ) , there may be many inputs that go missing at any given time and but i still get the 1ms header at the start

    can someone give an example on how to do this


    cheers

    Sheldon

  2. #2
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Default Re: finding missing pulses

    I'm a bit puzzled by this, but I'm thinking a big state machine and a timer.

    The state machine starts after the detection of the 1ms pulse (you could use PulseIn for that). Once you have a negative pulse with a duration of 1ms you go into the state machine. Start a timer checking for the first falling edge. If the falling edge is more than 300us you missed a pulse (tag it as missing), stop the timer and start counting again for the next 300us. If you did not miss a pulse (i.e. you got a falling edge - tag it as present), stop the timer and wait for the next rising edge, start your 300us count once more. Do this until your overall count is 10. At that point you should be ready for the next 1ms pulse. I'm probably all over the place, but this seems reasonable. This does nothing to figure whether any present pulse is a 1 or 0; but you can add that after you get the missing pulse detection part.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,037


    Did you find this post helpful? Yes | No

    Default Re: finding missing pulses

    I would suggest Interrupts on Port B, bit 0. It has Interrupt on edge either high or low, and you control this by bit 6 in Option_Reg.

    I'll try a test code to show you how.

    Do you have a PIC prefference?

    Ioannis

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,546


    Did you find this post helpful? Yes | No

    Default Re: finding missing pulses

    try something like this, you need a chip with ioc capability and dt ints

    you need to set tmr1 to just exceed a 255 count when a pulse is missing

    I use this state engine to decode Manchester code it should just a easily find and identify a missing pulse

    rec:

    pulsin rx ,0,pt
    if pt < t1ms then goto rec ; look for 1ms start pulse
    bit_cnt = 0 ; clr bit counter
    TMR1H=0 ; clr stopped tmr1
    TMR1L=0
    SB=RX ;read input pin to set int on change status

    T1CON=$31 ; start timer : setup timer to count past 255 when pulse missed ie say 450us = a 255 count

    INTCON=$88 ; enable interrupts
    IOCA.5=1 ; ioc int
    while (bit_cnt < 7 ) and ( flg.0=0) ; receive 8 pulses , adjust to suit

    wend
    IOCA.5=0 ; ints off timer off
    INTCON.0=0
    T1CON=$30
    ; if bit_cnt < 7 then missing pulse = bit_cnt
    return






    rec_isr:

    if TMR1H > 0 then flg.0=1 ; timer count > 255 ie. missing pulse

    IF TMR1L > t300us THEN ; discriminate between 300/ 430 us
    T1CON=$30
    pkt.0[BIt_cnt]=!SB ; save 1 for 430 0 for 300
    TMR1H=0 ; clr timer
    TMR1L=0
    T1CON=$31
    bit_cnt = bit_cnt+1 ; inc pulse count
    ENDIF


    SB=RX ;read port to reset ioc state , helps if noise is a problem

    INTCON.0=0
    endif

    @ INT_RETURN

  5. #5
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: finding missing pulses

    cheers guys , seems a setting the timer is the way to go and triggered by the 1ms low , working with a state machine , the problem i am seeing is the the timed pulse sometimes drift a little , but i hopping not enough over the 7ms to be incorrect. ill try some of the code and see , i am using DT_int14 for the timer's

Similar Threads

  1. need help finding a PIC
    By asdhillon86 in forum General
    Replies: 1
    Last Post: - 10th January 2011, 00:49
  2. Help in finding technical info.
    By hackableFM in forum Off Topic
    Replies: 3
    Last Post: - 27th February 2009, 04:20
  3. Help finding Alarm System Example
    By bbawkon in forum General
    Replies: 1
    Last Post: - 20th September 2008, 06:39
  4. Lost in finding a example
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th January 2007, 23:20
  5. Help finding Crosspoint Switch?
    By muddy0409 in forum General
    Replies: 13
    Last Post: - 12th January 2007, 03:30

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