Credit Card sized IR Remote control
mojorizing
Posts: 249
This project is an example of how one would add an IR remote control to a project. It uses a credit card sized remote control that can be sourced from Ebay for less than $5. The remote is made by Creative Labs and has a receiver that plugs into your PC serial port to enable remote control of your PC. Inside the receiver there is a 3 terminal IR module that has grnd,pwr,and signal output terminals, and can be removed from the PCB of the receiver. Below is a picture of the Creative Labs PC IR remote with receiver.
With the IR module on a protoboard and powered up with +5 vdc, the idle state of the output is +5 vdc.
This screen shot taken with an Oricom Pocket Oscilliscope in Serial Protocol mode shows what the serial stream looks like after pressing button #2. The IR module output is connected to LA7( nothing is connected to LA6) and is read from top to bottom, left to right. This screen shot shows a 9ms zero pulse to tune the AGC then a series of logic zero and one (+5 vdc) pulses that contains system address and command data. Over 40ms. of the serial stream is identical for all buttons. Using the Oricom Pocket Oscilloscope I noticed that the last 8 bits of each button press were different and I used this fact to distinguish between buttons on the remote. A logic level, be it zero or +5vdc, is 0.579 ms long followed by an idle state (+5vdc) of 0.55ms. Using this rule, button #2 gives a byte of 01010010.
A comparison of button #3 is below.
The last 8 bits of Button #3 are 10101000. Using the Pocket Oscilloscope I was able to determine the last byte of each button command.
To use this information in a project, it is will be necessary to sense the initial falling logic level when the IR module senses the remote control, then wait the required time (58.3 ms) and then sample the IR output every 1.2 ms for 8 times. This is best done using a timer in the ISR that is incremented using the RTCC.
Basically what happens is the SX is running in a loop named “snooze” with MIWU enabled on selected pins, in this example it’s rb.5 for the IR sensor module, but in addition it could be button pushes on a front panel, etc. When the initial IR pulse occurs, the SX enters the ISR , swaps the wkpnd_w with “Interrupt” which contains the source of the MIWU. The MIWU is disabled and from here until the interrupt is service, the SX is running with the RTCC interrupt enabled for every 10 microseconds. The timers for the particular source of interrupt are preloaded with the correct value and the SX leaves the ISR. , the GlobalInterrupt flag is set, and the SX leaves the ISR.
Now the SX calls routines sequentially that handle the source of the interrupt, in this case, the IR. Each routine is a state machine where the SX progresses thru each state as time goes on. This is important to realize and you’ll see that the IRRemoteinterrupt has only 2 states. Notice in the code after the label “IRRemoteinterrupt” how another interrupt source is handled, such as a front panel button debounce, The SX is running in RTCC mode and the initial interrupt would be the front panel button push but while the debounce timer is incrementing an IR pulse in received on rb.5. This pin (IR) is polled and it’s associated timers and flag is initialized at this time.
Anyway, as the IR timers increment the SX finally reads the state of rb.5 after the proper delay then delays further until 8 bits of the IR stream are read. The IR command is compare to set values and the code prceeds from there to respond correctly to the given IR remote. In the end the interuppt flags are cleared and the SX re-enters the MIWU mode.
I stripped this code from a project that I did using a SX52 with 3 sources of interrupts, this IR remote, a mechanical button, and 8 address lines of a SRAM where I needed to intercept the memory at certain addresses and take control. I hope the code is not too confusing, but I think the credit card size remote controller is great for projects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Post Edited (mojorizing) : 2/12/2006 5:59:21 AM GMT
With the IR module on a protoboard and powered up with +5 vdc, the idle state of the output is +5 vdc.
This screen shot taken with an Oricom Pocket Oscilliscope in Serial Protocol mode shows what the serial stream looks like after pressing button #2. The IR module output is connected to LA7( nothing is connected to LA6) and is read from top to bottom, left to right. This screen shot shows a 9ms zero pulse to tune the AGC then a series of logic zero and one (+5 vdc) pulses that contains system address and command data. Over 40ms. of the serial stream is identical for all buttons. Using the Oricom Pocket Oscilloscope I noticed that the last 8 bits of each button press were different and I used this fact to distinguish between buttons on the remote. A logic level, be it zero or +5vdc, is 0.579 ms long followed by an idle state (+5vdc) of 0.55ms. Using this rule, button #2 gives a byte of 01010010.
A comparison of button #3 is below.
The last 8 bits of Button #3 are 10101000. Using the Pocket Oscilloscope I was able to determine the last byte of each button command.
To use this information in a project, it is will be necessary to sense the initial falling logic level when the IR module senses the remote control, then wait the required time (58.3 ms) and then sample the IR output every 1.2 ms for 8 times. This is best done using a timer in the ISR that is incremented using the RTCC.
Basically what happens is the SX is running in a loop named “snooze” with MIWU enabled on selected pins, in this example it’s rb.5 for the IR sensor module, but in addition it could be button pushes on a front panel, etc. When the initial IR pulse occurs, the SX enters the ISR , swaps the wkpnd_w with “Interrupt” which contains the source of the MIWU. The MIWU is disabled and from here until the interrupt is service, the SX is running with the RTCC interrupt enabled for every 10 microseconds. The timers for the particular source of interrupt are preloaded with the correct value and the SX leaves the ISR. , the GlobalInterrupt flag is set, and the SX leaves the ISR.
Now the SX calls routines sequentially that handle the source of the interrupt, in this case, the IR. Each routine is a state machine where the SX progresses thru each state as time goes on. This is important to realize and you’ll see that the IRRemoteinterrupt has only 2 states. Notice in the code after the label “IRRemoteinterrupt” how another interrupt source is handled, such as a front panel button debounce, The SX is running in RTCC mode and the initial interrupt would be the front panel button push but while the debounce timer is incrementing an IR pulse in received on rb.5. This pin (IR) is polled and it’s associated timers and flag is initialized at this time.
Anyway, as the IR timers increment the SX finally reads the state of rb.5 after the proper delay then delays further until 8 bits of the IR stream are read. The IR command is compare to set values and the code prceeds from there to respond correctly to the given IR remote. In the end the interuppt flags are cleared and the SX re-enters the MIWU mode.
I stripped this code from a project that I did using a SX52 with 3 sources of interrupts, this IR remote, a mechanical button, and 8 address lines of a SRAM where I needed to intercept the memory at certain addresses and take control. I hope the code is not too confusing, but I think the credit card size remote controller is great for projects.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Post Edited (mojorizing) : 2/12/2006 5:59:21 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
·· I would recommend editing your post to remove the pasted code and instead attach it so that the screen doesn't have to be scrolled left/right so far to read the text.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
play, stop, pause, eject
previous, rewind, fast forward, next
1, 2, 3, shift
4, 5, 6, mouse
7, 8, 9, volume up
start, 0, mute, volume down
Also have you investigated the behaviour when a button is continued to be held down, does it repeat the entire transmission, or is there some sort of continuation command?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Post Edited (mojorizing) : 2/12/2006 6:13:00 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10