LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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


@matt198717 wrote:

Yes replace with a 13, but also you can flush the IO, but you should put a delay after the flush, use the time delay function(Which is in seconds) so you can have data dependancy before the write.  I would suggest about 100ms.


Hi, Matt:

I think you misunderstood about the carriage return thing.  BUT, you reminded me of where the flush I/O thing might come in handy - and that's right after the config 9but before the loop) to clean out anything that might be left over from something previously done.

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 41 of 114
(977 Views)

@billko wrote:

Sorry for confusing you.  The command sent in the VISA Write should have a carriage return attached to the end of it.  The VISA propertynode I think was okay, if not maximally efficient.  😉


Bill,

If i recall correctly, labview wont allow for multiple termination characters? You cant have one for a read and one for a write.  The pump manual only specifies being able to use a CR for the writes, which i agree he should try, but the reads still use a "/".  So he may need to enable term char for reads, disable for writes and then manually attach a CR and leave the "/" as the term char.  OR vice versa?



-Matt
0 Kudos
Message 42 of 114
(976 Views)

@matt198717 wrote:

@billko wrote:

Sorry for confusing you.  The command sent in the VISA Write should have a carriage return attached to the end of it.  The VISA propertynode I think was okay, if not maximally efficient.  😉


Bill,

If i recall correctly, labview wont allow for multiple termination characters? You cant have one for a read and one for a write.  The pump manual only specifies being able to use a CR for the writes, which i agree he should try, but the reads still use a "/".  So he may need to enable term char for reads, disable for writes and then manually attach a CR and leave the "/" as the term char.  OR vice versa?


I believe that Serial End Mode for Writes defaults to (none)?

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 43 of 114
(972 Views)

For some reasons, when I switch off and on the pump, The values entered through Labview are not the one I read from the pump. Looks like something in my code hardwrite those values when I run the code for the first time, and whatever I set on the pump won't stay in the pump memory once switched off.

 

That's wierd.

 

0 Kudos
Message 44 of 114
(967 Views)

We need to see your revised code.  I can't actually see what's inside because I don't have LV 2015 so I can't tell what's going on inside the event structure.  It doesn't appear that you haveything but standard VIs in there, so maybe you could upload the actual VI to the version conversion board?

 

I know this thread is getting a little muddled, so I'll try to straighten out what we should have so far:

 

Rolf's Snippet

Rolf's snippet was almost exactly correct, except he guessed wrong on the VISA Configure Serial Port VI Termination Character.  It sould've been a forward slash.  Plus, he guessed wrong on the command - Q? - but not the terminator - <CR> - (although he really should have shown the display style so we would all know the constant was displaying in '\' Codes Display).

your snippet

Your snippet was ALSO almost exactly correct, except for the aforementioned "unoptimized" part where you used the property node.  Also, you did not include the <CR> (or \r as a backslash code) in your CS command.  And you really don't need the flush inside the loop.  Outside the loop, right after the VISA Configure Serial Port VI, I can make a case for, but not inside the loop.

 

Oops edit: Should have been ASRL End IN nor ASRL End OUT. 
I would just use the VISA Configure Serial Port VI to configure it though.  Just right-click on the Termination Character and enter a number to avoid type casting confusion.

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 45 of 114
(958 Views)

@billko wrote:

 

Rolf's snippet was almost exactly correct, except he guessed wrong on the VISA Configure Serial Port VI Termination Character.  It sould've been a forward slash.  Plus, he guessed wrong on the command - Q? - but not the terminator - <CR> - (although he really should have shown the display style so we would all know the constant was displaying in '\' Codes Display).

 


Just a little trivia first: This example was not meant to be usable verbatim for the OPs problem. It was in response to his request for: Would you have an example from your own work?

And if you look at the snippet, it is in version 2011. No backslash display glyph option there! I did add a comment above though.

 

You can only configure one termination character for both read and write. And you can enable termination character for both directions individually. For receive it will terminate reads on the termination character, for writes it will actually append the termination character. However I never use the automatic termination character mode for writes. It is much clearer to actually append the correct termination character explicitedly to the commands passed to VISA Write. Or I write a wrapper around Write (and sometimes Read) that does this kind of common command manipulation for the device.

 

The use of Flush after the initialization is a common method, it should not be used during normal communication unless you run into errors and want to completely restart the communication (preferably only if you can also reset the device communication with a special command, which for this device would be the # (sharp) character).

Rolf Kalbermatter
Averna BV
0 Kudos
Message 46 of 114
(945 Views)

@rolfk wrote:

@billko wrote:

 

Rolf's snippet was almost exactly correct, except he guessed wrong on the VISA Configure Serial Port VI Termination Character.  It sould've been a forward slash.  Plus, he guessed wrong on the command - Q? - but not the terminator - <CR> - (although he really should have shown the display style so we would all know the constant was displaying in '\' Codes Display).

 


Just a little trivia first: This example was not meant to be usable verbatim for the OPs problem. It was in response to his request for: Would you have an example from your own work?

And if you look at the snippet, it is in version 2011. No backslash display glyph option there! I did add a comment above though.

 

You can only configure one termination character for both read and write. And you can enable termination character for both directions individually. For receive it will terminate reads on the termination character, for writes it will actually append the termination character. However I never use the automatic termination character mode for writes. It is much clearer to actually append the correct termination character explicitedly to the commands passed to VISA Write. Or I write a wrapper around Write (and sometimes Read) that does this kind of common command manipulation for the device. 


Of course, Rolf - but I wanted the user to uderstand that it almost could have been used verbatim.  I wanted to stress just how correct your code was.  😉

 

And you are also exactly correct about everything you said just now about the termination stuff.  It explains exactly why your code would work, where I did not think to go there.

 

Lastly the thing about showing explicit Display Style for non-default display styles is a pet peeve of mine.  By explicitly showing it, there is (within human reason) absolutely no way to misinterpret it.  Same goes for non-default radix for integers, like hexadecimal for instance.  This goes for constants, controls and indicators.  Just one less thing to distract the developer.  IMHO.  I've been known to be a little OCD on occasion.  😄

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 47 of 114
(934 Views)

@billko wrote:

Lastly the thing about showing explicit Display Style for non-default display styles is a pet peeve of mine.  By explicitly showing it, there is (within human reason) absolutely no way to misinterpret it.  Same goes for non-default radix for integers, like hexadecimal for instance.  This goes for constants, controls and indicators.  Just one less thing to distract the developer.  IMHO.  I've been known to be a little OCD on occasion.  😄


I consider a digital constant that uses non-decimal display mode without the radix made visible a programming error. During a code review that definitely warrants a critical remark! Smiley Very Happy

Rolf Kalbermatter
Averna BV
0 Kudos
Message 48 of 114
(931 Views)

@ICCR-Lab wrote:

I've got something maybe: 

 

 

vi cp pump.png

 

47 = my termination character. It seems that if I don't add a VISA Flush I/O Buffer I get it working 1 time every 2 runs.

 

 


- Well written NI LabVIEW applications have block diagrams that are organized and easy for other programmers to read. Try using Automatically Clean Up LabVIEW Block Diagrams so it will be easier and code looks neat. (ofcourse there are some places where it fails but mostly in this case it does well)

Thanks
uday
0 Kudos
Message 49 of 114
(910 Views)

@udka wrote:

@ICCR-Lab wrote:

I've got something maybe: 

 

 

vi cp pump.png

 

47 = my termination character. It seems that if I don't add a VISA Flush I/O Buffer I get it working 1 time every 2 runs.

 

 


- Well written NI LabVIEW applications have block diagrams that are organized and easy for other programmers to read. Try using Automatically Clean Up LabVIEW Block Diagrams so it will be easier and code looks neat. (ofcourse there are some places where it fails but mostly in this case it does well)


He actually did clean it up a lot.  But I think he was not aware of the cleanup button.  😉

 

I have to say that if you use the cleanup button and things look better, you need work on your organization efforts.  😄

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 50 of 114
(907 Views)