6
\$\begingroup\$

I'm trying to implement RS485 link between mcu and pc. I'm using MAX485 for testing my setup.

Question: I can not receive bytes if I use termination resistor. Why? How to solve this?

History:

If I place a termination resistor (120 ohm), it is obvious that A-B pins are no longer high impedance. According to the datasheet, if A-B pins are not in high impedance, MAX485 ic's RO (Readout) is low while listening. If data line is low right before transmission starts, this sequence is not accepted as a valid sequence. That's why I can not receive any bytes if I use termination resistor.

I solved this problem by removing termination resistor. This put the MAX485 IC's A-B pins into a high impedance state, which turns RO pin (Pin #1, the TX pin of this IC) into high state while listening. Since the TX pin of this IC is high right before transmission starts, I can communicate as intended. But I know I will need to use termination resistor.

What is wrong with this setup?

Circuit Behaviour:

  1. On the PC terminal screen, a key is pressed
  2. The USB/RS232 converter generates a sequence from its TX pin.
  3. STM32F407 receives this character, and simply echoes it via its TX pin.
  4. MAX485 ic receives this character, converts it a differential signal.
  5. Other MAX485 ic gets this differential signal and converts to the character.
  6. USB/RS232 converter gets this character via its RX pin.
  7. Received character is shown in the PC terminal screen.

Test case: Setup is correct if you can see pressed character in the terminal screen on the pc.

(I know I mixed the TTL levels and CMOS levels since I don't have appropriate IC's right now. Conversions made by resistors.)

This is my test circuit:

Problematic circuit

This is the truth table of MAX485:

Truth table of MAX485

\$\endgroup\$
8
  • \$\begingroup\$ Have you attached a scope to see what you get at each stage? (I can't tell whether your function table is what you expect, or what you've actually measured. If it's what you've measured, then is that with or without resistors?). For what it's worth, Maxim's spec sheet shows differential voltages of around +/- 0.8V with 120 ohm terminating resistors (and 4000 ft of cable). What voltage are you running the MAX485's from? \$\endgroup\$
    – gwideman
    Mar 21, 2014 at 8:57
  • \$\begingroup\$ Have you measured your termination resistors, to be sure they really are 120 ohm, and not 1.2 ohm, or some other goofy mistake? Without term resistors, is the data you receive on the PC the correct data, or just some data? What do you mean by "Max485 IC's RO pin (TX pin)". Which 485? and which pin? \$\endgroup\$
    – gwideman
    Mar 21, 2014 at 8:58
  • \$\begingroup\$ The truth table is from Max485's datasheet. Yes, I have attached a scope. I am seeing what I expect. I used 330 ohm, measured with a ohmmeter. It also breaks the communication. A 22K only disturbs the line, neither allows, nor breaks. But the twisted pair cable is hand made (for testing purposes), does it matter? Without term resistors, I get correct data. I mean pin number 1 by "Max485's RO pin (TX pin)". \$\endgroup\$
    – ceremcem
    Mar 21, 2014 at 9:53
  • \$\begingroup\$ I think cable isn't a problem. I replaced the cable with the one that I get from cat5 cable. Result is the same. \$\endgroup\$
    – ceremcem
    Mar 21, 2014 at 10:06
  • \$\begingroup\$ I think a circuit diagram of exactly what you have and tried would help. \$\endgroup\$
    – Andy aka
    Mar 21, 2014 at 12:46

2 Answers 2

4
\$\begingroup\$

Coincidentally, I just completed a project using the same rs485. Add a pull-up resistor at DE, and a pull-down resistor at 'RE. This way, you will always be ready to either receive or transmit. (10k pull-up, 220 ohms pull-down) Do this for both ICs. Do not leave either of these pins floating. Good Luck!

\$\endgroup\$
1
\$\begingroup\$

Normally, the serial data line (into the MAX3232) should be high when no data is being transmitted. A high-to-low transition signals a start bit of the data frame. Driving the data line low for a long period signals a break condition. Could this be confusing your RS232/USB converter? Try putting an inverter on the output of your receiver, and one on the input of your transmitter; this would put the output of an inactive RS485 bus in the high state.

\$\endgroup\$
4
  • \$\begingroup\$ I tried something similar. Isn't this equal to switch A-B connections? Now the twisted pair cable connects A to A and B to B points. If I switch the connection as A to B and B to A, then the transmitted signal is inverted. Which means, RO output is high on idle, yes, but I can not receive any bytes then. It's obvious: I can receive bytes now without terminator resistor. Which means, if I invert the signal, then what I get is also inverted. \$\endgroup\$
    – ceremcem
    Mar 22, 2014 at 0:19
  • \$\begingroup\$ No, that's not the same thing. The receiver output will be zero when the transmitter is tri-stated regardless of whether A & B are swapped. And yes, if you swap A & B, the output is inverted, so it won't work. What I was suggesting is put an inverter (e.g. 74LVC04) on the input of the transmitter, and one on the output of the receiver. The two inversions will cancel each other, the the output of the last inverter (going into your MAX3232) will be zero when the transmitter is disabled. \$\endgroup\$
    – user28910
    Mar 24, 2014 at 13:26
  • \$\begingroup\$ Oops. In that last sentence, I meant to say the output will be a one. \$\endgroup\$
    – user28910
    Mar 24, 2014 at 18:33
  • \$\begingroup\$ Oh, I got it... \$\endgroup\$
    – ceremcem
    Mar 24, 2014 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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