Shop OBEX P1 Docs P2 Docs Learn Events
Magic IR — Parallax Forums

Magic IR

RagtopRagtop Posts: 406
edited 2010-11-01 09:47 in Propeller 1
I am trying to use Gadget Gangster's Magic IR to trigger the play button on my Bose, but I keep getting a different set of values each time.

It works when I use the demo program, but when I try to feed magicir.playcode(4,play,127) from an array in DAT where I entered the values from the code1 array variable, it is a no go.

And each time I re-run the demo program and hit the play button I get different values for code1 and code1len.

I modified the original program to output the values for code1 and code1len.
CON              
 _clkmode        = xtal1 + pll16x
 _xinfreq        = 5_000_000
 
OBJ
 magicir : "magicir_010"
 DEBUG   : "Parallax Serial Terminal"
VAR
LONG code1[128], code1len, i,x
PUB main
 magicir.storecode(0, @code1, @code1len)
 DEBUG.start(250000)
 waitcnt(clkfreq*8  + cnt)

 x:=1
 repeat i from 0 to code1len
     x++
     debug.dec(code1[i])
     debug.str(string(" "))
     if x == 11
        debug.str(string(13))
        debug.str(string("------------------------------------"))
        debug.str(string(13)) 
        x:=1
 debug.str(string(13))      
 debug.dec(code1len)     
 repeat
   'magiccir.playcode(4,play,127)
   magicir.playcode(4,@code1,@code1len)
   waitcnt(clkfreq*5 + cnt)

DAT
   Play   long 85958,200065,245599,359681,405554, 519313, 565188, 599137, 644670, 758433
          long 804301, 918385, 963916, 997857, 1043729, 1077665, 1123207, 1157153, 1202692, 1236641
          long 1282175, 1316113, 1361661, 1475761, 1521310, 1555265, 1600795, 1634737, 1680614, 1794369 
          long 1840238, 1954001, 1999870, 2113297, 2158834, 6188705, 6274315, 6388417, 6434295, 6548049 
          long 6593931, 6707697, 6753573, 6787521, 6833389, 6947137, 6993010, 7106769, 7152653, 7186593 
          long 7232141, 7266097, 7311625, 7345569, 7391111, 7425057, 7470942, 7504545, 7550428, 7664193 
          long 7710075, 7744017, 7789561, 7823505, 7869045, 7982817, 8028689, 8142785, 8188324, 8301745
          long 8347626, 12378289, 12464245, 12578353, 12624230, 12738001, 12783867, 12897617, 12943481, 12977761 
          long 13022973, 13137073, 13182957, 13296721, 13342603, 13376545, 13422085, 13456033, 13501575, 13535521 
          long 13581061, 13615009, 13660551, 13694833, 13740041, 13854145, 13900033, 13933985, 13979525, 14013473
          long 14059020, 14172785, 14218675, 14332449, 14378330, 14491425, 14537300, 18567169, 18652785, 18766897
          long 18812778, 18926545, 18972427, 19086209, 19132090, 19166385, 19211590, 19325697, 19371577, 19485345
          long 19531236, 19565185, 19610728, 19644673, 19690216, 19724497, 19769703, 19803985

Comments

  • Nick McClickNick McClick Posts: 1,003
    edited 2010-10-29 11:55
    You'll often get a different code length because the remote may repeat the command or part of the command.

    Timing values will change slightly, too.

    One thing that's odd is you have 127 transitions - although there's space for that many, the code shouldn't need 127 transitions.

    Try re-recording the IR command, but this time just quickly press the button. Is the transition count shorter?
  • RagtopRagtop Posts: 406
    edited 2010-10-29 12:25
    It is working after adding a variable in the DAT section for length.

    I rewrote the Parallax Serial Terminal output for an easier cut and paste.

    The unlimited power your code provides is intoxicating. Oh, the possibilities.
    CON              
     _clkmode        = xtal1 + pll16x
     _xinfreq        = 5_000_000
     
    OBJ
     magicir : "magicir_010"
     DEBUG   : "Parallax Serial Terminal"
    VAR
    LONG code1[128], code1len, i,x
    PUB main
    
    magicir.storecode(0, @code1, @code1len)
     DEBUG.start(250000)
     waitcnt(clkfreq*8  + cnt)
    
     x:=1
     debug.str(string("Code1len is ")) 
     debug.dec(code1len)
     debug.str(string(13))
     debug.str(string("DAT"))
     debug.str(string(13))
     debug.str(string("   Play      long "))
     repeat i from 0 to code1len
         x++
         if x == 10
            debug.dec(code1[i])
            debug.str(string(13))
            debug.str(string("             long ")) 
            x:=1
         else
            debug.dec(code1[i])
            debug.str(string(","))
     debug.str(string(13))     
    
     repeat
       'magicir.playcode(4,@play,@playlen)
       magicir.playcode(4,@code1,@code1len)
       waitcnt(clkfreq*5 + cnt)
    
    DAT
       Volup     long 85913,199949,245796,359837,405668,519373,565208,599133,644640
                 long 678893,724411,758333,803851,837773,883293,917213,963070,996989
                 long 1042509,1076445,1121951,1155869,1201382,1315405,1361250,1474941,1520782
                 long 1634813,1680656,1794349,1840196,1954205,2000058,2113069,2158917,6188605
                 long 6274514,6388525,6434381,6548077,6593917,6707949,6753788,6787709,6833231
                 long 6867165,6912672,6946941,6992447,7026381,7071887,7105821,7151325,7185245
                 long 7230763,7265021,7310540,7344461,7389979,7504013,7549859,7663549,7709401
                 long 7823437,7868945,7982989,8028832,8142525,8188371,8301725,8347565
    
    
       VPlen     long 70
    
       Play      long 85625,199733,245607,359381,405258,519029,564909,599189,644394
                 long 758501,804377,918149,964023,997973,1043509,1077461,1122995,1156949
                 long 1202482,1236773,1281970,1316245,1361453,1475557,1521431,1555381,1600928
                 long 1634869,1680419,1794197,1840071,1953845,1999716,2112805,2158685,6188325
                 long 6274284,6388373,6434254,6548005,6593876,6707637,6753518,6787797,6833010
                 long 6946789,6992659,7106421,7152298,7186581,7232118,7266069,7311605,7345557
                 long 7391100,7425045,7470589,7504869,7550068,7663829,7709712,7744005,7789202
                 long 7823477,7869027,7982805,8028675,8142437,8188314,8301413,8347283,12378245
                 long 12463869,12577957,12623836,12737589,12783800,12897573,12943442,12977397,13022931
                 long 13136693,13182567,13296341,13342214,13376165,13421695,13455973,13501179,13535461
                 long 13581002,13614949,13660481,13694421,13739962,13853733,13899605,13933557,13979095
                 long 14013381,14058578,14172341,14218553,14332325,14378202,14491301,14537170
    
       Playlen   long 106
    
  • Nick McClickNick McClick Posts: 1,003
    edited 2010-10-29 13:16
    Glad it's working - the lengths look much better there.
  • bdickensbdickens Posts: 110
    edited 2010-10-29 13:22
    We should get a propeller based universal remote with raymans screen, your IR and the propeller mod,
  • eod_punkeod_punk Posts: 146
    edited 2010-10-29 13:35
    I'm working my way to a universal remote slowly, I have a thread over at Savage Circuits about my remote project. Currently I'm buttoning up things on my Networked remote, but plan on adding a touch screen remote with some xbee's to my current setup.

    http://www.savagecircuits.com/forums/showthread.php?169-Networked-Universal-Remote
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-10-29 17:47
    What IR receiver are you using?
    The Panasonic PNA4601M uses a 36.7 kHz carrier frequency while the Vishay TSOP4838 uses 38kHz.

    Which frequency is used by most remotes?


  • bazibazi Posts: 29
    edited 2010-10-30 02:36
    It will work with a 38khz receiver, not as good as with a 36,... but it will work. The range and the angle will be smaller...
  • bdickensbdickens Posts: 110
    edited 2010-10-30 11:32
    For those of us without any background, what would be the best IR LED to use with the Vishay TSOP4838 ? I didn't even realize (although that should have been obvious) that they came in different frequencies.

    A mouser part # would be helpful if you happen to know.

    Thanks
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-10-30 15:04
    The TSOP is the receiver, isn't it? So, when you ask for an LED you mean the sender LED?! The sender does not come in versions with different frequencies. You simply let the propeller generate the needed frequency that matches with the receiver you have.
  • bill190bill190 Posts: 769
    edited 2010-10-30 20:14
    bdickens wrote: »
    For those of us without any background, what would be the best IR LED to use with the Vishay TSOP4838 ? I didn't even realize (although that should have been obvious) that they came in different frequencies.

    A mouser part # would be helpful if you happen to know.

    Thanks

    I just came across this page tonight. It has 3 different IR LED's. (Interesting)...
    http://www.rentron.com/remote_control/IRLED.htm

    Then see "The Transmitter" at the following link. This discusses IR LED's and so forth...
    http://www.sbprojects.com/knowledge/ir/ir.htm
  • bdickensbdickens Posts: 110
    edited 2010-11-01 06:13
    From the specs on these devices (and I know next to nothing about hardware) I assumed that while the prop generates the on/off but the code is being carried across a beam of infrared light. I was presuming that the TSOP4838 would react "cleaner" if the sending LED matched. But in hindsight, it has to react across a broad range of devices since I doubt each manufacturer used the same LED. And I'm not sending to myself ! So yes, stupid question.

    BILL190 - Thanks. That was very interesting reading !
  • RagtopRagtop Posts: 406
    edited 2010-11-01 09:30
    Currently wondering if maybe this code could be used to have two props communicate with each other......
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-11-01 09:47
    If you want to do standard serial comms over IR you're limited to about 2400 baud -- it's doable, though.

    This object:
    -- http://obex.parallax.com/objects/462/

    ... will let you transmit serial using an IR LED. The receive end is a standard IR receiver module.
Sign In or Register to comment.