Shop OBEX P1 Docs P2 Docs Learn Events
Simplest RS485 to RS232 conversion — Parallax Forums

Simplest RS485 to RS232 conversion

william chanwilliam chan Posts: 1,326
edited 2012-09-12 17:34 in General Discussion
Hi Geniuses,

Can a one way RS485 signal ( from lets say from a Mifare Card reader ) be directly converted to RS232 ( TTL level will suffice ) by using just resistors and diodes?

Thanks,

William Chan

Comments

  • TubularTubular Posts: 4,622
    edited 2012-09-12 02:02
    It'll depend on the transmitter in the Mifare reader, as technically the signal could be as small as+/- 200mV (which won't work without horrid supply rail biasing)

    So, put a 120 ohm terminating resistor on and see what voltage is developed across that resistor using a scope.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-09-12 02:48
    This requires a two part answer.

    First RS232 is a +12/-12 serial data transmission and reception convention; while RS485 is a twisted pair noise elimination serial data transmission and reception. That is all about the hardware.

    Second, is the nature of the serial data. What exactly is the 'packet'?

    If it conforms to what we traditionally think of RS232 (certain baud rates and 8 or 7 bit ASCII (or EBDIC) data and related parity and related stop bits), there should be little problem.

    But one can just as easily have a serial packet that has a non-standard baud rate AND/OR more or few bits of data. These days, 16 bit transmission would allow UNICODE to be directly transmitted without conversion, or 24 to 32 bit would allow direct transmission of video information.

    And of course, there are the devious that might choose 13 bits in one direction and 19 bits in the other confound those of use that use an oscilloscope to peek at what is going on.

    You have to hook up an RS-485 reciever and see what is displayed on a scope to know what to do with it.
  • TubularTubular Posts: 4,622
    edited 2012-09-12 05:10
    Loopy, I think RS232 is probably the wrong description, as you correctly point out voltages define it. TTL serial would be a better description

    William, do you know what baud rate is required? Because large protective series resistance may limit the speed somewhat. Also how electrically noisy is the environment? Because I think you're going to lose many of the benefits RS485 normally provides, if you bias around a prop switching threshold
  • LeonLeon Posts: 7,620
    edited 2012-09-12 06:12
    RS-232 actually has a wide voltage range - +/- 3V to +/- 15V.

    I'd use an RS-485 to RS-232 interface chip.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-09-12 07:53
    To make a short answer, if you have a RS-422 (one way transmission), a simple chip should convert it to TTL. You actually need the TTL to check on a scope as the differential transmission may not easily connect with a scope.

    Since the RS-422 receivers come in a Quad chip, it might be easiest to get a RS-485 Tranciever chip and just have it tied to receive.

    There are tons of varieties of these, but a 75176 is quite adequate.

    http://www.ti.com/lit/ds/symlink/ds75176b.pdf
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2012-09-12 09:09
    The simplest answer is, "yes". You have a pair of wires, one of which is (+) non-inverting and the other is (-) inverting, or they may be labeled "A" and "B". Take your signal from the (-) side to your RS232 interface and maybe it works and you're done. Many RS485 interfaces when unloaded will give you a full 0 to 5V (or 3.3V) swing, and that will cross an RS232 threshold that is set at +1V or so.

    For caveats I point at what others have said above. The voltage swing will be much less if there is 120Ω resistor across the line, and of course you lose the advantages of RS485 signalling. RS485 to logic level chips are readily available in 8-pin packages.
  • Mark_TMark_T Posts: 1,981
    edited 2012-09-12 09:34
    A fast comparator? Outputs typically need a pull-up resistor as often are open-collector output. Wide supply voltage range usually too...

    Adding a resistor-divider network at the input will increase the common-mode range and terminate the signal properly.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-12 09:52
    William,

    If you just want to convert to logic levels, instead of RS232, an RS422/485 receiver is the best solution. Barring that, this circuit should work for you, assuming the grounds of the two systems are not connected:

    attachment.php?attachmentid=95527&d=1347468916

    If it's a commercial application, though, definitely make the extra effort and incorporate a differential receiver.

    -Phil
    487 x 287 - 2K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-12 10:24
    Here's an even simpler circuit to convert to RS232 levels:

    attachment.php?attachmentid=95528&d=1347470656

    Again, for this to work, the two system grounds should not be connected, else your signal amplitude will be halved, and you will not get a negative voltage swing. Here's what it looks like on my scope from a 5V RS422 driver:

    attachment.php?attachmentid=95529&d=1347470656

    Whether or not this actually works will depend upon your cable length and how forgiving your RS232 receiver is, since it does not quite produce a +/- 3V swing. You may have better luck if you bias the positive twisted-pair lead a volt or so above ground, rather than to ground level as shown here.

    -Phil
    500 x 167 - 2K
    640 x 480 - 13K
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2012-09-12 15:24
    Here are a couple of 'scope shots from the output of a letter "A" from an RS485 driver chip, the LT1785. The first is with a 10kΩ and the second with a 200Ω differential load, the signals measured relative to ground at 2V/division. The yellow trace is (-) inverting and the red trace is (+) non-inverting, with voltage measured relative to ground. You see, if you put the (-) RS485 signal directly into an RS232 receiver, it can potentially interpret the signal correctly, so long as the threshold of the RS232 receiver is greater than 1V. No other interface necessary. Your mileage may vary, and that caveat as noted by others applies to the cable length and more.
    D011.png


    D010.png

    Going the other direction, you have to bias the (+) RS485 input to Vdd/2. I once bought up a bunch of 2400 baud modems that were meant for use on the Apple Desktop Bus (RS485), and converted them for use directly from the i/o pins of a BASIC Stamp.
    640 x 480 - 10K
    640 x 480 - 10K
  • william chanwilliam chan Posts: 1,326
    edited 2012-09-12 17:34
    Seems like Tracy Allen has the simplest circuit, no circuit required at all.
    Thanks everyone.
Sign In or Register to comment.