LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

How can you say it behaves well  when it "the code keeps in memory weird commands"?

 

If you send a command, does the device send back a response?  Does it send back a response for every command you send?

 

If you never bother reading back the response when you write out a command, those responses are going to hang around in the serial buffer.  When you finally do something that does a VISA read, you are going to be reading a response even if it happened an hour ago, as long as you haven't flushed the buffer or closed the com port.

0 Kudos
Message 61 of 114
(632 Views)

what you are saying does make sense. I don't quite understand how serial communication works between a computer and that pump, but interestingly, you said

 


@RavensFan wrote:

you haven't flushed the buffer or closed the com port.


and THIS is exactly what is happening. I feel like you spotted something wring with my code but I don't see what is wrong. would you please be more specific? I feel like I should find another solution for priming my software (Timeout seems to be a bad idea) but how then could I prime my numerical boxes ?

 

You are very helpful, Thanks !!

 

Flo

0 Kudos
Message 62 of 114
(624 Views)

First.  Make sure you read the manual for device.  Make sure you send the correct command including any termination characters it might need.  If it sends a response (which most devices will as an acknowledgement that it received a command) then be sure to include a VISA Read to get that response, even if you don't need to do anything with it later.

0 Kudos
Message 63 of 114
(614 Views)

I've read the manual many times, and there is no termination character for a command (just two letters usually)

 

I've triple checked, and my commands are fine. As you said, the pump may send a responce back, even if I don't need it. So next step is to put a READ function even if I don't use it.

 

Also, I am interested by the fact you said that my timeout event was not ideal for what I need. How could I get the same result, by avoiding that timeout event according to you?

 

Flo

 

0 Kudos
Message 64 of 114
(609 Views)

@ICCR-Lab wrote:

I've read the manual many times, and there is no termination character for a command (just two letters usually)

 

I've triple checked, and my commands are fine. As you said, the pump may send a responce back, even if I don't need it. So next step is to put a READ function even if I don't use it.  

Also, I am interested by the fact you said that my timeout event was not ideal for what I need. How could I get the same result, by avoiding that timeout event according to you?

 

Flo

 


A command expecting a response is called a "query" and you should always read the results from a query, even if the response is just something like "OK".  This will keep the read buffer clear in a "natural" kind of way (i.e., clearing the buffer by reading the response).  You don't need to read anything if the command is not a query.  Trying to read a non-existent response will probably get you a timeout.

 

 

Also, a "carriage return <CR>" termination character is "optional" but I would tack it onto the end anyway, because...

 

From the manual:

Optionally, a carriage return may be used to indicate the end of a transmitted string. A received carriage return will cause the pump to immediately respond to the received command, and may help speed communications.  (Italics are mine.)

 

They don't spell it out, but any character used to "indicate the end of a transmitted string" is a termination character.  And again, the manual not being explicit, implies that not using the termination character will cause the instrument to wait around before acting on the command.  So I'm thinking it would be a lot more effiicient using a <CR> for your termination character.  Why wait around when you don't have to?  it may not matter much now, but even waiting a fraction of a second longer than you have to could turn a 30 minute test into a 45 minute test.  I once reduced two day (overnight, finishing in the morning) test into 6 hours just by optimizing the reads and writes to wait only as long as they needed to wait.

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 65 of 114
(594 Views)

Note that we've been down the path of adding a termination character to a write, but to re-iterate, it's easier just to explicitly tack it on to the end of the command rather than trying to get LabVIEW to add it on for you.

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 66 of 114
(589 Views)

I see.

 

I've already added a READ functions to every WRITE I've got. 

 

I'll try to add a cariage return to my command as well. would you have an example of that in one of your VI ? 

 

(I am asking for a lot 😄 ❤️ )

 

Flo

0 Kudos
Message 67 of 114
(582 Views)

@ICCR-Lab wrote:

I see.

 

I've already added a READ functions to every WRITE I've got. 

 

I'll try to add a cariage return to my command as well. 


Since probably all your commands are queries, that should be fine.  Unfortunately I cannot make specific recommendations because my LabVIEW version is too old.

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 68 of 114
(576 Views)

I can't try my modified code until Thursday/Friday, But i'll make sure to update you on that.

 

I will check on how to add tha cariage return 🙂

 

Flo

0 Kudos
Message 69 of 114
(571 Views)

@ICCR-Lab wrote:

I can't try my modified code until Thursday/Friday, But i'll make sure to update you on that.

 

I will check on how to add tha cariage return 🙂

 

Flo


Right click on the constants and make them display \codes mode.  Then enter a \r at the end of the constant.  (I also recommend turning on the display mode indicator so that it is obvious that the displayed constant is in the \code display mode.

0 Kudos
Message 70 of 114
(560 Views)