LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

A problem with communication with RS232 device

Sorry for adking this question, but forum search did not help me.

My sutuatuion is such.
I have a device wich has a rs232 port. I need to turn on the chanel 3 on it by sending a command: set:c3 1

But my device requres finishind each command with termination char
I have done this through Windows HyperTermonal program and everithing was Ok. I used 'Enter' button as . It worked.
But my Labview attemts failed. I've looked for examples of Serial communication.
I tried to send my command through Serial.vi - it failed.
I found that Visa configuration block has a default simbol of termination - /n. So a connected a D char (0xD = /r) according to Help recommendations. It does not turn on my device. (I used only Write-to-port pert of it. Because reading from port caused an Error 'Timeout expired before operation completed').

Then I used a 'Instrument I/O Assistant'. I have written to com1 port a set:c3 1 command and it worked!!!

So my questions are:
1. When I use serail.vi only for writing to port how should I terminate my command& What string should I type for sending
set:c3 1/r or
set:c3 1 /r or just
set:c3 1

2. All commands mentioned above did not worked. What is the reason? Why does 'Instrument I/O Assistant' work?
0 Kudos
Message 1 of 5
(2,919 Views)
My LabView version is 7.0
0 Kudos
Message 2 of 5
(2,911 Views)
Right-click on your string constant and choose the '\' Codes Display option, then type
c3\s1\r
into the constant.
When '\' Codes Display is on, \s means a space and \r a carriage return.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 5
(2,909 Views)
Thank you so MUCH!!! It works.

Do I need to use VISA close session in my VI?

Or I can delete this element and everithing wiill be ok? I need to run this VI several times to turn On and OFF my device.
0 Kudos
Message 4 of 5
(2,906 Views)
If your vi is repeatedly called by another vi, it's recommended to Open the Visa session at the beginning of the top level vi and Close it at the end.
Anyway, if you don't like this, you may remove the Close function; in this case, it is recommended that you enable automatic closing of Visa sessions in the LabView Options (Miscellaneous).
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 5
(2,902 Views)