Recording incoming logic signal duration, both edges - how to?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    964


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    I'm recording all kind of remotes like ones for TVs as well as garage-door openers, electric-shades and so on. My remote is ment to be really "universal", well at least I dream it will be so.

    As where most TV protocols work fine with my code, the other ones don't use "standard" protocols and that's the reason why I have to record both signal's state durations with, appearently, a little more precision.

    This is the "learning sequence" of the code I currently work on:
    Code:
    <html><head></head><body><!--StartFragment--><pre><code><font color="#000000">LEARN:
    <b>PULSIN </b>IRM_Out, 0, l_Bit[0]        <font color="#000080"><i>'get the first Low pulse
    </i></font><b>TOGGLE </b>C_Led                       <font color="#000080"><i>'indicate the &quot;waiting state&quot; to user
    </i></font><b>IF </b>l_Bit[0] = 0 <b>THEN </b>LEARN:        <font color="#000080"><i>'wait for the first pulse to start recording
    </i></font>C_Led = 1                          <font color="#000080"><i>'led is ON, learn has started
    </i></font><b>RCTIME </b>IRM_Out, 1, h_Bit[0]        <font color="#000080"><i>'get first High pulse from IR Module
    </i></font><b>FOR </b>Ctr_A = 1 <b>TO </b>(Max_Bit - 1)
       <b>RCTIME </b>IRM_Out, 0, l_Bit[Ctr_A] <font color="#000080"><i>'get Low pulse (1 to 38) from IR Module
       </i></font><b>RCTIME </b>IRM_Out, 1, h_Bit[Ctr_A] <font color="#000080"><i>'get High pulse (1 to 38) from IR Module
    </i></font><b>NEXT </b>Ctr_A
    <b>RCTIME </b>IRM_Out, 0, l_bit[Max_Bit]  <font color="#000080"><i>'get last Low pulse from IR Module
    </i></font><b>RCTIME </b>IRM_Out, 1, H_bit[Max_Bit]  <font color="#000080"><i>'get last High pulse from IR Module
    </i></font>C_Led = 0
    <b>END</b></code></pre><!--EndFragment--></body></html>
    Full code is in attached ZIP file.

    I'll try to adapt your code to my usage and see what I get. Thanks a lot for that.

    Bruce,

    I have only some 10F, 12F and 16F in my drawer

    Nevertheless, I'm going to grab the datasheet of this particular PIC and see what this function does. Something new to learn
    Attached Files Attached Files
    Roger

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Roger,

    My code is for RF so you'll need to change polarities. I'm checking for timeout during the initial pulse of each bit but am not recording the duration. It shouldn't take much modification.

    Is this a commercial project? If it's just a one-off for your own use, you might want to consider a ZX328n from ZBasic. At $10 (plus some supporting components), it comes with a bootloader preloaded. ZBasic (free compiler) has built-in functions (InputCapture and InputCaptureEx) that will do what you wish with 37.8nS resolution.

    However, I doubt you need better than 50µS resolution. Years ago I did what you're doing only instead of doing it in real-time, recorded codes as .WAV files using a soundcard and then decoded them afterwards. As I recall I was able to automatically handle all of the protocols I came across.

    You might also consider USB-UIRT which not only captures the codes (as Philips Pronto CCF files) but also measures the IR carrier frequency.

  3. #3
    Join Date
    Jan 2009
    Posts
    22


    Did you find this post helpful? Yes | No

    Default capture IR remote

    I've had some luck using the capture function of the CCP module.

    Set up an interrupt (or just poll the CCP1 flag) and alternate between setting CCP1CON=$04 and CCP1CON=$05 to capture TMR1 to CCPR1H:CCPR1L on falling and rising edges, respectively. As TMR1 runs, you can save as many transitions as memory allows. (You may be able to use just the highbyte, depending on the resolution you need.)

    To transmit the recorded signal, set up as compare mode CCP1CON=$0A and toggle the output on and off.

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    964


    Did you find this post helpful? Yes | No

    Default

    Thanks bruce.

    This is absolutely non-commercial. It is more about to see how "far" I can go using PICs. I will adapt your code; it is always worth a try

    gmglickman,

    Would you have some code snippet to share? I did something similar but didn't work well.

    BTW, I have already made some remotes for friends of mine; all remotes are working fine. You can see how one look like here http://home.citycable.ch/flotulopex/...I_Frames_e.htm
    Last edited by flotulopex; - 6th January 2010 at 08:58. Reason: spelling
    Roger

Similar Threads

  1. Replies: 24
    Last Post: - 1st December 2009, 09:01
  2. Decoding an incoming infrared signal: need advice
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2008, 17:28
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 21:36

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