Decoding Serial from uController with Scope - How to determine Polarity? - Page 1
Forum section: electronics / beginners

author: K1JOS
author_rank: Regular Contributor
timestamp: August 15, 2014, 07:12:26 pm
content: I am getting two different decodes of a motor controller RS232 output. The data stream is 9600 BAUD, 8N1. The data packet is start bit, 5 bytes, stop bit. All done half-duplex with no hardware control.On my Agilent MSOX scope I decode I decode on the RS232 RX pin in HEX as:Code:0x02, 0x88, 0x01, 0x00, 0x04I also look simultaneously on a laptop terminal monitor as the signal inputs into an Arduino serial USART and it decodes as:Code:0x3F, 0x47, 0xE6, 0xEE, 0x00On the scope, I tried different polarity settings as well as changing the order of LSB and MSB but that just gave me RX decode errors.Any advice appreciated as to whats going on so I can figure out which decode is the "real' code.thanks

author: Maxlor
author_rank: Frequent Contributor
timestamp: August 15, 2014, 07:24:06 pm
content: It's hard to say exactly without seeing the signal, but I think you have two settings wrong on the Agilent. First, the MSB/LSB setting, and second, the polarity setting. Remember that RS232 uses negative voltage (so low) for logic 1, and 0V (so high) for logic 0. Even when inverting the bits and accounting for wrong MSB/LSB settings, the two decodes don't match up exactly; maybe the start/stop bits are being intepreted as data bits by the scope? Should result in invalid frames of course. How about a screenshot from the scope?

author: Bored@Work
author_rank: Super Contributor
timestamp: August 15, 2014, 07:48:37 pm
content: Look at the signal as such. Decode one character by hand. Check which of the two devices got it right, if any.

author: K1JOS
author_rank: Regular Contributor
timestamp: August 15, 2014, 08:22:01 pm
content: I assumed (incorrectly?) that the setup on the scope that gave me no errors was the correct one. Idle polarity high matches the decode I see on the laptop but the Agilent shows decode errors while if I set it up with idle polarity low there are no errors. I have attached pictures.To be clear, I am scoping a proprietary motor controller (can't get any tech info) that has a RS485 output. I took this and brought it to a MAX483 chip connected to the serial input of an Arduino. I figured the "correct" decode had to be at the output of the MAX483 before the Arduino did anything to it. How can I tell which is the correct USART format to decode coming out of the RS485 MAX483 chip?thanks to all for the help.

author: David Hess
author_rank: Super Contributor
timestamp: August 15, 2014, 08:36:19 pm
content: Quote from: K1JOS on August 15, 2014, 07:12:26 pmWhat?There is 1 start bit and 1 stop bit per character with 8N1.

author: Rufus
author_rank: Super Contributor
timestamp: August 15, 2014, 08:51:24 pm
content: Quote from: K1JOS on August 15, 2014, 08:22:01 pmThe RS485 lines are probably floating while the controller is not transmitting. The output of an RS485 receiver with floating inputs is likely random. If float produces a mark state between packets async receivers will consider it to be an error or break condition. It likely messes up reception of the first character of the packet as well.Pull one RS485 line up and the other down with a few k to get the receiver output to idle in the right state between packets.

author: K1JOS
author_rank: Regular Contributor
timestamp: August 15, 2014, 09:11:33 pm
content: OK, I bypassed the Arduino and the two MAX483 on both sides of the RS485 bus. I went directly to the serial out pin on the PIC18F in the motor controller.I find the identical decodes as in my initial post depending on whether the Agilent idle polarity is low or high. See attached pictures. How can I determine which is the correct code from the PIC?Many thanks in advance

author: Rufus
author_rank: Super Contributor
timestamp: August 15, 2014, 10:24:22 pm
content: Quote from: K1JOS on August 15, 2014, 09:11:33 pmThe one that isn't giving errors on the scope decode - 02 88 31 00 04. Async outputs from processors usually idle high to directly drive inverting RS232 buffers.02 is ASCII STX and 04 ASCII EOT which have a higher that average probability of being chosen as start and end of packet characters by whoever designed the protocol.

author: Maxlor
author_rank: Frequent Contributor
timestamp: August 15, 2014, 10:41:24 pm
content: I agree, the scope is more likely correct than the Arduino output. Maybe if you switch the Arduino to 9600-8-N-2, you'll get the same output.What I get when manually decoding it is 02 88 31 00 04 in MSB first (same as your scope) and 40 11 8C 00 20 in LSB first. Both seem random but plausible to me, you'll have to determine yourself which one makes more sense to you.

author: K1JOS
author_rank: Regular Contributor
timestamp: August 16, 2014, 03:01:50 am
content: Many thanks to all. I don't know where the inversion is taking place, but I will diagnose further.