Difference between revisions of "Sparkfun: IR Receiver Breakout Board"
|Line 26:||Line 26:|
== '''Sending a Signal''' ==
== '''Sending a Signal''' ==
Revision as of 07:30, 4 October 2012
Overview: 0, In your Background section, give details on what the device is. What is it able to do? Show a picture of the device that shows what pins it has. In 'Sending a Signal', show a diagram with the IR emitter sending a signal to your device. Describe at a high level what you are doing, then go into the details of how you do it. Wiring: 0, Give a specific example of how to wire it. What pins go where? Which bone header are you using? P8, P9? Code: 1, Give step by step instructions so it's easy for someone else to reproduce it. git: 2 Demo: 0 Total: 3/10 Comments: More details are needed. I think someone else in the class would have trouble reproducing what you have done. It looks like your code transmits only. Have you had any luck with receiving on the bone? Generally functions aren't defined in .h files. Could you move the functions to a BoneHeader.c file and create
Carrier Frequency: 38kHz
The picture on the left shows the physical device. This IR Receiver receives an modulated IR signal and reacts accordingly. It has filters built in to eliminate interference from ambient light, and it will not react to just any IR signal sent to it. This device needs an IR signal that is modulated as a 38kHz square wave. When it receives a modulated IR signal, it outputs a low signal. Otherwise, it outputs a high signal.
Sending a Signal
The TSOP85338 operates with a carrier frequency of 38kHz. That is, when the IR sensor is receiving an IR signal that is being modulated at 38kHz it outputs a logic 0. Using the BeagleBone to send a message to the TSOP85338 can be done using one of its PWM outputs. To perform testing of these attributes, ehrpwm1:0 can be used. By setting the duty_freq to 38000 and duty_percent to 50, it is possible to toggle an IR LED which if received by the sensor will output a logic 0. If the TSOP85338 is not receiving this modulated IR signal, it outputs a logic 1.
Reading Using Interrupts and GPIO
Receiving a signal from the TSOP85338 can be done on the BeagleBone using its gpio pins. In order to do this, the bitrate must be known initially or measured somehow. Once the bitrate is known, you can write a program that waits until an interrupt is received on a particular gpio pin that triggers on "both" edges. Essentially this will wait for the output of the TSOP85338 to change states. After it triggers, you can read the data received at intervals that match the bitrate until the message is received. This can be done for a set number of bits or until a terminating sequence occurs (user defined). Ex) if transmitting 8-bit char values, you can wait for a \0 ascii character to know that the message has been received.
If working in C, poll.h has some nice tools that can be used to create your interrupts.
This is not the best method to read the sensor with as the Operating System can get in the way of reading exactly on time
using UART or the PRU (Programmable Real-Time Unit) would prove much more efficient.
Testing and Results
All measurements and tests were performed using a 5V source
To test the operation of this device, I wrote a test script for the BeagleBone that repeatedly transmits an ascii 'c' char to the IR Receiver. I used a bitrate of 1kHz to transmit. With an 8-bit char, that gives a character transmit rate of 125Hz. While that is not particularly fast this rate allowed for accurate testing of the rise time for this device, which as can be seen in the figure below was measured on an oscilloscope to be 225us. By the measured rise time value, the maximum bit rate is around 4.4kHz.
The code used to perform this testing is available on github.com. Use the following to download it.
The above figure is the measurement taken of the TSOP38553's rise time.
In the above figure, The input to the TSOP38553 is in the red box below. It is shifting a 'c' or 0b01100011. The top section in green is the output.
DataSheet & Schematic: TSOP85338 Page on Sparkfun.com
Consumer IR: Wikipedia page on CIR