2
\$\begingroup\$

I am using Saleae logic analyzer to reverse a console port. Saleae is able to successfully decode the signal (asynchronous serial) after performing an "invert" operation on the received signals.

I am trying to figure out how this transform(invert) works in order to write a custom program to interface with the console port. The protocol is asynchronous serial with a baud rate of 9600, one stop bit and no parity.

invert(0x35) = 0x4E ("N")
invert(0x17) = 0x65 ("e")
invert(0x11) = 0x74 ("t")

Is this a standard inversion algorithm for asynchronous serial communication? Am a beginner in this field and hence a bit confused.

\$\endgroup\$
  • 1
    \$\begingroup\$ But where is this 0x35 on the presented waveform? Please show the data and the corresponding waveform you are talking about. \$\endgroup\$ – Eugene Sh. Jan 15 '18 at 17:22
  • 1
    \$\begingroup\$ RS-232 line drivers and recievers invert the signal, so a "High" out of the UART becomes a "Low" (usually a negative voltage) on the RS-232 cable. \$\endgroup\$ – Peter Bennett Jan 15 '18 at 17:40
  • 1
    \$\begingroup\$ Looks like you are misinterpreting something. The datas on two sides of your = are unrelated as it seems. \$\endgroup\$ – Eugene Sh. Jan 15 '18 at 17:54
  • 1
    \$\begingroup\$ If the signal is RS-232 levels, any serial terminal emulator program should work with an RS-232->USB adaptor. If you are dealing with a UART signal directly (sometimes called "TTL RS-232"), you will need a TTL Serial-USB adaptor instead, which will not have the RS-232 level inversion. \$\endgroup\$ – Peter Bennett Jan 15 '18 at 18:20
  • 1
    \$\begingroup\$ But why do you think it is "inverted"? Are the docs telling so? Can you show them to us? \$\endgroup\$ – Eugene Sh. Jan 15 '18 at 18:49
3
\$\begingroup\$

The 'invert' function causes the protocol analyzer to interpret a logic '0' as logic '1' and vice versa. This may be necessary to decode a waveform which is 'inverted' relative to the 'normal' logic levels for that protocol.

RS232 specifies +3~15V for the Start bit and '0' data bits, and -3~15V for '1' data bits and the Stop bit(s). However when translated to and from TTL/CMOS logical levels the signal is usually inverted. In 'TTL serial' the Start bit is low and Stop bit is high, and data bits match positive TTL logic levels (ie. high level = '1', low level = '0').

The analyzer detects the start of a word by looking for the transition between Stop/idle and Start bit. The detected start point will vary depending on the signal polarity and data present, so an 'inverted' signal will show decoded words in different positions and there won't be any obvious relationship between the detected bits.

To transform the signal in your own custom program, all you have to do is interpret high level as logic '0' and low level as logic '1'. You will have to decode the signal yourself, by looking for the beginning of a Start bit (transition from '1' to '0') skipping 1.5 bit periods to read the level in the middle of each data bit, and finally checking for the Stop bit.

\$\endgroup\$
  • 1
    \$\begingroup\$ To amplify, what the asker may be missing is that you can't reliably fix this inversion in software after the receive path of a typical UART, because an inverted waveform isn't really valid. It might sometimes be detected as some other character consisting of some of the inverted bits, but the framing is wrong. The inversion has to be corrected before the serial stream is framed and decoded by the receiver. It can only really be fixed in software when the decoding of the pulses on the wire is done by the software, ie a "Software Serial" type of implementation without a hardware UART. \$\endgroup\$ – Chris Stratton Jan 15 '18 at 19:09
  • 1
    \$\begingroup\$ Yes, that's why I said "you will have to decode the signal yourself". Once it has passed through a Serial to USB adapter it's too late. I wrote my answer before the asker mentioned using a serial-USB adapter, and assumed (s)he was working on some kind of bit-banged interface with software decoding. \$\endgroup\$ – Bruce Abbott Jan 15 '18 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.