RC5 decode on a 10F + Question


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Yes, get rid of the MODEDEFS...
    Other tips that might help out...
    Use DEBUG instead of SEROUT
    Instead of inline code, grab the bits in a loop.
    Not sure if it'll save anything, you've got pauseus and pause. Maybe just use a big pauseus rather than both commands.
    Treat your Y variable as a word initially, then when you changing it up, treat it as 2 bytes, y.high and y.low. Might have to declare a couple of smaller bit variables (maybe scavenge a bit from a register from a module you're not using, like maybe a timer that's not running) while doing the bit swapping.
    This might be one of those 'codius minimus' projects...DT? Anyone else?

  2. #2
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Skimask,

    Thanks for your fast reply, will try the things you indicated.

    I also found that commenting out the RR1, RM1 and flag section in pbpPIC12.ram gives
    an extra 3 bytes !

    Thanks !

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I don't think I'd ever try PBP with a 10F ... just not enough room to spare.
    Much better to use ASM.

    Here's one from Bruce.

    PIC10F200 Automated IR Light Switch
    http://www.picbasic.co.uk/forum/showthread.php?t=3261

    Doesn't do what you want, but it shows what you can do with a 10F200 and ASM.
    <br>
    DT

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    ultiblade,

    I just compiled your code for a 10F202 with PBP 2.50, and it all fit's. No Errors.
    I did not change the .RAM file.

    Which version of PBP do you have?
    <br>
    DT

  5. #5
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I don't think I'd ever try PBP with a 10F ... just not enough room to spare.
    Much better to use ASM.

    Here's one from Bruce.

    PIC10F200 Automated IR Light Switch
    http://www.picbasic.co.uk/forum/showthread.php?t=3261

    Doesn't do what you want, but it shows what you can do with a 10F200 and ASM.
    <br>
    Amazing ! Missed that, i was only searching for 'RC5' examples ...
    Maybe coming wintertime will bring me a new hobby, learning Assembly !

    I'm using pbp2.47. Yesterday i made some code changes, but it still won't fit without
    the ram file change. I commented out only the FLAG parameter, that does the trick.

  6. #6
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Here's the code until now, works perfect with a RC5 remote. It now act's like a sort of a IR RC5 to binary encoder. Just press the number buttons 0 to 7 on the remote and the 3 IO outputs will be set accordingly ... (Just one minor thing, still remains : the FLAG section has to be commented out in the pbppic12.ram file, for me to be able to fit TMP as byte)

    Code:
    '==== Set fuses =====================================================
    @ device pic10F202,wdt_off,mclr_off,protect_off
    
    
    '==== Set XTAL =====================================================
    DEFINE OSC 4                                    ' int XTAL @ 4 Mhz
    
    '==== Set variables ==================================================
    Y VAR word                                      ' To Hold the 12-bit RC5 code
    TMP var BYTE
    
    '==== Set IO =======================================================    
    IR_PIN VAR GPIO.3                               ' GPIO.0 input pin reading IR data
    'SERIAL var GPIO.1                               ' GPIO.1 SEROUT 9600-8-n-1 output
    RES1 var GPIO.0                                  ' Binary 1
    RES2 var GPIO.1                                  ' Binary 2
    RES3 var GPIO.2                                  ' Binary 4
    
    OPTION_REG.7 = 0                                ' Internal pull-ups = on
    TRISIO = %00001000                             ' Set TRIS register input's & output's
    OPTION_REG.5 = 0                                ' Set Timer inc. on internal inst.
    GPIO   = %00000000                              ' Set all digital low
    
    '==== Signal information ===============================================
    'Given the information found on http://www.sbprojects.com/knowledge/ir/rc5.htm
    'bit      1    2    3    4    5    6    7    8    9   10   11   12   13   14
    '      |    |    |    |    |    |    |    |    |    |    |    |    |    |    |
    'uSec   1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778 1778
    
    '==== Main program ==================================================  
    MAIN:
    IF IR_PIN = 1 THEN GOTO MAIN                    ' Wait for the first bit to arive
    y.13 = IR_PIN                                    ' Incoming signal 
    pauseus 889                                     ' In order to se this 0 we are in the second 
                                                    ' period of the first 1.778 msec, so we will 
                                                    ' wait another 889 usec to enter the 2nd period.
    
    pauseus 1600                                    ' Almost at the end of the second period, look for
    y.12 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.11 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.10 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.9 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.8 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.7 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.6 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.5 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.4 = IR_pin                                    ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.3 = IR_pin                                   ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.2 = IR_pin                                   ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.1 = IR_pin                                   ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    pauseus 1600                                    ' Almost at the end of this period, look for
    y.0 = IR_pin                                   ' a high or low signal
    pauseus 178                                     ' Time to the end of this period
    
    y = ~y                                          ' Invert y word
    
    if Y.lowbyte = 255 then goto ERROR              ' If all lowbytes are 0xFF then noise is received 
    
    
    '==== Parse received values  =========================================
    TMP.1 = Y.13
    TMP.0 = Y.12
    if not tmp = 3 then goto error
    
    TMP.4 = Y.10
    TMP.3 = Y.9
    TMP.2 = Y.8
    TMP.1 = Y.7
    TMP.0 = Y.6
    if not tmp = 0 then goto error
    
    TMP.2 = Y.5
    TMP.1 = Y.4
    TMP.0 = Y.3
    if tmp > 0 then goto error
    
    TMP.2 = Y.2
    TMP.1 = Y.1
    TMP.0 = Y.0
    
    OPTION_REG.5 = 0                                ' Internal pull-ups = on
    res3 = tmp.2
    res2 = tmp.1
    res1 = tmp.0            
    
    '==== End of main loop reset and go from top ============================
    ERROR:                                        
    Y=0
    tmp=0                                       ' Clear key codes
    PAUSE 250                                   ' debounce
    GOTO MAIN                                   ' Return to main loop
    
    END
    And again: THANK YOU guys !

    Best Regards, UltiBlade

Similar Threads

  1. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  2. Switch Debounce using a 10F chip
    By modifyit in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st March 2006, 05:22
  3. IR decode problem "hitachi TV remote"
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th March 2006, 15:29
  4. Decode RC5 ?
    By charudatt in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd November 2005, 10:12
  5. RC5 Encode / Decode
    By charudatt in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th October 2003, 05:14

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