Shop OBEX P1 Docs P2 Docs Learn Events
RS-232 to RS-485 advice required please. — Parallax Forums

RS-232 to RS-485 advice required please.

StuartttttStuarttttt Posts: 45
edited 2009-07-12 18:41 in BASIC Stamp
Hi,

I'm trying to send / recieve data from PC (StampPlot) to BS2 using two RS-232 to RS-485 (transparent) converters
but not having much success.
I'm using RS-232 pins 2, 3, 4, and 5 at the moment, to a 485 converter then a Cat5 cable.

A sample of code I'm using is :

SEROUT 16,84,[noparse][[/noparse]"!READ (DEPTHSP)",CR] 'Read Auto control depth setpoint slider
SERIN 16,84,1000,Main1,[noparse][[/noparse]DEC DEPTHSP]

The programme·works perfectly with a long RS-232 cable but I need a longer transmission cable.
The 485 converters guide is a bit vague, do I·need to change / add anything to enable it to work with the 485 converters ?
·ie. RS-232··· RTS pin 7 ?
Any help will be appreciated.

Stuart










·

Comments

  • StuartttttStuarttttt Posts: 45
    edited 2009-07-11 17:40
    Just to add. I just have tried using all RS-232 pins with the converters but same got the same result.
    Stuart
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-07-11 18:27
    So called "transparent" converters internally have a method to change the direction of the transmission. Both ends normally are in receive mode but switch instantly to transmit mode when either end generates a start bit. They usually don't switch back to receive mode for some set time after the stop bit, and that time is adjusted for the minimum baud rate that they will have to carry. Some are smarter than others, and the delay may be a simple RC circuit. The point is that you have to allow for that turnaround delay.

    You didn't mention having a null modem adapter. What happens when you say, "not having much success"?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • StuartttttStuarttttt Posts: 45
    edited 2009-07-11 18:38
    Hi Tracey,

    I have just uploaded a small test code to the BS2 using the standard RS-232 cable. When I run the code, then insert the two 485 adapters I am actually getting data back from the BS2.
    Also using StampPlot I do appear to get data back from the BS2 but can't send to it.
    I can not load code to the BS2 via 485. Using "debug identify" there is no stamp, loopback or echo.

    Stuart
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-07-11 21:45
    You won't be able to program the Stamp, because that depends on connection of pin 4 on the DB9, (ATN to Reset on the Stamp, DTR on the PC). That signal does not come through the RS485 connection and it is essential to programming. There are other issues too. For programming over that type of connection, you would need more like RS422, full duplex with rx and tx separately on 4 wires in your CAT5 cable, and another pair of wires and a transmitter/receiver pair to carry the DTR signal.

    I don't know though why you are not receiving data from the PC. Can you try it with a terminal program (e.g. Hyperterminal)? Could it be a timing issue?

    Could you use RS232 at a much lower baud rate to get the distance that you need?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • stamptrolstamptrol Posts: 1,731
    edited 2009-07-11 22:11
    A couple other things to try.

    Is the '485 side of your connection wire two wires or 4 wires? If two, you will have to have the Tx+ and Rx+ (and Tx-/Rx-) tied together on both converters to give the proper half-duplex setup. To state the obvious, if using a 4 wire, full duplex connection the Tx's on one converter go to the Rx's of the other.

    As Tracy pointed out, in half duplex or "auto switchover" mode, there can be a bit of a delay from one mode or the other but it usually shows up as missed characters, not total failure.

    Are these '485 converter called "self-powered"? Those type steal power from the serial port on either end in order to run. The PC can certainly do that, but the Stamp's port implementation may not present enough parasitic power to properly operate the converters.

    To get things working in the simplest form, you should only need pins 2, 3, 5. Set the converters for non-auto switchover, 4-wire, ignore RTS/CTS. Thats closest to a straight wire connection.

    It will be worth it to sort out '485! Gives lots of flexibility for future projects.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • StuartttttStuarttttt Posts: 45
    edited 2009-07-12 13:00
    Tracy and Tom,

    The 485 adapters "were" half duplex, self powered. After applying a mere +9v to the supply pins (as stated on the terminal) they don't appear to work at all now. Using an oscillosope on D +/A and D -/B there was a data stream present on both a couple of days ago, but not any more ?
    I can only imagine they were not very good quality/faulty.
    However, undeterred, I will return to this thread when I have purchased and tried a new pair.
    Thanks for your time and comments.

    Regards
    Stuart
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-07-12 18:41
    On the Stamp end there is less reason to use a dongle. In place of a dongle you could use a (cheaper!) RS485 transceiver chip that could plug into a breadboard. The Stamp can easily control the direction and data pins, and the transceiver takes care of interface to the RS485 pair, all using the 5 volt Stamp power supply. On the PC end, you still need one dongle.

    The chip I often use is the LT1785, but there are many choices out there.

    I should add that the Stamp end would use standard pins, p0 to p15, not the debug port, p16.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.