LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA READ wait for termination character not working

Solved!
Go to solution

 

emime_0-1624374065184.png

 

I have created a simple subVI to send and receive messages from the stage I am communicating with. It sends the commands without issues but doesn't wait for the response which is a carriage return when the movement ends.

 

So when trying to send multiple commands in a row, they don't wait for the previous action to be completed before loading the next and the stage misses some commands, I need to make sure it waits until the "action completed" message is read before moving on to the next command. 

 

I based my code on this talk: (1739) Proper way to communicate over serial - YouTube.

 

Can anyone take a look at what I've got and give me some pointers?

Thank you.

Download All
0 Kudos
Message 1 of 37
(1,841 Views)

You can do all with the VISA Configure Serial Port vi. Wire the integer constant 13 to the Termination char input.

You don't need all those property nodes, but if you do, put them inline before starting communications.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 37
(1,830 Views)

How many characters is your longest response? Are you sure that the termination character is a carriage return and not a line feed. The most common termination character is the line feed. Some instruments expect a carriage return/line feed combination. Also, all of your initialization of the VISA session should be done immediately after the open and before your write. As written, you have potential race conditions since the setting of the attribute and the read or write can operate in parallel. Use data flow to control the sequence of operations.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 37
(1,829 Views)

emime_0-1624375693944.png

I am absolutely sure that it uses carriage return, it was specified in the user manual. The greatest number of bytes a message can be is 33 (also from the user manual) so I put 100 just to be safe.

 

It send the messages just fine, It is just not waiting for the receipt of the all done message. I have moved all the specifications before the read operation and I still have the same error. Thanks for your suggestions, if you have any more ideas, I'd appreciate them.

 

emime_0-1624377245830.png

 

0 Kudos
Message 4 of 37
(1,815 Views)

@emime wrote:

emime_0-1624375693944.png

I am absolutely sure that it uses carriage return, it was specified in the user manual. The greatest number of bytes a message can be is 33 (also from the user manual) so I put 100 just to be safe.

 

It send the messages just fine, It is just not waiting for the receipt of the all done message. I have moved all the specifications before the read operation and I still have the same error. Thanks for your suggestions, if you have any more ideas, I'd appreciate them.

 

emime_0-1624377245830.png

 


Something is amiss here, because the protocol says <CR> (carriage return) but inside the message, I see "0D" which is a carriage return!

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.
Message 5 of 37
(1,789 Views)

Here is the user manual for external devices.

 

MP-285A_QuickRef_ExternalControl.pdf (sutter.com)

 

Protocol and Handshaking: Most command sequences have a terminator: ASCII CR (Carriage Return; 13 decimal, 0D hexadecimal) (see the MP-285
external-control commands table). All commands
return an ASCII CR (Carriage Return; 13 decimal,
0D hexadecimal) to indicate that the task associated
with the command has completed. When the controller completes the task associated with a command, it sends ASCII CR back to the host computer
indicating that it is ready to receive a new command. If a command returns data, the last byte returned is the task-completed indicator.

0 Kudos
Message 6 of 37
(1,749 Views)

I have no idea why the post was deleted, but the manual was pretty confusing.  (I did end up understanding it though.)  So the message received is to be 13 bytes long.  The first 12 consist of 3 i32 numbers, and the last byte is the 0x0D, or <CR>.  Pretty straightforward, but really overcomplicated in the manual.

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.
Message 7 of 37
(1,762 Views)

I would set it up like this


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 37
(1,760 Views)

Assuming that you are sending the appropriate command, your code should work - although are you sure you need a ten minute timeout?

 

Edit:

Crossposted with 's post, but they are both the same code anyway, although 's code is cleaner.  And cleaner is better, and it's not just a cosmetic thing, either.

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.
Message 9 of 37
(1,753 Views)

No one has asked but are you getting an error? If so, what is the error? How are you determining that you are not getting a response. As mentioned, your timeout is quite long. If you are returning immediately you may be getting the return data but are not seeing it in the string indicator because it is unprintable characters. Some will appear as white space such as the carriage return. You may think the indicator is empty when in reality there is data there.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 37
(1,746 Views)