From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with RS232 write/read.

I have a serial device, device responds to ASCII messages:
Reguest string:
!1100/
Responce from device:
!1100/#xx$xxxx/
x - ASCII characters.

I need to communicate with devise using RS232. Device has RS485 port (2-wire). RS232/RS485 converter data direction is controled by RTS line.
In my program I do something like this( single read for now): configure serial port, delay, asserted RTS line, transfer string, delay, unasserted RTS, read string, close port. I use VISA serial. Now I receive garbage. Where the problem might be ?
0 Kudos
Message 1 of 8
(3,077 Views)
Your baud rate and/or parity is mismatched.
- tbob

Inventor of the WORM Global
Message 2 of 8
(3,052 Views)
Have you tried talking to it in hyperterminal? That's the first tool I reach for when doing serial comm. IF you can't get good data in hyperterminal, you've got a hardware issue.

Sheldon
Technical geek, engineer, research scientist, biodegradable...
Message 3 of 8
(3,036 Views)
Sheldon and Tbob responses are indeed the first things to check.

You mentioned that you are using a rs-232 to rs-485 converter and controlling line direction with one of the control lines.

I have seen some converters through garbage on the lines durring the switch.

It the data is right most of the time but has garbage at the front or back of a string, you may be seeing this issue. This can be tolerated by strategicaly flush the buffer and delays before and after the switch.


But, first go with Sheldon's and Tbob's suggestions.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 8
(3,006 Views)
I tried other RS485 coverter ( with auto direction). My program works fine:
Request to device:
!1100/
Responce from device:
#00$xxxx/

Also using port monitor program I monitored data flow between original software (it comes with device) and device.
Reguest string:
!1100/
Responce from device:
!1100/#xx$xxxx/
x - ASCII characters.

So first is request echo and then responce from device.
Manipulating RTS line I only managed to receive request echo, but no responce.
Please see attached VIs: GIA10N - with no RTS control, and GIA10N_RTS - with RTS control ( I receive only request echo with it).
I am sure that my RS232/RS485 converter works standart way, because using serial comms software ( "Advanced serial port monitor") whitch dont know anything about my device I receive responce when I enable "RS485 interface mode". Then I get this:
Reguest string:
!1100/
Responce from device:
!1100/#xx$xxxx/
x - ASCII characters.
0 Kudos
Message 5 of 8
(2,991 Views)
Here is second VI
0 Kudos
Message 6 of 8
(2,991 Views)
Check your termination, "/" is neither linefeed(\n) nor carriage return(\r), your instrument could be mistaking "/" for some special command and return garbage back. Change your termination character to a linefeed and see if that will make a difference.
0 Kudos
Message 7 of 8
(2,946 Views)
I tinkered a bit with your code and removed the termination character input to your VISA serial set-up tool and then I added a carriage return to the end of your "serial write" string. Try it and see if it works.


I'm a newbie, so no promises!!!
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 8 of 8
(2,940 Views)