|
||||||||
|
||||||||
|
AAN102 Interfacing to an IR Module By Michael Simpson Ever wanted to control one of your projects remotely. How about data entry with out a keypad hookup? With a simple IR module and a bit of programming you can start collecting keystrokes with the best of them. I wont go into the theory behind infrared diodes or transistors nor will I get into distance detection. I will be concentrating on two particular modules. The Sharp GP1U58X and the Vishay TSOP1840. Both these modules operate at 40kHz and are well suited to our applications. There are a great number of remotes, and protocols to match but I will be writing about one in particular. The Sony protocol.
The Protocol Lets start by diving into the protocol. The IR module will output a pulse stream of bits with varying widths. The widths are defined as follows.
The world is not perfect and to compensate for various manufactures we have expanded the specification a bit as follows.
The actual protocol consist of a starting bit followed by 12 data bits. The data bits can be further broken down into command and device bits as shown.
These bits come with the least significant first and will be represented as the command byte and the device byte. We will get into this further when we look at the code. OK enough of this. The Athena has a built-in command that takes care of all the bits and bytes for you. All you have to do is connect the IR module and your ready. The Modules Lets look a little closer at the modules before we wire them up. The Vishay and sharp modules are interchangeable except for the pin out as shown here.
The Circuit Wire up the circuit as shown. You can use the Sharp or the Vishay module.
Schematic 1
The Athena has a command called irin this command returns both the cmd and device codes. If the device code is 0 the command has timed out. You can set the timeout by setting the register PULSEINTIMEOUT. The closer this register is to 255 the faster the timeout. Program (download it here)
The program is straight forward however there is an IRMODE register that will allow you to receive raw IR data from an Athena using the irout command in the same mode. However that's another application note. Parts List
|
Copyright © 2001 - 2007 Kronos Robotics