LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA and READ function - Problem linked to the bytes at port

Rolf,

     I think your algorithm and mine are basically the same.  Read until VISA sees the termination character, then process what you read.

 

     I did say "process the number of bytes read" -- I should have clarified this by saying "Process the entire string that you just read".  I managed to "confuse myself" -- I was thinking about an instrument that communicated using a binary series of bytes, with the sign bit signalling "start of packet" and the packet size being determined by a complicated algorithm.  Sorry about that ...

 

Bob Schor

0 Kudos
Message 11 of 114
(1,944 Views)

If you have configured the right termination character (you use the VISA Configure Serial Port function don't you?) you can simply set the "Enable Termination Char" to true (is default set to true) and wire the right termination character to the "termination char" terminal.

It should then not return an error.


Rolf Kalbermatter
My Blog
0 Kudos
Message 12 of 114
(1,941 Views)

Okay, 

 

so, here is a temporary solution attached to the post. It "works" but it may carry an error... err(-1073807339)

 

Could i ask you for the pieace of VI you guys are talking about? I would like to check how you read until the termination character 🙂

 

Flo

0 Kudos
Message 13 of 114
(1,941 Views)

The VISA Configure Serial Port can be found under Instrument IO->VISA->VISA Advanced->Bus/Interface Specific->Serial. After that you simply use the normal VISA Read.

 

err(-1073807339) is a Timeout error, so your message is either really longer than you think before the termination character occures, or you have not yet set the right termination character and/or enabled it.

Rolf Kalbermatter
My Blog
0 Kudos
Message 14 of 114
(1,940 Views)

Would you have an example from your own work? I am being confused right now, and i fell that my answer may be somewhere around that termination character !

 

edit: it's getting more and more confuising. The first READ function works fine, the other one, which is the same as the one before, doesn't work. I am officially lost 🙂

 

Cheeers,

Flo

0 Kudos
Message 15 of 114
(1,930 Views)

The devices I use normally use the standard <carriage return> termination character. A simple function to communicate with this would look like this:

 

VISA Communication.png

 

You'll have to adjust the termination character to the VISA Configure Serial Port to your own needs and also make sure to terminate the command you send to the device with the right character. The \r at the end of my command is simply the carriage return and for this to work the enable "\-codes display" for the string needs to be enabled (right click on the string and select the according option).

 

You probably need to make sure to send the proper termination character in your command that you write to the device or it will sit there waiting for more to come and simply ignore your next command.

Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 114
(1,921 Views)

I tried your solution. but at the end my READ function throw an error... the surprising bit is that the returned string from the READ function is EXACTLY what I want, but I still have this error...

 

I've attached my modified VI, I tried to include the termination character, but I am still a bit confused with that. Does my code make sense? I've included the "/" at the entry of the VISA, then enabled the '\' codes display  from my string command "CS". the string termination character should be included in the response right ?

0 Kudos
Message 17 of 114
(1,911 Views)

@rolfk wrote:

The devices I use normally use the standard <carriage return> termination character. A simple function to communicate with this would look like this:

 

VISA Communication.png

 

You'll have to adjust the termination character to the VISA Configure Serial Port to your own needs and also make sure to terminate the command you send to the device with the right character. The \r at the end of my command is simply the carriage return and for this to work the enable "\-codes display" for the string needs to be enabled (right click on the string and select the according option).

 

You probably need to make sure to send the proper termination character in your command that you write to the device or it will sit there waiting for more to come and simply ignore your next command.


Note that there is no Visa Flush I/O Buffer function because, by reading until the termination character, you are reading exactly what you need to read into the VISA buffer.  No more, no less.

 

Also: As I understand it, LabVIEW does not pre-allocate the VISA Read buffer with byte count amount of bytes, so go ahead and make byte count significantly greater than you think you'll ever need.  Hence 1000 bytes for the byte count in the example.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 18 of 114
(1,909 Views)

@ICCR-Lab wrote:

I tried your solution. but at the end my READ function throw an error... the surprising bit is that the returned string from the READ function is EXACTLY what I want, but I still have this error...

 

I've attached my modified VI, I tried to include the termination character, but I am still a bit confused with that. Does my code make sense? I've included the "/" at the entry of the VISA, then enabled the '\' codes display  from my string command "CS". the string termination character should be included in the response right ?


Do you see any VISA Bytes at Serial Port nodes in the example?  You don't need it.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 19 of 114
(1,907 Views)

Thanks billko,

 

it slowly starts to make sense.

 

Would you please tell me if I am doing it ok: 

- my termination character is "/" 

- my command is "CS"

- i know that the command works fine, I still get this error.

pic5.png

 

 

 

0 Kudos
Message 20 of 114
(1,905 Views)