LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Read/Write For rs232 and rs485

 

Is there something different that needs to be done when doing Visa Read/Writes for RS485 instead of RS232. 

 

I have 2 separate applications for testing purposes. One that creates a serial message and sends it. And second one that receives the message and displays it. There is no termination character, but the size of the message is always 20 bytes.

 

All of this works fine on when transmitting over rs232 ports, but we just got the equipment in to test over rs485 ports and I am not receiving anything.

 

I had just assumed nothing on the LabVIEW side(setting up visa resource) would be any different whether it is 232 or 485. Is there a setting that needs to be changed when working with rs485?

 

0 Kudos
Message 1 of 8
(4,808 Views)

Since they are both basically serial comunications there is nothing that should need to be changeed in your code.

 

RS485 can be picky about termination resistors and polarity (A+ A-) 

 

What RS485 adaptors are you using?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 8
(4,787 Views)

I greatly appreciate the quick response.

 

I do not believe there are any adapters involved. The cords are coming out of a NI PXIe-8431/16 (https://www.ni.com/en-us/shop/model/pxie-8431-16.html). We have 8 rs485 ports coming out an I am just trying to connect 2 of them together using the same gender changer I was using for the rs232 ports. I've been told I should not need a null-modem.

0 Kudos
Message 3 of 8
(4,767 Views)

@LovelandGameDev wrote:

I greatly appreciate the quick response.

 

I do not believe there are any adapters involved. The cords are coming out of a NI PXIe-8431/16 (https://www.ni.com/en-us/shop/model/pxie-8431-16.html). We have 8 rs485 ports coming out an I am just trying to connect 2 of them together using the same gender changer I was using for the rs232 ports. I've been told I should not need a null-modem.


I have never used that hardware so I am not sure about pin outs and all that on your device.

 

But A+ needs to go to A+ and A- needs to go to A- same for B+ and B-

 

Doubble check your connections.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 8
(4,760 Views)

Definitely check your wiring connections.  Note that using RS-232 based cables, whether straight through or null modem, may not work.  The reason is that RS-232 ports have pins set to a well-defined standard as either DCE or DTE.  Meanwhile, RS-485 ports which are either 2-wire (transmit/receive on the same pair) or 4-wire (transmit/receive on different pairs), and the fact they are differential pairs as opposed to single ended communication wires like RS-232 means the wiring connections are completely different from RS-232.  Also, there really is no standard for RS-485 pinouts, so different manufacturers might assign the pairs to different pins assuming they are using DB-9 ports and cables.

 

One other thing to note.  2-wire RTD means the sending and receiving are on the same pair.  Depending on how the RS-485 port handles this, it is possible that an RS-485 port sending a message will receive an echo of that message on its receiving pins and you may have to detect that and reject the message in software.  The better ports have methods to account for that automatically making sure to turn off the receive pins while the device is transmitting.

0 Kudos
Message 5 of 8
(4,753 Views)

I appreciate the help, there ended up being a null modem cable made for rs485 that worked

0 Kudos
Message 6 of 8
(4,745 Views)

 Hi all,

 

I have a system where I need to read/write from multiple RS485 devices via NI-VISA. I am opening the com port that is connected to USB to RS485 converter and have for this test 2 RS-485 devices that are connected over that bus (I am using unique ID's fro each device so when I send it over the bus ONLY the device with that ID is responding). When using only one 485 device there is no problem and I continuously read and write to that device over the bus. But when I have two devices it starts working OK but after some time it seems that one of devices is not responding and the loop is hanging while waiting for Number of Bytes at Serial Port. I have discovered that if I send again the same command ID then I receive the answer from the appropriate device.

The sequence I use is: Write to COM port 3 bytes that identify the device ----->>> Wait for Number of Bytes at Serial Port----->>>Read the answer from that Device->>>> than same for the second device and loop again.

 

Why is this happening? Any ideas?

Thanks,

0 Kudos
Message 7 of 8
(3,976 Views)

Hi TinoMK,

 

I would recommend checking the baud rate for the devices and using the 'VISA Configure Serial Port VI' to set those up appropriately if you haven't already. 

 

Another suggestion would be to switch the cables of the devices to see if the issue lies there. Alternatively, verify that the device that hangs works with your program, and then add in the original device that worked.

 

If you aren't able to resolve your issue, I highly recommend creating a new forum post and including your code, as well as any debugging steps you have tried. This current thread is 1.5 years old and you will achieve a better response with a new post.

 

Good luck!

 

BrandonN

Applications Engineer

National Instruments

Message 8 of 8
(3,962 Views)