LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

E4990 Labview control- Problem in Data Acquisition

I am trying to control my Impedance Analyser Keysight E4990A using LabVIEW and I think, I have built the logic completely. But on running the program after connecting to the instrument, it sweeps over a set of frequencies that i have given using a .csv file, and the output file contains only a set of zeroes over all the frequencies. I am trying to compute absoulute impedance and phase. I have also added a delay using flat sequence structure between executing and reading. 

Prateek1_0-1755327743480.png

 

nly. 

0 Kudos
Message 1 of 5
(294 Views)

I have attached the VI for controlling the E4990A. I am also attaching the kind of output it is throwing always... please help me in getting the correct readings.

Prateek1_0-1755328042020.png

 

0 Kudos
Message 2 of 5
(298 Views)

Hello, Prateek.

 

     I have a number of suggestions for your problem with data acquisition from this VISA instrument.

 

     The first thing to suggest is to connect your Instrument to your computer and run MAX, NI's Measurement and Automation Explorer.  Identify the Interface connected to your VISA device and select it.  You should be able to open a Test Panel on the right-hand Pane where you can set the VISA parameters (such as Baud Rate).  Your manual for the Keysight device will tell you most of the settings you need.  If it is like many such VISA peripherals I've used, you send a bunch of Commands, and use a "termination character (typically Line Feed (hex 0A) when you hit the "Enter" key, so you need to specify (when you set up VISA) to use a Termination Character.

 

     Look at the Commands in your manual.  There is probably one that asks the VISA device to "identify" itself.  Go ahead and send it, then do a Buffer Read, which should get you a return String that says something like "Keysight E4990".  Note that a single Read, because you are using a Termination character, will read (within reason!) as many characters as your device sends until it finishes the message by sending the <LF>.

 

     If this works, go ahead and try to get it to send you, say, 10 readings of "whatever" (you may need to give it multiple commands to set it up and then say "Go").  Do another Buffer Read -- you should get either the first of 10 (in which case you need to do 9 more Reads) or all 10 with (or without!) some "separating character".  You'll at least be able to verify that you can "talk to" your device and get data back from it.

 

     Now all you have to do is write LabVIEW code to do the same thing you just did "manually".

 

     So here's the next piece, about your LabVIEW code.

  • You know data flows in wires.  A very important wire is the Error Line, which goes through the bottom terminals of most sub-VIs and functions.  You should (almost) always connect them together from an Error Terminal on the input edge of the surrounding Case, While, Event, or similar loop to the output edge.
  • The Sequence construct is (almost) not necessary if you use the Error Line.  The only exception, of course, is the Wait function, which has no Error In/Out.  I don't remember if LabVIEW 2017 has "vim", but look on the Timing Palette and see if there is a "Stall Data Flow" function that you can put on any wire (specifically, on the Error Line) and which "ties" a Wait to the wire that runs through it.  Makes the code much easier to read/understand, particularly when you make sure the Error Line runs strictly horizontally.
  • You bring out "Impedance" and "Phase" by using two Index Array functions.  One of my first posts on the LabVIEW Forums, some kind soul told me I could take one Index Array, "pull down" on the bottom edge, and I'd get (without wiring anything on the left side!) two outputs that were the first two elements of the input Array.  Wire "Impedance" to the first, "Phase" to the second.  Much neater.
  • START and STOP are "rectangular Booleans", which means they have a Mechanical Action called "Latch when Released".  This means once you push it, it stays "pushed" until you read it, when it returns to its default value.  So your "Start" button will have the (strange) function that if you push it once, it runs your code, but stays "down", so if you push it again, it runs your code again, and pops up.  Is this what you want?  [I expect the answer is "No"].
  • A general rule for such Boolean variables (and maybe other "Value Changed" variables in Event Structures) is the controls are placed inside their respective "Value Changed" Event (I think I do this at least in 95% of my use cases).
  • Suggestions to help you (and others) "read and comprehend" your LabVIEW code.
    • (Almost) always use the Error Line.
    • Use Sub-VIs to "hide the messy details" when it gets too big/busy.
    • Keep wires as straight/horizontal as possible.
    • Don't display Controls and Indicators as Icons -- too big and clumsy.  [Turn off by going to Tools, Options, Block Diagram, and turn off "Place front panel terminals as icons".]
    • Learn about State Machines.  Most of my Project have a main While Loop running a Channel Message Handler (a variety of State Machine) with an Event Loop running in parallel with it above the State Machine and sometimes some concurrent State Machines handling other multi-step tasks, such as managing plotting and saving the data (Producer/Consumer design).

Bob Schor

 

 

 

 

0 Kudos
Message 3 of 5
(235 Views)

Hello! Thank you for getting back to me. I have already tried using the test panel and sending manual commands. In that case, the readings were correctly measured. After that, I removed the instrument drivers wherever I used them and replaced them with VISA. Then I assigned the terminal character property as per your instructions. You can have a look, still I am getting the same zero readings. Please, suggest something. 

Prateek1_0-1755494368647.png

 

0 Kudos
Message 4 of 5
(220 Views)

Hello, Prateek.

 

     Thank you for including your code.  The first three functions in your VI, which might be something related to an Instrument Driver, are not recognized by my system, and are clearly not the generic VISA Drivers.

 

     On the Block Diagram, open Instrument I/O.  From there, open VISA, then Bus Specific, then Serial, then Configure Port.  This is where you set the VISA Parameters (as you did in the Test Panel in MAX.

 

     Note that the path through the Block Diagram is for my installation of LabVIEW 2021.  The menus might be slightly different in LabVIEW 2017.

 

     Please remove the Frame Sequence structure inside the For Loop.   Please straighten out the Error Line and (as much as possible) the other "horizontal" wires.  Please get rid of so much blank space between functions -- everything should (ideally) fit on a single laptop screen.  What are the two "0" characters that I cannot delete at the upper left of the Event Loop?  They seem to be related to (unwired?) constants on the Block Diagram.

 

     Aha!  I found your error.  I decided to "clean up" your Block Diagram.  Look inside the For Loop with all the VISA commands, and look at the first two functions in that Loop, a Format into String and a VISA Write.  Which one comes first?  [The answer is you don't know, but probably the VISA Write, with an empty string as its input].  Why is this?  Where did you not use the Error Line?  What if you properly did use the Error Line?

 

     There are some cases when you don't need to use the Error Line, but failing to use it can (and did) cause  your code to fail.  I'm attaching an Image of my cleaned-up version of your code.  The blocks marked with ? are where you need to put the VISA routines that you've demonstrated seem to work, and you should be able to find (by comparing this with your code) where the Error Line was missing (and probably caused your routine to fail).  I turned off the "Icon" mode for most Front Panel Controls (helps unclutter Block Diagram), and other comments include some (possibly wrong) assumptions on my part.

 

Bob Schor

BS e4990 visa.png

 

 

 

0 Kudos
Message 5 of 5
(192 Views)