Trying to decode IR Signal
Mag748
Posts: 269
Hello everyone.
I have been working on this project for about 2 weeks now and have discovered a lot, and I have a few questions. I have a device made by a company
called Interwrite called the PRS 'clicker' and it is an IR transmitter used in classrooms to answer questions. There are 12 buttons, and each button
corosponds to a letter/number 1 through 9 (A through I), 0(J) and a high and low confidence button. Also,
there are thousands of these all over the world and each one has its own unique ID that is transmitted allong with the chosen answer (so the teachers can
grade you). What I am trying to do is figure out the code these units transmit so I can alter the unique ID number to be whatever I want. Sneaky huh? So
this is what I've got so far:
I connected a simple Phototransistor to an osciliscope and recorded the transmission after pressing the 1A button (as if choosing the answer A, or 1).
Using my basic understanding of IR signals after reading everything I could on the forums, pdfs from the parallax website and the internet, I found
these characteristics.
First of all, there is a 8.880ms low before what seems to be the start bit. The start bit is a 4.360ms high. then the signal starts. Between each bit is a
0.680ms low (so all the actual bits are high). of the high bits there is a short one and a long one. the short is 0.500ms and the long is 1.560ms. I am asuming
these are the 0s and 1s respectively. (but for now that doesnt really matter
So this helped a little.
All together, the transmission is 56 bits long. So I tried to modify the Program Listing 1.4 included in the Weekend Special - IR LED & 40 kHz
Detector.PDF to accomedate this many bits, and to record pulses of state 1, rather than 0, as in the SONY protocol. So this did not work. I wish I could
include the entire modified version of the program but it is on my other laptop that has the serial port, and no way of getting the program to this fancy
laptop. anyway, i will show the main code that I am having trouble with.
I changed the IR_Pulse word array to a signle word, and then created a 56 bit long array called Message. so that would be Message VAR Bit(56)
I have to do this, because I dont have the ram to store all 56 pulse times. I thought that having the following statements after each pulsin would solve the
problem
process_ir_pulses:··'subroutine
x = 0
DO
·PULSIN IR_det_pin, active_high, IR_pulse
·IF IR_Pulse > 200 & IR_Pulse < 300 THEN Message(x) = 0
·IF IR_Pulse > 700 & IR_Pulse < 800 THEN Message(x) = 1
·IF IR_Pulse = 0 OR IR_Pulse > 5000 THEN EXIT
·x = x + 1
LOOP
DEBUG "Finished Processing IR Pulses. X = ", DEC x, CR
RETURN
Later the program DEBUGs the Message array from 0 to x
When this is run, I get the start pulse first, which is correctely about 2150 units. And then I get about 15 other units (1s and 0s) which do not match the
oscilliscope results. And X only ends up being 16. So theres a problem. Is the Basic stamp too slow to record all 56 bits in the ~87.8ms time frame the
message is being sent? If so, how come it works with the SONY protocol?
I commented out one of the IF statements to see if that sped the program up a bit, and it seemed to. X increased to 21 or something with one IF gone. With
2 gone, it went up to like 26 or something, dont remember. and then with all of them gone (I changed the do to a do while in order for it to end ever) x
reached 31.
So I am guessing that the Basic stamp is too slow for the project that I am trying to do. Is there any other way of doing this is with the basic stamp?
Thank you very much,
Marcus Garfunkel.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I have been working on this project for about 2 weeks now and have discovered a lot, and I have a few questions. I have a device made by a company
called Interwrite called the PRS 'clicker' and it is an IR transmitter used in classrooms to answer questions. There are 12 buttons, and each button
corosponds to a letter/number 1 through 9 (A through I), 0(J) and a high and low confidence button. Also,
there are thousands of these all over the world and each one has its own unique ID that is transmitted allong with the chosen answer (so the teachers can
grade you). What I am trying to do is figure out the code these units transmit so I can alter the unique ID number to be whatever I want. Sneaky huh? So
this is what I've got so far:
I connected a simple Phototransistor to an osciliscope and recorded the transmission after pressing the 1A button (as if choosing the answer A, or 1).
Using my basic understanding of IR signals after reading everything I could on the forums, pdfs from the parallax website and the internet, I found
these characteristics.
First of all, there is a 8.880ms low before what seems to be the start bit. The start bit is a 4.360ms high. then the signal starts. Between each bit is a
0.680ms low (so all the actual bits are high). of the high bits there is a short one and a long one. the short is 0.500ms and the long is 1.560ms. I am asuming
these are the 0s and 1s respectively. (but for now that doesnt really matter
So this helped a little.
All together, the transmission is 56 bits long. So I tried to modify the Program Listing 1.4 included in the Weekend Special - IR LED & 40 kHz
Detector.PDF to accomedate this many bits, and to record pulses of state 1, rather than 0, as in the SONY protocol. So this did not work. I wish I could
include the entire modified version of the program but it is on my other laptop that has the serial port, and no way of getting the program to this fancy
laptop. anyway, i will show the main code that I am having trouble with.
I changed the IR_Pulse word array to a signle word, and then created a 56 bit long array called Message. so that would be Message VAR Bit(56)
I have to do this, because I dont have the ram to store all 56 pulse times. I thought that having the following statements after each pulsin would solve the
problem
process_ir_pulses:··'subroutine
x = 0
DO
·PULSIN IR_det_pin, active_high, IR_pulse
·IF IR_Pulse > 200 & IR_Pulse < 300 THEN Message(x) = 0
·IF IR_Pulse > 700 & IR_Pulse < 800 THEN Message(x) = 1
·IF IR_Pulse = 0 OR IR_Pulse > 5000 THEN EXIT
·x = x + 1
LOOP
DEBUG "Finished Processing IR Pulses. X = ", DEC x, CR
RETURN
Later the program DEBUGs the Message array from 0 to x
When this is run, I get the start pulse first, which is correctely about 2150 units. And then I get about 15 other units (1s and 0s) which do not match the
oscilliscope results. And X only ends up being 16. So theres a problem. Is the Basic stamp too slow to record all 56 bits in the ~87.8ms time frame the
message is being sent? If so, how come it works with the SONY protocol?
I commented out one of the IF statements to see if that sped the program up a bit, and it seemed to. X increased to 21 or something with one IF gone. With
2 gone, it went up to like 26 or something, dont remember. and then with all of them gone (I changed the do to a do while in order for it to end ever) x
reached 31.
So I am guessing that the Basic stamp is too slow for the project that I am trying to do. Is there any other way of doing this is with the basic stamp?
Thank you very much,
Marcus Garfunkel.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
For starters, I would try extending and modifying the Get_Ir_Remote_Code subroutine in IrRemoteButtons.bs2.· It's in a zip file on the IR Remote for the Boe-Bot page, and the PDF book with an explanation of the program is also there.
·
Time VAR Word
counter VAR Word
·
DO
main:
IF IN9 = 1 THEN GOTO main
DEBUG CLS
PULSIN 9, 1, time
DEBUG DEC time, CR
RCTIME 9, 1, time
DEBUG DEC time, CR
RCTIME 9, 1, time
DEBUG DEC time, CR
RCTIME 9, 1, time
DEBUG DEC time, CR
·
…15 more RCTIME + DEBUG commands here…
·
RCTIME 9, 1, time
DEBUG DEC time, CR
LOOP
·
Using this program to look at the output of the creative RM-1500 (which came with my sound blaster NX) which I know has 32 bits in each message, AND it transmits those 32 bits twice, this is the output that I get:
·
2323
324
1
785
349
1
174
17472
1403
333
1
780
349
1
174
0
0
0
0
0
0
·
The first number I assume is the start bit of the first message so it is recieving that. While reading the pdf, I wasn’t sure why it it suggested switching to RCTIME rather than stick to PULSIN. Neither of them seem to work for me anyway.
·
As you can see from the output, is seems like it is taking the BS2 soooo long to read the pulses. I mean it can only read 15 of the 64 pulses the remote sends. Am I understanding this correctly? If anyone sees anything I am doing wrong, I would greatly appreciate the help.
·
Thank you very much,
Marcus
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
2310
793
793
239
781
20774
794
793
793
239
793
0
0
0
0
0
0
0
0
0
0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I suspect the high times you are referring to are the times the IR is being transmitted. During these times, the IR detector sends a low signal.
Replacing the IF...THEN statements with DEBUG commands will cause the code not to work. To understand why, (and correctly develop your application) it would be helpful to go through IR Remote for the Boe-Bot with a closer attention to detail. Chapter 1, Activity #1 to #3, and Chapter 2, Activity #1 to #3.
If the signals your IR receiver sends really are active-high, capturing them is a matter of adjusting the state arguments in the RCTIME commands. A state argument of 1 for a PULSIN command makes it measure the high time in a low-high-low signal. A State argument of zero in a PULSIN command makes it measure the low time in a high-low-high signal. A State argument of 1 in an RCTIME command makes it measure the time from the beginning of the command to the time the signal falls below the 1.4 V BASIC Stamp I/O pin threshold. A State argument of 0 in the RCTIME command measures the time from the beginning of the command to the time the signal rises above the 1.4 V threshold.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Marcus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am now at the stage of this progect in which I need to send a message to an IR reciever using an IRED. I know what the messages are that I have to send, but I am not sure·about the best way to do it. Because the message is 56 bits long, and there are no spaces between bytes, I can not use the SEROUT command. I also looked into using the pulsout command but did some quick calculations and determined that the time it takes the BS2 to read the bit it needs to send from ram and transmit it would take longer that the shortest pulslength of .5 ms. I also looked into getting a UART that I could give the information and the way it needs to be sent. Are there any UARTs that would be able to send a continous message without and pauses between bytes? If not is there any other way I could do this with the BS2?
Thank you very much,
Marcus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm not sure what you mean by "IRED", but if you mean the IrDA protocal, then you may want to look at the MAX-3100 Maxim chip which is a serial input UART capable of sending IrDA signals.
If IrDA is not what you're trying to do, you may be stuck with a LONG string of consecutive PULSEOUTs using a faster Stamp processor than the one you examined, or an SX processor. You can send a pulse of .8 uS using a BS-2SX or any of the other faster Stamps.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Thanks,
Marcus
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔