WhiteSpace
Well-known member
I wonder if someone could give me a pointer please. As mentioned on another thread, I've been changing my IROUT/IRIN remote control vehicle project to SEROUT/SERIN via infrared. I first tried HSEROUT/HSERIN and have switched to "ordinary" serial for various reasons. Serial via IR is working very well, actually rather faster than IRIN. I would like to check the time between bytes and the duration of each set of commands, in order to improve the handling at the receiver end.
I have a 28x2 creating a 33 kHz carrier wave on one pin, combined through a transistor AND gate with the SEROUT from another pin set as:
and sending via IR LED to the receiver unit. My understanding from manual 2, p.218 is that "N" mode is inverted, idle low, pulse high, so I would expect the LED to be lit for 1 and dark for 0. It all seems to be working fine - the bytes are being received at the other end (the IR sensor is active low, so the SERIN mode is set to to T2400_16).
However, while measuring the duration of a bit (seems to be about 380 microseconds) and the length of a byte (about 3.7 ms), I noticed that the bits appear the opposite way round to how I would expect - so what I take to be 1s are low and 0s are high.
Here are a couple of examples. I've been using PCB scope, and in fact this exercise has been quite useful, because I have really learned how to use it. I've run a number of bytes, chosen for their distinctive patterns in binary.
So here is the byte 126.
Channel 1 is the signal at the base of the transistor handling the carrier wave. Channel 2 is the signal at base of the transistor handling the serial.
126 in binary is 01111110. I think what the scope is showing is a start byte immediately followed by the "0" LSB (producing the double-length high on the left), then the 6 "1" bits, then the "0" MSB. But that doesn't correspond to what I understand is being sent from the Picaxe - I ought to be seeing the inverse of this: a low bit, six high bits, a low and then a stop bit.
Similarly 130 looks like this:
130 is 10000010, so I would expect a high bit at each end, with lows in between. Instead there is a double length high, presumably start bit, LSB, then a low for bit 1, then 5 high bits (which checks with the period between the cursors, roughly 5 x 390 microseconds), then low MSB.
What blindingly obvious point am I missing here, please? Thanks very much.
I have a 28x2 creating a 33 kHz carrier wave on one pin, combined through a transistor AND gate with the SEROUT from another pin set as:
Rich (BB code):
serout IRLED, N2400_16, (LeftSendByte);
However, while measuring the duration of a bit (seems to be about 380 microseconds) and the length of a byte (about 3.7 ms), I noticed that the bits appear the opposite way round to how I would expect - so what I take to be 1s are low and 0s are high.
Here are a couple of examples. I've been using PCB scope, and in fact this exercise has been quite useful, because I have really learned how to use it. I've run a number of bytes, chosen for their distinctive patterns in binary.
So here is the byte 126.
Channel 1 is the signal at the base of the transistor handling the carrier wave. Channel 2 is the signal at base of the transistor handling the serial.
126 in binary is 01111110. I think what the scope is showing is a start byte immediately followed by the "0" LSB (producing the double-length high on the left), then the 6 "1" bits, then the "0" MSB. But that doesn't correspond to what I understand is being sent from the Picaxe - I ought to be seeing the inverse of this: a low bit, six high bits, a low and then a stop bit.
Similarly 130 looks like this:
130 is 10000010, so I would expect a high bit at each end, with lows in between. Instead there is a double length high, presumably start bit, LSB, then a low for bit 1, then 5 high bits (which checks with the period between the cursors, roughly 5 x 390 microseconds), then low MSB.
What blindingly obvious point am I missing here, please? Thanks very much.