LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicating with picoammeter via VISA works with Labview example, but not with my own code

Hello,

   I am using Labview 2024 Q3 and I am trying to read from a Keithley 6485 picoammeter. I have tried the provided example "Simple Serial.vi" and I get the following response from the Keithley: KEITHLEY INSTRUMENTS INC.,MODEL 6485,4382273,C01 Jun 23 2010 12:22:00/A02 /J

 

However, I wrote my own version of the Simple Serial.vi which (as far as I can see) provides the same data to the VISA vis, so should work exactly the same, but I get no response from the Keithley. I am communicating via the RS232 link using a CH340 USB to RS232 cable. I have tested this using the NI VISA Interactive Control and all seems well. 

Could it be that the Simple Serial.vi is using somewhat old versions of the VISA vis, whereas my version (Simple VISA) is using more recent VISA vis and they are failing somehow ?

 

I have attached the Simple Serial.vi example and my Simple VISA.vi.

 

Any thoughts on what might be the issue would be welcomed.

Thanks

Chris

 

Download All
0 Kudos
Message 1 of 3
(195 Views)

The main difference between your two VIs is the display style of your command string.  The Simple Serial example has the display style for the command set to \ Codes. Your version uses Normal display style.

 

What this means is with a normal display style, you are sending the literal 2 character '\' and 'n'. When it is set to \ Codes, the \n is an escape code that means a single byte: a Line Feed. Because you are not terminating your command with a line feed, the instrument does not properly read your command.

 

Additionally, DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

 

The way VISA Read works, as you have it configured, is to stop reading when the number of bytes requested has been read or the termination character (default is a Line Feed) has been read. By using the bytes At Port, you create a weird race condition where if the instrument was slow, you will not get the entire reply. Or, just as bad, you waste a lot of time waiting just to make sure you get the full message. The simple solution here is to get rid of the wait and the Bytes At Port and just tell the VISA Read to read more bytes than you expect in a reply. This will allow the VISA Read to return as soon as the termination character is read (to needless waiting) and with the complete rely.

 

For more information, go watch this: VIWeek 2020/Proper way to communicate over serial


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
0 Kudos
Message 2 of 3
(166 Views)

Hello,

    thankyou for your response.

I had been trying to make my version as close as I could to the provided example (Simple Serial.vi). My first manifestation of the program did not include "Bytes at Port", but since the provided example did, then I included it in my vi - otherwise I wouldn't have included it.

 

Also, the provided example also uses "Normal display" not "\ Codes", but I tried that just in case without a good result.

 

I have since tried something else. I copied and pasted the entire Simple Serial.vi (i.e. the provided Labview example) into a new vi. As stated before, the original Simple Serial.vi does work and gives a response from the picoammeter. However, the copy and pasted vi does not. I will persevere !

 

Chris

 

 

0 Kudos
Message 3 of 3
(111 Views)