Author Topic: Decoding Serial from uController with Scope - How to determine Polarity?  (Read 4921 times)

0 Members and 1 Guest are viewing this topic.

Offline K1JOSTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
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: [Select]
0x02, 0x88, 0x01, 0x00, 0x04
I also look simultaneously on a laptop terminal monitor as the signal inputs into an Arduino serial USART and it decodes as:
Code: [Select]
0x3F, 0x47, 0xE6, 0xEE, 0x00
On 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
« Last Edit: August 15, 2014, 09:59:50 pm by K1JOS »
 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
Re: Decoding RS232 with Scope different Results than on PC
« Reply #1 on: August 15, 2014, 07:24:06 pm »
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?
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: Decoding RS232 with Scope different Results than on PC
« Reply #2 on: August 15, 2014, 07:48:37 pm »
Look at the signal as such. Decode one character by hand. Check which of the two devices got it right, if any.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline K1JOSTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Decoding RS232 with Scope different Results than on PC
« Reply #3 on: August 15, 2014, 08:22:01 pm »
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.
 
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16607
  • Country: us
  • DavidH
Re: Decoding RS232 with Scope different Results than on PC
« Reply #4 on: August 15, 2014, 08:36:19 pm »
I am getting  The data packet is start bit, 5 bytes, stop bit.

What?

There is 1 start bit and 1 stop bit per character with 8N1.
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Decoding RS232 with Scope different Results than on PC
« Reply #5 on: August 15, 2014, 08:51:24 pm »
I took this and brought it to a MAX483 chip connected to the serial input of an Arduino.

The 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.
« Last Edit: August 15, 2014, 08:55:03 pm by Rufus »
 

Offline K1JOSTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Re: Decoding RS232 with Scope different Results than on PC
« Reply #6 on: August 15, 2014, 09:11:33 pm »
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

 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Decoding RS232 with Scope different Results than on PC
« Reply #7 on: August 15, 2014, 10:24:22 pm »
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?

The 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.

 

Offline Maxlor

  • Frequent Contributor
  • **
  • Posts: 565
  • Country: ch
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.
 

Offline K1JOSTopic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: us
Many thanks to all.  I don't know where the inversion is taking place, but I will diagnose further.



 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf