Universal IR Decoding

Greetings!

I am new to Parallax and the Propeller but A friend recommended it for a project I am building. It is very similar to the remote controlled LED strips you can buy anywhere nowadays. Small 24 button remote to control colors and behaviors of RGB LEDs. Based on what I see I believe the propeller can handle the logic needed to control the LEDs I have. However, in all my searches I cannot find much relevant and recent information about modules to do the IR decoding of a remote. Yes, I found something for a sony remote. But, I will be using a random remote from some unknown manufacturer. I have the ability to read and decode the IR codes on my Raspberry Pi, so I know the code for each button, but I need to know if this propeller has easy to use module for this. I normally program in Python but I suppose i'd be learning Spin for this project.

Thanks in advance for your help!
Sean

Comments

  • You might want to take a trip over to the Object Exchange at: http://obex.parallax.com.

    Would something like this work for you? http://obex.parallax.com/object/290

    A search on “IR” in the OBEX brings up several possibilities.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,521
    edited 2019-09-14 - 21:45:42
    Welcome to the forum, Sean!

    First, are you sure it's an IR remote? I have two remotely-controlled LED systems, and both remotes use RF, not IR.

    -Phil
  • @JRoark - I'll take a look. I have no idea if that would work for me. How would one know unless they experiment? Perhaps someone else has experience with it?

    @Phil Pilgrim (PhiPi) - Thanks!! I'm always happy to find a healthy community of people willing to help. Yes, I am planning to use IR. The LED strip I have at home uses IR. Though I am aware an RF version also exists.
  • I don't know if the generic IR remote you have uses a 38kHz protocol. But if it does there is a simple C propeller tutorial that decodes a button press on the remote and shows the value. It is located at:
    learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/ir-receiver-and-remote

    Hope this helps,
    Tom
  • MJBMJB Posts: 1,139
    edited 2019-09-15 - 12:51:42
    When I just started with the Propeller Peter Jakacki just had started with Tachyon Forth and so Tachyon was my first programming language for me on the Propeller.
    Just to say - you don't have to learn SPIN first ...
    And I had never seen Forth before ... but now it is my Propeller language of choice.

    so here a link to a post by Peter, where he uses Tachyon for IR-Control.
    There is code to read IR-remote command codes, and code to send IR-commands as well.

    https://forums.parallax.com/discussion/145300/steering-wheel-interface-to-infrared-remote-control

    and you can do it just from the command line to experiment with your LEDs

    EDIT:

    so just load a current Tachyon image with PropTool into your Prop.
    then paste:
    ( *** INFRARED RECEPTION *** )
    
    
    \ Not really required but easy enough to add and useful for sampling RC codes.
    
    \ Use an IR receiver (TSOP1128) to sample codes using the -1 method
    
    
    #P16 |< CONSTANT =rxinp
    
    
    pub IRRX
    
            BEGIN
    
              =rxinp WAITPNE        \ wait for low
    
              =rxinp WAITPEQ        \ wait for high
    
              =rxinp WAITPNE        \ wait for low
    
              CNT@ =rxinp WAITPEQ CNT@ SWAP -        \ synch period
    
                0 BL FOR                                         \  measure high skip low
    
                2*
    
                 CNT@ =rxinp WAITPNE CNT@ SWAP - 3RD / 1 > 1 AND +
    
                =rxinp WAITPEQ                                \ skip low, wait for high
    
                NEXT
    
              CR .LONG NIP
    
                #200 ms
    
              KEY? AND
    
             UNTIL
    
            ;
    
    
    then type at the prompt
    IRRX
    
    then press your IR buttons ...
  • Peter JakackiPeter Jakacki Posts: 8,854
    edited 2019-09-15 - 13:08:42
    @MJB - I'd forgotten that I had already done some IR decode although I do have an IR transmit routine as part of Tachyon. I've updated the decode part and also include the transmit routine. Altogether they take 128 bytes of code.
    pub IRTX ( code pin -- )
    	DUP APIN LOW
    	38 KHZ 9 ms MUTE 4500 us
    	32 FOR 1 ROL 38 KHZ 450 us MUTE 450 us DUP 1 AND IF 450 us THEN NEXT DROP
    	9 ms
    	;
    
    pub IRRX ( pin -- code )
    	MASK 4 COG!
    ---	wait and synch
            WAITLO WAITHI WAITLO
    	 --- synch period timing as reference
            WAITHI 2 COG@ 1 COG@ -
            0 32 FOR
    	--- next bit timing
              2* WAITLO 2 COG@ 1 COG@ -
    	--- calulate timing as a 1 or 0 using synch ref 
    	  3RD / 1 > 1 AND +
              WAITHI
            NEXT
            NIP
            ;
    

    The best way to run the decoder is to leave it running in it's own cog and updating a global variable.
  • MJBMJB Posts: 1,139
    SeanWM wrote: »
    Greetings!

    ... remote controlled LED strips you can buy anywhere nowadays....
    Sean

    if you are using WS2812 RGB LEDs there is code in Tachyon to play with them from the command line.
    I was having a lot of fun doing it quite some time ago.
    And will be again some time in dark winter ...

    But of course other LEDs can be handled easily as well.

    If you tell a bit more what you want to do
    there might be more concrete examples for you.


  • Beau SchwabeBeau Schwabe Posts: 6,417
    edited 2019-09-15 - 19:06:27
    This might help .... "... I put together as more of a debug, but it contains the right building blocks to be a fully functional Universal 'learning' IR transmitter/receiver."

    https://forums.parallax.com/discussion/141601/getting-started-with-ir-specificaly-controlling-tvs#Comment_1114843

    Tested Remotes:
    BIONAIRE             - Wireless floor heater
    PANASONIC            - TV/VCR                
    RCA Generic          - UNIVERSAL             
    Phillips             - DVD/VCR Player        
    JVC  (RM-V715U)      - VIDEO camera         
    SONY (RMT-V154A)     - TV/VCR                
    SONY (RM-736)        - TV/VCR                
    SONY (RM-D190)       - CD PLAYER             
    Technics (SH-R808)   - Radio/Tape/Turntable  
    Chrysler Auto Remote - Rear Seat DVD remote 
    Generic DVD          - DVD Video / TV       
    iLive (IBCD2817DP)   - Radio/CD player      
    Credit Card Remote   - Generic 008                                          
    Polariod (RC-6007)   - Camera    
    
  • @twm47099 Yeah! I found that one too. Only thing is, it seems like it is only for Sony protocol. Any idea if it can be adapted for other protocols?

    @MJB Can you tell me more about Peter Jakacki and Tachyon Forth? What are they relative to Spin? Feels like drinking through a fire hose at the moment lol. Python is the language I've been learning. It seems the propeller can use a number of different languages and I am not sure which is best for me. Thanks for sending those resources!

    More info about the project, I am using through hole 5mm RGB LEDs that will be assembled in a cluster on a PCB. I am currently using an Adafruit Trinket m0 to control 4 channels of PWM (4th separately being used for thru hole UV LEDs). A 5th channel has a IR sensor which is currently decoded using Adafruit decoder. So the programming in circuitpython I had to do to get the IR running was minimal. I have this project up and running with the exception of one major part; I can use the remote to change from red to blue to green to whatever color I want. But the moment I enter a routine that fades up and down through different colors I cannot actually exit the routine with the remote. I have to disconnect power. My friend felt that this could be easily resolved with the propeller chip, which totally makes sense having the IR code running on one core while the LEDs are controlled by the other cores.

    1) I really want to resolve this issue in the Trinket since I am just steps away from finishing my prototype. Starting over with the propeller would be a real setback. If you know of any resources that will help me restructure the circuitpython program so that the IR code continues to run and can interrupt a routine that would be incredible. Please and thank you!

    2) The more I read about the propeller the more I want to learn about it. I love the idea of having 8 independent cores. I am just not sure which language to use to start playing with propeller. I am a Mechanical Engineer, not Electrical or Computer Science, so I am starting from the beginning so to speak. Which language do you recommend starting with? I noticed Parallax seems to be centered around education so I assume there are some resources there. Any insight could be helpful.

    Thanks again.

    Sean
  • Peter JakackiPeter Jakacki Posts: 8,854
    edited 2019-09-15 - 22:39:37
    @SeanWM
    Welcome to the Parallax forum. Your friend is is indeed a friend, having recommended the Propeller chip.
    Since MJB mentioned using Tachyon I can only say that he must be a friend of yours too :)

    Coming from a Python background you may like the interactiveness of the Tachyon console since Tachyon runs on the Propeller itself. What you want to do is trivial in Tachyon and you can interact and have fun doing it and improving it.

    I can recommend using WS2812 RGB chips since they are so easy to daisy chain and control from the Prop. However you can use individual RGB LEDs and Tachyon has a built-in 32 channel PWM that makes it very easy to implement this approach too.

    BTW, Tachyon is a custom implementation of the Forth "language" specially designed for the unique architecture of the Propeller chip but anyone who uses Forth professionally knows that Forth is not a "language", it is a whole interactive O/S like environment that runs on the embedded target where instead of writing code that generates a binary download blob, you write code that grows the language. Once you teach it to walk you can use that language to teach it to run, and then jump etc. In your case there is a mature and very extensive foundation to work with making it easier to build an application.

    You can start making things happen almost immediately by blinking an LED, for example an LED on P5 you could type "5 BLINK" at the serial terminal and it would start blinking immediately. Then type "10 HZ" and it will blink faster. Now type "20 5 DAC" instead and it will be steady but dim, while "100 5 DAC" will brighten it up more etc. Now "A 5 BLINK B 20 5 DAC" will have it blinking dimly. Easy as that!

    But Tachyon is designed for commercial products so while you can play with it, it is not a toy. To turn that simple demo into an autostarting "app" just type this:
    pub DEMO    2 RUN: A 5 BLINK B 20 5 DAC ;
    AUTORUN DEMO
    BACKUP
    
    Next time it starts up again it will run that in the background while you can still interact with Tachyon. (I have even made it run in its own cog though in this case it is not necessary)

    Some have "played" with Forth, but Tachyon as mentioned is much more than Forth and it is not a toy. It is a serious development tool and environment, IF you are serious.

    EDIT: I've attached my latest V5.6 "nightly build" binary you can load in and start talking to the Prop immediately using a serial terminal set for 115200 baud. This binary also includes much much more such as a FAT32 SD file system etc.
    V5.6.png
    890 x 749 - 37K
  • MJBMJB Posts: 1,139
    SeanWM wrote: »
    Which language do you recommend starting with?
    Sean

    let's say you want to cook s.th. nice ...
    you ask people what they would recommend
    you go to the bakery ... they recommend a nice cake
    you go to the butcher and end up with a steak
    the farmer market will recommend lot's of vegetables

    ... you see what I mean

    if you ask me I would take Tachyon-Forth - a bit of a learning curve - (was for me too) but so rewarding - especially since you can just play interactively which
    I haven't seen (to such an extend) in any other language/operating-system around on the Propeller.
    And the Propeller2 has Tachyon/Taqoz in ROM

    but I am sure others will have THEIR personal recommendations ;-)

    AND - if you have not done it yet -
    have a look at those WS2812 RGB LEDs
    they do their own dimming - no need for PWM ...




  • MJBMJB Posts: 1,139
    SeanWM wrote: »
    @MJB Can you tell me more about Peter Jakacki and Tachyon Forth? What are they relative to Spin?
    Sean

    have a look at the Tachyon threads and up there in Peter's post
    click the links in the footer for lot's of examples, code, documentation

    Forth is like the old HP-Calculators which had/have no "=" key
    ... if you know what I mean ;-)

    and @Peter Jakacki is a wizard in hard- and software from downunder
    Around here in the forums - since the beginning ? -
    Just search for his posts ...

    Peter Jakacki
    Username Peter Jakacki
    Joined 2006-09-11 - 11:46:09
    Visits 12,818
    Last Active 2019-09-16 - 00:25:49
    Posts 8,579
  • @Peter Jakacki
    Thanks for your detailed description. Tachyon sounds interesting but where do I start? Where can I find some basic information about it. Google only returned a few other threads in the Parallax forum. Not much documentation.

    Are you able to tell me if I can use Blocky to create the code I desire? It looks pretty straightforward. Or maybe Spin? I don't want to bite off more than I can chew learning a new complex language and stalling my project. I found Spin code online that controls LED and it's something I could adapt. I'm just not sure if Blocky or Spin have a module I can use to decode any IR remote. I'd like to be able to control 4 channels of PWM and a 5th channel of an IR receiver that can continuously update the LED colors, brightness, and routines. I am using specific LEDs because they are brighter and have a specific viewing angle that is useful for my project. Thanks for bringing your expertise!

    @MJB I gotcha. I've already gotten a few opinions (from other forums as well) and it has become difficult to reconcile them and find the best solution for my project... and future projects. Can you tell me which resources you used to learn Tachyon?
  • MJBMJB Posts: 1,139
    edited 2019-09-16 - 08:49:45
    Peter and the forum got me again.
    While I write he writes too and is faster ...
    SeanWM wrote: »
    @Peter Jakacki
    Thanks for your detailed description. Tachyon sounds interesting but where do I start? Where can I find some basic information about it. Google only returned a few other threads in the Parallax forum. Not much documentation.
    @MJB I gotcha. Can you tell me which resources you used to learn Tachyon?

    start with the signature of Peter's message above.
    Links to lot's of useful information.
    Take the PropellerTool, load in Peters binary image of Tachyon
    and start playing immediately
    with the little snippets he gave you above
    5 BLINK <enter>
    on the serial console
    Are you able to tell me if I can use Blocky to create the code I desire?
    It looks pretty straightforward. Or maybe Spin?
    don't ask the baker for a good steak ;-)
    I don't want to bite off more than I can chew learning a
    new complex language and stalling my project.
    sure it will be a new language and environment and give some delay to your project.
    But it is not a COMPLEX LANGUAGE
    It is not like programming in the traditional style - it is TALKING to the propeller.
    And it does immediately what you tell it. And if this is NOT what you want tell it s.th. different.
    I found Spin code online that controls LED and it's something I could adapt. I'm just not sure if Blocky or Spin have a module I can use to decode any IR remote. I'd like to be able to control 4 channels of PWM and a 5th channel of an IR receiver that can continuously update the LED colors, brightness, and routines. I am using specific LEDs because they are brighter and have a specific viewing angle that is useful for my project. Thanks for bringing your expertise!

    in Tachyon basically all is there that you will need.
    As Peter said this is a TRIVIAL task to do in Tachyon.
    I bet in less than an hour he would have it running.

    We can help you step by step.
    Just give it a try.
    You will never regret it
    decode any IR remote.
    is a very big step - let's start small and just get your one IR remote running first ...
    or even take a standard one if yours is a very exotic one.


  • I have no idea whether blocky can do what you want, but I know Tachyon can. As for "complex" i wouldn't think that those few snippets of code were complex. Seeing that the IR decode and PWM are built into Tachyon you can think of those functions like any other library function. In the case of Tachyon though, you can interact with them. That cuts down the head scratching by finding out if it is so. What you thought was complex therefore becomes simple. Learn by interaction and incrementally build your app.
  • MJBMJB Posts: 1,139
    SeanWM wrote: »
    ...
    I sent you a PM

  • SeanWMSeanWM Posts: 5
    edited 2019-09-16 - 15:55:49
    @Peter Jakacki My comments of complexity were based on some assumptions. The code you showed looks quite simple. I'll give Tachyon a try! You can expect to hear from me lol.

    @MJB Lol, all very valid points. Just trying to size up a bunch of things I know nothing about. I understand your points. Thanks for taking the time to reply. BTW, when I said any IR remote I meant 1 random remote that I want to use. I found one of the Parallax IR resources seems to only be useful for Sony code.
  • I wrote a Philips RC-5 decoder several years ago; it's attached in the even you find it useful. SIRCS is easy to decode so it's very popular -- I wrote the code for a Propeller-powered laser tag controller that uses Sony IR bit encoding (legacy issue); SIRCS is useful, but other protocols are easy to deal with, too.

    Have a look at this site:
    -- https://www.sbprojects.net/knowledge/ir/index.php
    Click on the hamburger menu in the upper right for different IR protocols.
  • Peter JakackiPeter Jakacki Posts: 8,854
    edited 2019-09-17 - 03:38:30
    Don't forget you can use Tachyon as a hardware/software debugging tool with quick "one-liners" that can graph the state of the IR input displaying a timing diagram of sorts. Better still is use the timing analyzer SPLAT written in Tachyon code that allows you to view multiple channels and change settings using just your serial terminal. I forgot about this tool and I will include it in a binary and append it to this post shortly.

    Here's some demo code that creates 8 channels of PWM from P16 , and sets them up with different duty cycles.
    256 longs pwmtbl
    : DEMO
    	%11111111_00000000_00000000 pwmtbl 7600 PWM.START
     	#P16 FROM 8 FOR I 14 - 20 * I PWM NEXT
    	;
    
    Now type DEMO and then run SPLAT (or S for shortcut).
    SPLAT.png
    1276 x 799 - 22K
  • is SPLAT by any chance in the P2 ROM? Is there something I could paste into a ROM TAQOZ to get this?

    Quite interesting and a very nice name...

    This looks really nice.

    Mike
  • Peter JakackiPeter Jakacki Posts: 8,854
    edited 2019-09-17 - 03:44:29
    msrobots wrote: »
    is SPLAT by any chance in the P2 ROM? Is there something I could paste into a ROM TAQOZ to get this?

    Quite interesting and a very nice name...

    This looks really nice.

    Mike

    The ROM is way too small for almost anything except TAQOZ, but still a cut down version. BTW, a full blown standalone verison of TAQOZ would well and truly fit in 32k though, what a pity.
    I've had SPLAT out for many years and it works even better at 2M baud serial but I will adapt it for P2 with a much larger buffer and faster capture speeds too. Time to upgrade SPLAT but on the P2 it could also run in 1080p on the monitor
  • Sean
    SeanWM wrote: »
    @Peter Jakacki
    Thanks for your detailed description. Tachyon sounds interesting ...

    @MJB I gotcha. I've already gotten a few opinions (from other forums as well) and it has become difficult to reconcile them and find the best solution for my project... and future projects. Can you tell me which resources you used to learn Tachyon?

    Sorry it took me so long to respond. Here is a link I use as a FORTH reference: https://www.forth.com/starting-forth. Combine that with the Glossary in Peter’s sig and as Peter recommended to me use the source code from EXTEND and you have some good tools for learning FORTH.
    JIm
Sign In or Register to comment.