How to measure a differential signal with a mcu?

Thread Starter

Rocks45

Joined Jul 12, 2017
14
Hello iam having trouble coming up with how to go about measuring a differential voltage from a rs-485 transceiver using a mcu.What iam trying to accomplish is getting a "oscilloscope type" graphical view so they can see the signal,obviously the resolution and accuracy wont be great.I was reading around and thinking i can use a non-inverting op-amp for the negative signal then have two adc(+,-) pins with voltage dividers to step it down to Vcc?Iam completely lost and still new to this so any input is appreciated.Thanks
 

ebp

Joined Feb 8, 2018
2,332
RS-485, with proper receivers, will work with "common mode" voltage that is well beyond the supply rails of the receiver. The allowable common mode range is -7 V to +12 V. If you need to be able to look at that full range, the circuit is a little complex, but not too bad. About the only way I can see to do it with an ADC is to attenuate and offset the signals so that the allowable common mode range, with the differential signal imposed on it, does not exceed the input range of the ADC. It would be rare to have and RS-485 differential signal of greater than 5 V peak to peak, but even at that the total signal range becomes -9.5 V to + 14.5 V - a 24 V span. With an ADC with 5 V full scale, would need to use an attenuator with a gain of 5/24, and then offset the attenuated signal by just under +2V to get it within the range of 0 to +5 V. The minimum differential signal for RS-485 is only 200 mV, so after attenuation, that is down to just under 41 mV, or about 0.83% of full-scale for the ADC. That;s just over two counts for an 8 bit converter. For a demo system, you could impose limits that require less attenuation and assure large differential signal, while still showing recovery of a differential signal from common mode.

It's all doable, and if you sample at a rate of probably at least 20 times the bit rate, you can likely get a display that doesn't look too bad, provided the common mode signal frequency is low relative to the bit rate. The worst part will be the time skew. Ideally you would want to sample both sides of the pair simultaneously to avoid the skew. ADCs that let you do that are certainly available, but if you want to use one that is on a microcontroller you won't be able to for any micro I know anything about.

I don't have any schematic drawing tools on the computer I use to access AAC, but others will likely come along and offer some suggestions for circuitry.
 

Thread Starter

Rocks45

Joined Jul 12, 2017
14
Ok first thank you for the responses, i will look into both.Second should i have to worry about isolating the signal iam reading so iam not directly inline with the actual signal on the network?Thanks again
 

danadak

Joined Mar 10, 2018
4,057
The SAR method basically presents no significant load or alteration of the network.
Maybe a few pF max in C loading, thats all.

Regards, Dana.
 

ebp

Joined Feb 8, 2018
2,332
I thought I understood what you wanted to do, but I'm not sure.

  1. Do you want to digitize each side of the differential pair or just look at the difference between them? If the latter, do you want the "recovered digital" signal or the analog difference? It makes a very great difference to the circuitry depending on what you want to sample. There is no point in using an ADC for looking at the digital signal.
  2. Is this to be done on some sort of demo setup or and actual in-use RS-485 link?
  3. What is the highest bit rate you expect to sample?

If you want to look at an in-use RS-485 link, you are very unlikely to need isolation but you must be careful not to disturb the termination impedance of the cable. 485 is typically used with twisted pairs of around 100 to 110 ohms. It would probably be acceptable to have additional loading of at least 10 times that, but I'd suggest at least 20 times (2000 ohms or greater). This would prevent significant change in the signal for a normally-terminated line.

If you expect to look at even something like an unterminated pair with 2.5 V common-mode voltage (the "clean" case), you would still need to attenuate the signal to sample it with an ADC with 0 to 5 V input range. Lack of termination can result in signal voltages outside of the that range. To accommodate the common mode range that is allowable, you must attenuate and offset the signal or receive it with a proper differential amplifier (analog difference) or line receiver (digital only) prior to applying it to an ADC.
 
Top