pulsin is not getting the next part of wave


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

    Default pulsin is not getting the next part of wave

    Hi guys , well this one has got me thinking , and i am not sure how i may get around it , so a bit of advise on the code would be good

    IR data train is as follows

    seq is normally high , low for 9ms ,high for 4.5ms, low for 560us , high for data etc ,etc then at end it goes low for 9ms , high for 2.5ms, low for 560us , high for etc etc for 2nd key data block seq , and then repeats entire IR train

    the problem is i need to measure duration of low of 9ms , then the high duration of 4.5ms

    the high duration length ( 4.5ms or 2.5ms ) after the low 9ms determined if its the 1st or 2nd key within the same pulse also if its blank repeat of key 1

    the first Pulsin command gets the pulse length of 9ms ok , but the 2nd pulsin command will not measure the high duration until the next high going pulse.

    any suggestions on how to get the length of both the 9ms low and then the high 4.5ms pulse

    The 2nd pulsin command as shown below is not working as required

    cheers

    Sheldon


    Code:
    leader  var word
    leader1 var word
    
    
    Main: 
     
      PULSIN GPIO.0,0,Leader  ' leader pulse is ~9mS low-going on port 0 
      IF Leader < 850  tHEN  main
    
      pulsin GPIO.0,1,Leader1      ' check for 1stkey seq only no repeat headers 
      
     if leader1 < 300 then Main  ' if high for < 300 (2.4ms then its the 2nkey)

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    Hi,
    The second Pulsin misses the high portion of the pulse because it "trigs" on a low to high to transition - in this case the same transition that ends the first Pulsin - so by the time the second Pulsin starts looking for a transition the transition have already occured.

    Here's a more "manual" aproach which may work:
    Code:
    HighCount VAR WORD
    LowCount VAR WORD
    
    HighCount = 0
    LowCount = 0
    
    While GPIO.0 = 1 : WEND        ' Wait for falling edge
    
    While GPIO.0 = 0               ' Increment count while input is low
      LowCount = LowCount + 1
    WEND
    
    While GPIO.0 = 1               ' Increment count while input is high
      HighCount = HighCount + 1
    Wend
    The actual resolution obviosuly depends on the oscialltor speed etc but it shouldn't be hard to figure out how many "counts" equals one ms.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    i have gone around the problem by just looking for correct value of the high pause duration as i know if signal is valid and correct should always work

    Main:

    ' PULSIN GPIO.0,1,Leader ' leader pulse is high going on port 0
    ' IF Leader < 400 tHEN main ' look for 4,5ms high pulse below 400ms then its 2nd key area pulse or data/ address bits
    ' if leader > 480 then main ' above 480 then its no sig

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


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    I know from what i can see here that there is no easy way to both measure a pulse and then it next immediate rising or falling going pulse , am i correct in this ???

  5. #5
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    know from what i can see here that there is no easy way to both measure a pulse and then it next immediate rising or falling going pulse , am i correct in this ???
    Maybe not using pulsin,but you could always use hardware capture if the pic has it.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    With Pulsin the short answer is no.

    Using the Timer 1 Gate will be much more easier ifyour PIC supports it.

    Also controlling the Interrupt Edge on PB0 in combination with a timer (0 or 1) will also help you on this.

    The edge is set in the Option Register, bit 6 on most PICs.

    Ioannis

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    Did you try the snippet I posted in the first reply? I think it's pretty straight forward and I think it's pretty much the way that pulsin works "behind the scenes" except that doing this way "trigs" on level and not on transition.

    If it doesn't work for whatever reason there are several other ways, some of which other members have outlined here but in order to be able to give you a good advice things like which chip you're using and at what frequency you're running it would be good to know. Not to mention what kind of resolution you actually NEED.

    /Henrik.

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    Hi,

    Solution is pretty simple:

    Code:
    
    leader  var word
    leader1 var word
    
    Main:    
    PULSIN GPIO.0,0,Leader  ' leader pulse is ~9mS low-going on port 0
       
    IF Leader < 850  tHEN  main
      
    RCTIME GPIO.0,1,Leader1      ' check for 1stkey seq only no repeat headers
        
    if leader1 < 300 then Main  ' if high for < 300 (2.4ms then its the 2nkey)
    may be you could consider the IF condition takes few µs ... to be verified, because your time unit is 10µs !

    That's all !

    Alain
    Last edited by Acetronics2; - 30th March 2012 at 16:55.
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    it does have PWM , but not tried it as yet , still not sure it would pickup and measure the low to high to low to high cycle and give a measurement for both duration

    if only a pulsin "Mark 2" would do this

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


    Did you find this post helpful? Yes | No

    Default Re: pulsin is not getting the next part of wave

    Thanks guys ,

    Both the RCTIME and counter solutions work , as well as my temp get around.

    I was not aware of the RCTIME command ,thanks for that

    because the times being measured are so long at this point in the signal (IR input) , is not a big timing issue for how it is checked using the if command etc

    cheers

    Sheldon

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