Jump to content

Two devices connected via single com port [rs232]


agonified

Recommended Posts

Hi everyone,

I am using Labview to control two devices which must be controlled via rs232 protocol. Communication is so simple; connecting only Tx, Rx, and, ground pins is enough and sending string commands such as 'setvalue' and 'readvalue' makes controlling the device easily possible. My problem is, devices are upstairs and I want to use only one cable to connect both of them(BTW there is only one serial port on my pc). A single cable out of the com port is seperated into two with a 'Y' adapter near the devices. This is where the problem occurs. I can't get response from devices when I connect both of them. However, if I remove the cable between one of the devices and the 'Y' adapter, other works perfectly.

I set up a testing environment at home with three computers such that at a given time, one was 'server' and other two were 'client's. I applied same wiring schema via com ports and the results were strange: both of the clients were able to get messages from server but server was only getting messages from one of the clients. I tried all possible combinations like exchaning server with client1 and client2. No luck... Same happened. Server computer was able to read messages sent by only one of the clients. Strange enough, in case of connecting my devices upstairs, I could not get response from any of them.

I am not able to locate the source of the problem unfortunately. As far as I can imagine, it might be diffrence in the ground pins voltage levels of the three of the computers and/or devices. Can someone please explain me what's wrong with my wiring setup? And, if it is completely out of the abilities of the rs232 protocol, what are the other cheap solutions? FYI, my devices can also use rs485 protocol to communicate.

Thanks in advance.

Link to comment

I don't find it strange you have only one responsive device.

My suggestion, by a second serial port (on USB is mostly OK, test before paying ;) )

I can imagine the USB device will not be able to feed the power over a long cable.

I don't know how long a serial cable can be but I suggest you set up a PC near the devices with two serial ports and communicate with these devices via a serial server (included with NI-VISA) over ethernet.

Ton

Link to comment

QUOTE(tcplomp @ Aug 1 2007, 07:03 AM)

...I don't know how long a serial cable can be...

From MANY years ago, I recall that the max length of an RS-232 cable was 25 feet for unshielded and 50 feet for shielded WITH soldered pins inside the hood. The transmission rate was 9600 bps.

I would suggest going to RS-485 if your remote devices support it. You'll need an RS-485 adapter in the PC or have to use a USB to RS-485 adapter.

Another choice might be using a device like those from Lantronix. You connect the RS-232 / RS-485 devices to the device server, then the device server to a LAN. You use TCP/IP to connect to the server, then use escaped strings to select the rs-485 device.

UPDATE

The Lantronix devices are also available in wireless, definitely a plus when working at home :)

Link to comment

Hello,

I don't think RS232 supports multiple instruments on the same port. I do know RS 485 does. I have never tried it though. I would also recomend RS485 for longer distances and/or is you are putting this in a noisy environment. RS485 is a differential protocal and RS232 is single ended. I have used these RS485 Hubs with good sucess.

http://sewelldirect.com/quatech-usb-rs-422-485-surge-4.asp

Dan

Link to comment

The other guys are right - RS-232 supports only two nodes - one on each end of the cable. Think about the schema: your PC sends a string which goes along the Tx line to the components. This signal is just a varying voltage pulse train, and both of the instruments see the voltage changes, so they get the message. If you send a "getvoltage" message - they'll both get it, and then try to send their responses back on the Rx line but varying voltages on it - this is why your send is working and your responses aren't: when you do the send, it's only one node that's talking (the PC), when you getting your response, there are two nodes talking simultaneously (the instruments), so the PC is getting confused. It's like asking two people a question, and then trying to listen to their responses simultaneously. What you need is a protocol that identifies which instrument it's talking to, and each of the instruments is self aware. For example - you ask two people a question, but you addres them first: "Bob, how old are you?" Mike hears "Bob" and then isn't interested in replying because the message wasn't addressed to him. Bob replies, and then you ask the same question, but with "Mike" at the front instead. Better yet - do you have ethernet between the PC and the instruments? You could use an ENET-RS232/2 - they're cheap an look just like serial ports to windows.

Link to comment

This may be a silly question, but did you check for an auxiliary COM port on your motherboard?

I just got a new MoBo this last week and was surprised to find an internal COM port (in addition to three sets of internal USB ports ;) ). The port would be a 2x4 100-mil header (mine was designated "COMB").

As stated above, RS232 was not designed for more than two devices (one master and one slave). It would be in your best interest to seek out an alternative solution to your setup.

-H

Link to comment

QUOTE(Ben @ Aug 2 2007, 03:22 AM)

Just to split hairs.... I have seen gizmos that daisy chain RS-232.

Split away! :) These gizmos are usually just nodes that add and filter message addressing. They don't make the physical RS-232 layer multi-node, they just add addressable message handling. They do add a little overhead (as they're parsing and the like), but they might be okay in your application. That said, if you've got the infrastructure, the ENET-RS-232/2 is propbably still a good option IMHO.

Link to comment

QUOTE(crelf @ Aug 1 2007, 04:09 PM)

Actually, they do not respond at the same time: they have network addresses so that users can use them on the same LINE. 'readvariable1' means 'only device which has network address 1 must respond, others keep slient'. So there is no reason for my computer to get confused because at a given time, there is only one device trying to talk to the PC.

QUOTE(Doon @ Aug 1 2007, 05:05 PM)

This may be a silly question, but did you check for an auxiliary COM port on your motherboard?

Nope, already checked, no luck... :(

I still don't understand why this setup does not work. Can someone clarify me before I go with other solutions? I will most probably go with second rs232 interface.

Thanks everyone. Such a great community you are... :worship:

Link to comment

Both devices are control the same data line, so even though one is quiet, it is keeping that line HIGH (which is how RS-232 is when no data is transmitting). So even when you are sending data back from one device, the other device is either keeping the line HIGH anyway or the voltages are summed and the low transitions are only going halfway down which may not be low enough to be detected as a LOW. Either way, you are not getting data back.

Maybe if you add a CMOS AND gate (with +/- 15 V supply) to AND the signals from the two devices (if I am wrong about the state when no data is being transmitted, then you will need a CMOS OR gate), you could get this to work. Some isolation between the two devices is required.

QUOTE(agonified @ Aug 1 2007, 04:26 PM)

Actually, they do not respond at the same time: they have network addresses so that users can use them on the same LINE. 'readvariable1' means 'only device which has network address 1 must respond, others keep slient'. So there is no reason for my computer to get confused because at a given time, there is only one device trying to talk to the PC.

Nope, already checked, no luck... :(

I still don't understand why this setup does not work. Can someone clarify me before I go with other solutions? I will most probably go with second rs232 interface.

Thanks everyone. Such a great community you are... :worship:

Link to comment

QUOTE(rpursley @ Aug 1 2007, 08:52 PM)

Both devices are control the same data line, so even though one is quiet, it is keeping that line HIGH (which is how RS-232 is when no data is transmitting). So even when you are sending data back from one device, the other device is either keeping the line HIGH anyway or the voltages are summed and the low transitions are only going halfway down which may not be low enough to be detected as a LOW. Either way, you are not getting data back.

Maybe if you add a CMOS AND gate (with +/- 15 V supply) to AND the signals from the two devices (if I am wrong about the state when no data is being transmitted, then you will need a CMOS OR gate), you could get this to work. Some isolation between the two devices is required.

Then, why I can read messages sent from only one of the clients in my test environment?

Link to comment

QUOTE(agonified @ Aug 2 2007, 06:26 AM)

That was an important bit of information to know. Is this method of daisy-chaining your devices supported in the documentation that comes with them?

QUOTE(rpursley @ Aug 2 2007, 06:52 AM)

Both devices are control the same data line, so even though one is quiet, it is keeping that line HIGH (which is how RS-232 is when no data is transmitting).

An excellent point - I completely agree with rpursley on this one.

QUOTE(agonified @ Aug 1 2007, 08:44 PM)

FYI, my devices can also use rs485 protocol to communicate.

Unless you want to use a second interface or the ENET-RS-232/2, then RS-485 might have to be your answer.

Link to comment

QUOTE(crelf @ Aug 1 2007, 09:14 PM)

Is this method of daisy-chaining your devices supported in the documentation that comes with them?

Yes it is. But it is not mentioned that whether it requires rs232 or rs485. So, knowing that only one device can respond at a time, is it still impossible to go with rs232? I don't want to buy new hardware... :unsure:

Link to comment
QUOTE(agonified @ Aug 2 2007, 10:10 AM)
Yes it is. But it is not mentioned that whether it requires rs232 or rs485.
I'd bet a beer that the daisy chaining is only supported in RS-485 mode. ...and when an Aussie bets a beer, you know he's pretty bloody ure that he's right.
Link to comment

QUOTE(crelf @ Aug 2 2007, 08:42 AM)

Me too :D

This inspired me :lightbulb: to think about setting up a "LabVIEW Beer Exchange" that would operate similar to the Federal Reserve Bank. Rather than meeting once a month to swap canceled checks, once a year it could work out who owes who how many beers and the debt can be settled at NI Week.

Then again, maybe I should finish my coffee and get some real work done. :yes:

Ben

Link to comment

QUOTE(Ben @ Aug 2 2007, 11:01 PM)

This inspired me to think about setting up a "LabVIEW Beer Exchange" that would operate similar to the Federal Reserve Bank.

I already owe a lot of people a lot of beer next week, but I figure that they'll remind me :)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.