Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Timout error on simple VISA query in LabviewNXG 5 with HMC8043

Solved!
Go to solution

Hi all,

 

I'm very new to Labview and I'm working through various videos and training courses.  I believe I have LabviewNXG and NIVISA 20 installed correctly but I have found that a bit confusing.

 

I have 4 instruments connected through USB to my Windows 10 Pro laptop.  These appear as USBTMC devices.  In NI Max (and SystemDesigner) I can see these 4 devices and I can use the VISA test panel to send SCPI commands to each of them successfully.  The HMC4083 (PSU) does require a \n terminator on a command to work correctly, the other instruments do not.

 

In LabviewNXG I opened the VISA Simple Query.gvi example which can be used to send a SCPI command to a named test instrument.  This works for 3 of my test instruments without a problem.  The HMC8043 is sent a command (*IDN?\n) and I see a message pop up on the device's UI to tell me it has received it (the specific identification command.)  The read always results in a timeout error.

 

I have tried amending the Instrument profile in the .gvi project to set "Termchar EN" to true and use the TermChar (I don't know what to hook that too but it defaults to \n.)  I've pasted an image below.  This doesn't impact the other 3 instruments but the HMC8043 still has a timeout error on the read.

Screenshot 2020-06-15 at 15.46.53.png

 

 

Screenshot 2020-06-15 at 15.50.25.png

There is a white paper provided by Rohde & Schwarz which has this to say:

 

*Note4 - Termination Character '\n'

'\n' is a Linefeed (LF) termination character, hexadecimally represented as 0x0A. It serves as message termination character.

In case of RawSocket and Serial connection, for VISA Write operations you always have to terminate strings with the LF character, because that is the only way to tell the instrument that message has ended. To recognise the end of the response in VISA Read operations, you need to set the VISA attributes VI_ATTR_TERMCHAR_EN to TRUE and VI_ATTR_TERMCHAR to 0x0A. Otherwise, although VISA Read receives correct response, it finishes with timeout error since it still expects more bytes to arrive.

Some instruments require the LF regardless of the connection type. In any case, sending the message with the LF at the end is the most universal and always works properly.

According the SCPI standard, instruments must terminate responses with LF. In our example above, notice the LF at the end of the identification string response in the NI Visa Test Panel. RsVisaTester does not display white characters, but you can see them in the RsVisaTraceTool log.

 

I don't know if NI Visa automatically handles the TermChar as it works with the HMC8043 irrespective of any IO settings.  I've attached an image of the IO settings and the commands work irrespective of the Enable Termination Character setting.

 

Screenshot 2020-06-15 at 15.54.02.png

 

Gut feel tells me it's a simple setting in my VI project but I've searched and tried various properties in the Instrument Node but to no avail, and now I'm lost for other things to try.

 

EDIT: I ran a IO Trace on both the NI VISA request which works (lines 1 to 4) and the Simple VISA Query which doesn't (remaining lines).  The output is attached.

 

Thanks

 

Andrew

0 Kudos
Message 1 of 6
(2,568 Views)
Solution
Accepted by topic author andrewDJ

Hi andrewDJ,

 

you are sending *IDN?\n - literally. By that, I mean \n are in your query 2 characters 0x5C 0x6E.

You need to send 0x0A. Switch the string display to '\' codes

 

Cheers,

Milo

0 Kudos
Message 2 of 6
(2,524 Views)

Thanks Milo - seems obvious now you point it out.  So today I toggled the "Show Escape Sequences" property for the string input and it worked.  Great.  And then to check, I unset that property and it still worked.  Further, today, I don't need to add the "\n" to the command at all for the HMC8043 and it works (irrespective of that property value.)  That's in the Simple VISA Query VI; in VISA Test Panel I still need the \n for that instrument.

 

The only difference between today and yesterday is that I've rebooted the machine and turned off the instruments overnight. It's very confusing.

 

EDIT: So I closed the project without saving anything and re-opened the example.  I tried it without setting that property (making no changes) and it failed to work - timeout error.  I set the property and ran it and it works if I append \n and fails with a timeout if I don't. If I unset that property, it fails to work; set it, it works with \n.  This is completely different behaviour from when I first ran it this morning, but what I would expect to happen given your reply.  I've neither rebooted or power cycled the instrument.  

 

Something is happening that I'm failing to grasp.  I'm glad it's working obviously, but I would like to understand why this behaviour.

0 Kudos
Message 3 of 6
(2,516 Views)

To have the HMC04x working correctly with VISA USB-TMC, use these settings:

TermCharEnable ON

TermChar 0x0A

 

Send commands with \n at the end.

Strip the responses of trailing \n.

 

BR

Milo

0 Kudos
Message 4 of 6
(2,509 Views)

That's what I was trying yesterday - you can see the changes I made to the VI Instrument Properties in one of the images I attached, and I confirmed these were set in the captured IO Trace.  It didn't work yesterday even with these set.

 

This morning, first attempt, I did not have these set and it worked irrespective of the use of \n and the Show Escape Sequences property for the command string; second attempt (after reloading the example project to start from scratch) without TermCharEnable/TermChar properties it would only work with the Show Escape Sequences property set AND using \n.  

 

Perhaps it is using TermCharEnable and TermChar under the covers - I could run and check the IOTrace.  Although that doesn't really explain the behaviour I experienced this morning.

 

It's that difference in execution experience that I can't work out.  I expect as I get more used to the way LabviewNXG works it will become clearer but the non-repeatability is confusing.  

 

I'm new to LabviewNXG but a pretty seasoned developer and I'm sat here thinking "Milo will never believe I haven't done something else, even by accident, because I wouldn't", but I swear that the two attempts this morning were from a load of the original, unmodified example project 🙂

 

Thanks anyway

0 Kudos
Message 5 of 6
(2,504 Views)

Keeping the IO Trace open and recording is always a good idea, you can check what is really sent / received

0 Kudos
Message 6 of 6
(2,501 Views)