deepakdeshp
Posts: 33
Joined: Thu Oct 26, 2017 7:23 pm

How to interface 3 serial ports each 9 pins to the PI?

Fri Jun 08, 2018 6:59 pm

Hello,
As the name suggests , I am planning to control 3 serial ports by a single Raspberry Pi 3b model. The project requires that the 9 pin RS 232 ports have to be controlled and data written to them. Please suggest the hardware I will have to purchase to accompany this task.

Thanks all in anticipation

User avatar
DougieLawson
Posts: 33628
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: How to interface 3 serial ports each 9 pins to the PI?

Fri Jun 08, 2018 7:18 pm

You're probably better off converting to RS-485 and using an add-on HAT to drive that.

Trying to drive three RS-232 (style) UARTS isn't easy to accomplish on a RPi (unless it's a CM/CM3/CM3L).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

hippy
Posts: 3603
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to interface 3 serial ports each 9 pins to the PI?

Fri Jun 08, 2018 7:49 pm

deepakdeshp wrote:
Fri Jun 08, 2018 6:59 pm
The project requires that the 9 pin RS 232 ports have to be controlled and data written to them. Please suggest the hardware I will have to purchase to accompany this task.
All you need is three USB-to-RS232 serial cables with 9-way connectors on them -

http://img.dxcdn.com/productimages/sku_150345_1.jpg

They are widely available, cheap, easy to use, and if based on the Prolific PL2303 chipset the drivers are already baked into Raspbian and usually any other Linux.

You might need three 9-way null-modem connectors or cross-over cables depending on what you are interfacing to, whether male plugs or female sockets.

And you will need a USB hub if you don't want to plug them directly into your 3B.

deepakdeshp
Posts: 33
Joined: Thu Oct 26, 2017 7:23 pm

Re: How to interface 3 serial ports each 9 pins to the PI?

Sun Jun 10, 2018 10:31 am

All you need is three USB-to-RS232 serial cables with 9-way connectors on them -

http://img.dxcdn.com/productimages/sku_150345_1.jpg

They are widely available, cheap, easy to use, and if based on the Prolific PL2303 chipset the drivers are already baked into Raspbian and usually any other Linux.

You might need three 9-way null-modem connectors or cross-over cables depending on what you are interfacing to, whether male plugs or female sockets.

And you will need a USB hub if you don't want to plug them directly into your 3B.
Thanks all for your answers. hippy, your solution is excellent , only hitch is that the 3 ports need to be installed in a limited space box. If there was no cable, in the diagram, the solution would have been perfect.

hippy
Posts: 3603
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to interface 3 serial ports each 9 pins to the PI?

Sun Jun 10, 2018 2:21 pm

deepakdeshp wrote:
Sun Jun 10, 2018 10:31 am
hippy, your solution is excellent , only hitch is that the 3 ports need to be installed in a limited space box. If there was no cable, in the diagram, the solution would have been perfect.
Perhaps describe exactly what requirements you have then it may be possible to find something which is most suitable.

If you cannot simply use a bigger box you could start trimming cables to shorter lengths. If you can find a small USB hub you can unsolder its sockets, wire the serial USB cables direct to those without USB plugs. You can also remove the moulding around the 9-way connectors. You could even buy PL2303 or similar chips, have them on your own HAT-like board.

User avatar
scruss
Posts: 1773
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to interface 3 serial ports each 9 pins to the PI?

Sun Jun 10, 2018 4:48 pm

The difficulty with using PL2303 chips is that they tend to appear on semi-random /dev/ttyUSBxx names on boot up. FTDI can be a bit more predictable.

There are multi-serial HATs/boards available, like this one: Pridopia - Raspberry Pi 4 UART Board RS232 / RS485 x4. Haven't used it, can't recommend it, but it's out there …
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

hippy
Posts: 3603
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to interface 3 serial ports each 9 pins to the PI?

Mon Jun 11, 2018 12:02 am

If it is transmit only from the Pi as the OP suggests it could be extremely easy; It could even be done with a single 74xx logic chip and some level shifters. Might not even need the level shifters.

deepakdeshp
Posts: 33
Joined: Thu Oct 26, 2017 7:23 pm

Re: How to interface 3 serial ports each 9 pins to the PI?

Mon Jun 11, 2018 1:11 am

I have to read and write to 2 UART rs232 devices.

hippy
Posts: 3603
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to interface 3 serial ports each 9 pins to the PI?

Mon Jun 11, 2018 10:47 am

deepakdeshp wrote:
Mon Jun 11, 2018 1:11 am
I have to read and write to 2 UART rs232 devices.
Are you receiving unsolicited data or can you get away with sending a command then waiting for a result or reply ?

If you can point a single UART to the specific device you need to communicate with, then move on to the next, it is fairly easy to implement.

The more you can tell us about exactly what you need to do, how it has to work, the better people will be able to help you.

deepakdeshp
Posts: 33
Joined: Thu Oct 26, 2017 7:23 pm

Re: How to interface 3 serial ports each 9 pins to the PI?

Mon Jun 11, 2018 6:08 pm

hippy wrote:
Mon Jun 11, 2018 10:47 am
deepakdeshp wrote:
Mon Jun 11, 2018 1:11 am
I have to read and write to 2 UART rs232 devices.
Are you receiving unsolicited data or can you get away with sending a command then waiting for a result or reply ?

If you can point a single UART to the specific device you need to communicate with, then move on to the next, it is fairly easy to implement.

The more you can tell us about exactly what you need to do, how it has to work, the better people will be able to help you.
Thank you.
I can wait after sending a command then waiting for a result or reply. The application is that the pi will be interfacing with 3 precision balances for which the Pi will be a single 7 inch touch display. Any of the scales will be used and at a time a single scale will be used. The Pi will act as the single display , The output of the balances interface to the pi with a 9 pin rs232 port.

hippy
Posts: 3603
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: How to interface 3 serial ports each 9 pins to the PI?

Mon Jun 11, 2018 11:41 pm

In that case it should be pretty easy to build a suitable interface for using the Pi UART -

Code: Select all

                _____                           _____     ___
Pi TX >-.-------\    \            RX A >--------\    \   |   \
        |        | OR )--> TX A                  | OR )--|    \
        | .-----/____/                    .-----/____/   |     |
        | |     _____                     |     _____    |     |
        }-|-----\    \            RX B >--|-----\    \   |     |
        | |      | OR )--> TX B           |      | OR )--| AND |--> Pi RX
        | | .---/____/                    | .---/____/   |     |
        | | |   _____                     | |   _____    |     |
        `-|-|---\    \            RX C >--|-|---\    \   |     |
          | |    | OR )--> TX C           | |    | OR )--|    /
          | | .-/____/                    | | .-/____/   |___/
          | | |                           | | |
/SA ------^-|-|---------------------------' | |
/SB --------^-|-----------------------------' |
/SC ----------^-------------------------------' 
All TX and RX are shown with UART polarity ( idle high ). A, B, C lines to the actual scales will need to be inverted by RS232 buffers. Drive /SA, /SB, /SC from GPIO. Set one of those low to enable a particular channel, set the other two high.

The question then becomes, not what you need to buy, but who you need to convince to build that for you.

deepakdeshp
Posts: 33
Joined: Thu Oct 26, 2017 7:23 pm

Re: How to interface 3 serial ports each 9 pins to the PI?

Wed Jun 13, 2018 8:14 am

hippy wrote:
Mon Jun 11, 2018 11:41 pm
In that case it should be pretty easy to build a suitable interface for using the Pi UART -

Code: Select all

                _____                           _____     ___
Pi TX >-.-------\    \            RX A >--------\    \   |   \
        |        | OR )--> TX A                  | OR )--|    \
        | .-----/____/                    .-----/____/   |     |
        | |     _____                     |     _____    |     |
        }-|-----\    \            RX B >--|-----\    \   |     |
        | |      | OR )--> TX B           |      | OR )--| AND |--> Pi RX
        | | .---/____/                    | .---/____/   |     |
        | | |   _____                     | |   _____    |     |
        `-|-|---\    \            RX C >--|-|---\    \   |     |
          | |    | OR )--> TX C           | |    | OR )--|    /
          | | .-/____/                    | | .-/____/   |___/
          | | |                           | | |
/SA ------^-|-|---------------------------' | |
/SB --------^-|-----------------------------' |
/SC ----------^-------------------------------' 
All TX and RX are shown with UART polarity ( idle high ). A, B, C lines to the actual scales will need to be inverted by RS232 buffers. Drive /SA, /SB, /SC from GPIO. Set one of those low to enable a particular channel, set the other two high.

The question then becomes, not what you need to buy, but who you need to convince to build that for you.
Thank you so much hippy, this has given us a good direction. I will update here about the project as it progresses.

Return to “Add-ons”

Who is online

Users browsing this forum: leroipele, Paul Webster and 5 guests