Speech Controlled IR Remote

Introduction: Speech Controlled IR Remote


In this document I will explain the process on creating a Parallax Propeller controlled IR remote controller. This Instructable will explain one of several different ways this could be achieved  The device will be connected to a PC via the USB to serial connection.
The controller then can be controlled via an application on the PC that can connect and send information via serial connection. This instructable will also describe how the board can be controlled by a speech recognition application that is located on an Android phone. 

I am writing this Instructable in such a way to keep the complexity down, so beginners can easily understand and follow the process. This project can be expanded in several ways that will make the project more feasible to be used in everyday life. One possibly way is to replace the serial connection with a bluetooth module or a network interface card. This will remove the need to a PC, which in turn reduces the power requirements for the project.  

Equipment required:
P8X32A QuickStart (Parallax.com Item number: 40000)
A self made board using the Parallax Propeller chip.

38kHz Infrared (IR) Receiver Module (RadioShack Catalog #: 276-640)
High Output Infrared LED(RadioShack Catalog #: 276-143)

You can find my code for the project at the following link. https://github.com/michaelh123/IRRemote

If you want to build the board from individual parts, you can download the propeller software and follow the Propeller Education Kid Lasts-Fundamentals v1.2pdf on building the board. 

This Instrucatble is not meant to do in depth of how Infrared works, nor any of the protocols that are used, such as SIRC. This document is not a in depth programming Instructable as well. 

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: IR Receiver Circuit

The IR Receiver will allow us to read the IR codes. Once we have read and stored the codes we can transmit them at a later time.

We want to use an infrared receiver that looks for only a certain frequency and filters out the rest, such as  RadioShack Catalog #: 276-640. This particular Infrared receiver filters out any frequency that is not 38khz. This allows the micro controller to only worry about the time that the signal is on or off.

 We could use an phototransistor, that can sense the presence of IR light, but we would need a circuit that can filter any frequency out that we are not looking for. 

When an Infrared remote transmits a code the Infrared LED is turning on and off at a quick pace. For example the common frequency is 38khz, which results in the LED turning of and off at a 26 microsecond cycle time. 

The following circuit will be connected to pin 0 on the Propeller board. 

Step 2: IR Transmitter Circuit

The infrared LED is the device that we will use to transmit the IR codes. When replaying the code the output pin will modulate the signal at 38kHz or a 26 microsecond cycle time for the signal to transmit, with the correct on and off times for the code.

The circuit in the image will be attached to P1. The resistor may change depending on the LED IR that you have. Verify the specs and ensure that the resistor is big enough for your application. 

In this circuit you can remove the transistor(Q1) from the circuit. I am running the LED at 5 volts and the pin on the Propeller is 3.3 volts. I like to create a boundary between those two different voltages even tho you could use an resistor to protect the pin on the propeller. 

Step 3: IR Receive Code

The IR code we will be using will be a modified version of magic IR that can be found on obex.parallax.com object number 663 or url: http://obex.parallax.com/objects/663/.

The downloaded zip file contains three spin files: Synth.spin, magicir_010.spin and magic_ir_demo.spin.

Synth.spin contains the code to allow the Propeller to perform 38kHz cycles on Pin 1.
magicir_010.spin contains the code to read and transmit the IR code.
magicir_demo.spin  contains code to showcase how the library works.

We will be taking magicir_010.spin and adding two functions to it that will allow us to read and transmit IR codes. 

First we will need to add an Parallax Serial Terminal object to the magicir_010 code. This will only be used when you are wanting to receive codes. (Picture 1)

Next we will have to add a setup pub to initialize the serial terminal.. (Picture 2)

The next section that will be added will wait until a code has been received and will print it to the serial after a code has been received. The function will block out from continuing until an code has been received. If you want the code to continue executing other instructions while you wait for a code you will have to rewrite it.  (Picture 2) 

Step 4: Modifying Spin to Receive and Transmit on Demand.

We will be modifying the magic_ir_demo.spin file in this step. First we will add code that will allow us to read the code, then code will be added that will allow us to replay the code. 

Receiving Code
 The first to allow us to read code and see it in an serial terminal  we need to set up the serial terminal by calling magicir.setup. This will then return to the magic_ir_demo control and will allow us to continue, which we will then call magicir.storecode. This function sets up the pins and starts a new cog and returns. The next is playcodeFormat which blocks out until a code has been received then execution will continue. (Picture 1)

Once a code has been received the code will print out information on the serial terminal that you will want to copy and paste into your code. 
It will have several lines of em[number] := %number. You will want to copy all the lines including the length line. It will look similar to picture #2. 

Once you have this code create a new pub replicating the button name and paste it into the pub. Add "magicir.playcode(1,@em,@ length)" after the length line to transmit the code.

As you can see in pictures 3 and 4, there is an example of the button press number 1. 

Playing Code
 When we want to play a code, we will want to call a pub that puts the code in the correct parameters and calls magicir.playcode. An example is in picture 3 and 4.

In the main pub we start the serial terminal and reads information coming in from the serial terminal. Once a character has been received, the if loop will analyze the character and play the correct code. In picture 5 we have numbers 0 - 9 that we can control.

The codes are from a Comcast Silver Remote in the code from my Github. 

Step 5: C# Serial Communication

The C# application is what we will be hosting on the computer that the Propeller board is connected to. The application  has the capabilities for manual input or listen for a UDP connection. 

When the application loads, it gets a list of the serial port names on the PC and puts them in a drop down box. You will need to select the correct one. If you want to build on top of this, you could create an protocol for it to query each serial interface and determine which serial port is the correct one.) 

Number Pad
 If you are wanting to use the number pad instead of an Android device, this is a brief overview of how it works.  When a button is pressed will open the serial port, if it is not open already  Then it will send the number that was pressed to the serial device. This all happens within a few milliseconds. 

UDP Communication
When the listen button is pressed, a new thread is started and listens for UDP connections on port 11000. When data has been received it will analyze the data and make any modifications to it as needed. Once any modifications has been made it will send it to the Propeller board. 

Image two shows the function that gets called to send data to the serial port. It first 

Step 6: Android Voice Communication

Since this is not directly a programming Instructable for Android, I am going to briefly describe what the application does, how it does it and show some code. If there is a high demand for a full length  tutorial on creating the application from the beginning then I will create one. 

The application uses the TextToSpeech and recognizerIntent to recognize and play voice. 

There is an multidimensional  array at the top of MainActivity.java that is called Channels. This array is what allows you to tell the application what channel to change to. For example, you wanted to change the channel to CNN, you would say "Change channel to CNN" which would convert CNN to the appropriate channel and will send it to the UDP application. 

The quick rundown of the application is the following:

OnCreate sets up the TextToSpeech interface and assigns txt_ip and txt_port to the appropriate viewable controls. 

startVoiceRecognitionActivity starts the RecognizerIntent intent and asks for a result. When the activity is done it will return to the application calling the function onActivityResult. 

OnActivityResult gets ran when an intent passes control back with a result of a request. The code then looks to see what request it was and process the appropriate block of code. 

The code can be found at: https://github.com/michaelh123/IRRemote

Step 7: Finished Product -- Well Sort Of.

Now that you have a working prototype of an Android Controlled IR remote. I encourage you to expand your knowledge by adding features to this prototype. 

Here are some ideas:
 Remove the required computer and add a NIC card or Bluetooth module.
 Add a function that allows you to access codes dynamically, instead of statically.
 Add an SD Card to be able to add more codes dynamically. 
 Add a timing function to repeat codes at a regular basis. 

There are many things that this prototype can be transformed into. I made this very very basic Instructable to give you an idea on how to make an IR remote using a Propeller chip. 

This was my first Instructable, hope it wasn't that terrible. 

Have fun!

Be the First to Share


    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Clocks Contest

      Clocks Contest



    5 years ago

    Best example of using magicir propeller object I've seen. Helped a lot with the universal remote control feature of my robot.