We've had this ancient LED message signs made by Pro-Lite at work ever since I started. They were controlled by an equally ancient IBM PC that has since vanished along with the software and much hope of being able to use them again. There is a seemingly RS-232-ish port on the back with pins 2 and 7 wired which intuitively tells you, yes, serial! Pin 2 is TX which would be convenient because you wouldn't need a null modem cable to talk with it. But alas, I've tried many many ways and have come up empty.
The signs do also have remote controls. Clunky with a smooth surface membrane which proves to be frustrating at best. Besides, I'd like to the sign to display something useful, current and timely. Say, scrape some RSS feeds and display them.
So I figured that IR was going to be my best way in (at least at the moment). Plus, it's just fun.
Plus it gives me a project to use with the Arduino. The first step was to capture and decode the IR signals coming from the remote and translate that into code. I connected a Radio Shack 38Khz IR receiver to the Arduino and used the example sketch on the Arduino playground as a “scope” of sorts to record the pulses coming from the remote.
Analyze IR Remote
Waiting...
Bit stream detected!
0 0
284 0
284 1
6888 1
6888 0
7140 0
7140 1
8576 1
8576 0
8872 0
8872 1
10292 1
10292 0
10596 0
10596 1
15440 1
15440 0
15724 0
15724 1
17152 1
17152 0
17424 0
17424 1
22300 1
22300 0
22576 0
22576 1
....
It all comes down to timing. The left column is the time in microseconds and the right column is the state. If you use Excel and graph this, it looks like this.
This makes things a bit more clear as to what is going on but doesn't yet translate this into code at all. So, I next wrote a Perl script to parse through this output and produce something that was more useful. I compute the delta between each pulse to determine the pulse width in microseconds.
Pulse time: 6604 (1)
Pulse time: 296 (0)
Pulse time: 1440 (1)
Pulse time: 232 (0)
Pulse time: 1484 (1)
Pulse time: 244 (0)
Pulse time: 4880 (1)
Pulse time: 300 (0)
Pulse time: 1440 (1)
Pulse time: 280 (0)
Pulse time: 4840 (1)
Pulse time: 284 (0)
Pulse time: 3168 (1)
Pulse time: 280 (0)
Pulse time: 4844 (1)
Pulse time: 292 (0)
Pulse time: 3140 (1)
Pulse time: 272 (0)
Pulse time: 1468 (1)
Now you can see a pattern emerge. Most of the pulse widths cluster around five types. I've called them null, 0, 1, start, and repeat, based on their location in the bitstream and how the repeat in the bit stream. Also, since the Arduino IR receiver sketch has a resolution of 4 microseconds, there are going to be some discrepancies. So, I additionally calculate the average pulse widths within a certain amount of confidence.
Avg null pulse time: 282.732673267327 (101 samples)
Avg start pulse time: 6582.66666666667 (15 samples)
Avg zero pulse time: 1435.82978723404 (47 samples)
Avg one pulse time: 4171.59183673469 (49 samples)
Avg repeat pulse time: 54277.6 (5 samples)
So now I have most of the information needed to built an IR emitter. But first I needed to learn about IR modulation.