Today I'm going to show you how to control your instrument using LabVIEW without a driver.
When will you use this? Sometimes instruments don't come with a driver. And, in other instances,
drivers don't let you take full control of everything that the instrument has to offer.
Let's get started with a blank VI. You should be looking at your untitled front panel. What
we want to be looking at is the block diagram. So if you go to Window and click Block Diagram,
this is the page we want to start at. Now if you right-click and pull up your palette
I clicked the little down arrow here. We want to go to Instrument I/O, and then you want to
go to VISA. And I suggest pinning this to your window here. And, basically, what we're going to
be doing is sending SCPI commands, which means Standard Commands for Programmable Instrumentation,
to a 33522A function generator from Agilent. I chose this particular instrument because
it doesn't have a driver yet. There will be one. But, right now, if you want to speak
to this instrument through LabVIEW, you have to use VISA and SCPI. Alright, now let's get
started. The first thing you want to do is open a session. If you go to VISA Open.
Put that over here. Now I go back up. Next, you're going to want a VISA Write, and,
most likely, you're going to want a VISA Read. And then, when you're all done, you want to
close the session to the instrument. So these are kind of the four main building blocks
that are commonly used when using VISA. Now if we go over to the VISA Open, this tab right
here is where you pick your instrument. If you right-click on that first tab, and you
go to control, it'll create a VISA resource name. Now if we look at the front panel,
You can see that we can select our instrument now. I clicked the little down arrow 33522A.
Now I'm going to go back to the block diagram. The other thing you need to fill in here is
this error in(no error). If you right-click again and go to Create, and again pick Control,
it creates a control for this error in(no error), and you'll be done with that for the day, basically.
Now you need to tie your instrument name to the VISA Write and the error in to
the VISA Write. Now the next step is putting in the commands that you want to send to the
instrument. If you right-click and go to Create, you can either do Constant or Control. Control
lets you see it on the front panel. I'm going to go ahead and pick Constant for this one, and
I'm going to move it up here, so I've got a little more room, and make this box a little bigger,
because I'm going to be sending a few different commands. Okay. I went ahead and pasted in
a few SCPI commands. I'll go through this in a little more detail in a few seconds.
As you can see, I ended with a SYST:ERR? query. Since I'm doing this query, I need
to do a Read afterwards. And I'll show you how to connect that up now. So you need to
connect the resource name and then the error out and error in. Now with the Read, you need
to define a byte count for the data that's going to be returned. If you right-click, go
to Create, and choose Constant I'm going to enter 1024, then go ahead and do VISA resource out,
do error out. Now when you do a read, you're going to want to see the result. So on this Read
buffer, right-click, go to Create, and you want to create an indicator. I'm going to give
it a new name of Error. And this indicator will show up on the front panel. If I go to
the front panel, I can see, right over here, the results of the error query would show
up right here. I'm going to go ahead and make this a little bigger. Let me go back to the
block diagram. Okay. Now we're ready to run. I'm going to go ahead and push Go and look at
the front panel here. Alright. We've got No Error, so that's good. Now if we take a quick
look at the SCPI commands here, you can see that I'm setting the function generator up
on Channel 1 to have a function of SIN. I'm setting the frequency to 1 kHz. I'm setting
the units to VPP, and then I'm setting the amplitude to 2 VPP.
I'm using OFFSET 0. And then I'm telling the output on Channel 1 to expect a load of
50 ohms, and then I'm turning OUTPUT1 ON. At the end of it, I'm sending a SYST:ERR?,
just to make sure I didn't make any mistakes in my SCPI commands. When you create a string
like this, you need to put a leading colon in front of the root commands that follow
*RST. This indicates to the parser that you're starting a new root command. The 33522A is
a two-channel box, and you designate Channel 1 and Channel 2 by using SOURCE1. This is
the root command in this instance. If I put SOURCE2, I'd be talking to Channel 2.