I've tried attaching a PNG showing the trace, but the forum is rejecting me with the following error:
The upload folder is full. Please try a smaller file and/or contact an administrator.
I've uploaded the PNG to imgur, I have no idea how long they maintain images for, so I'm sorry if the link is dead (mostly thinking if anyone stumbles upon this in a few years).
Here is the code that is running:
noInterrupts();
digitalWrite(Y, HIGH);
P = pulseIn(X, LOW, usLong);
digitalWrite(Y, LOW);
a = pulseIn(X, LOW, usLong);
digitalWrite(Y, HIGH);
b = pulseIn(X, LOW, usLong);
digitalWrite(Y, LOW);
c = pulseIn(X, LOW, usLong);
digitalWrite(Y, HIGH);
d = pulseIn(X, LOW, usLong);
digitalWrite(Y, LOW);
interrupts();
Taking a look at the plot, you can see the data line is held at 3V normally, to communicate you short it to ground. A short pulse is a 1, a long pulse is a 0. You can ignore the first set of pulses, where the RED trace is held LOW. That's me sending a "power on" command to the device. It responds with a short 40 uS pulse (the first time that RED goes HIGH). As you can see, pulseIn does not immediately return after the pulse ends (BLUE goes HIGH), instead it holds for approximately another 40 uS. This causes the next pulseIn command to misfire, missing the next short pulse, but catching the first long pulse. This pattern repeats, with pulseIn not resetting for about 50 uS, missing the second long pulse.
This is of concern to me because this code worked fine with an older Arduino board and Arduino 0018. As I've mentioned before, I'm updating some "back of the napkin" hardware to something a little more robust, which required some minor code modifications (essentially inverting inputs/outputs), but now the code is failing to run properly. The big differences I can think of are I'm using an Arduino MEGA2560 and Arduino 1.0, but I can't imagine this would result in worse performance.
I'm beginning to think the proper way to do this would be to hook up my data line to an interrupt and just use the timers to figure out pulse lengths, but that would require some hardware rework since the data line is not connected to an interrupt capable pin.