Writing Code for USB, LAN and GPIB Using an Alias with Visual Basic

Writing Code for USB, LAN and GPIB Using an Alias with Visual Basic


Hi, I’m Bill Griffith, an Application Engineer
with Agilent Technologies. Today we’re going to show you how to use the same program with
three different interfaces without modifying your code. An alias can be used to address
the instrument in your code, and we can update the alias with a new instrument address without
changing the program. This is helpful if your instrument’s IP address is changed, or if
you want to change to different interfaces. I’m going to demonstrate this with a 34411A
multimeter which comes standard with the GPIB interface, USB, and LAN. Let’s get started.
Here in my program is where we need to specify the VISA address. I often put a variable here,
and then cut and paste the address into my program. Let’s go ahead and change this
to the alias DMM1. Now we’ll go to the Agilent connection expert and it will find our DMM
on the GPIB bus, so it’s found the instrument. Here’s the VISA address, and we’re going
to go ahead and create our alias. So I add the alias, DMM1. So now we can go back to
our program and run it with our alias added. So go out, initialize the DMM, and then we’re
going to go and measure a block of readings, and then we can close our connection. So without
modifying our program now we’re going to go ahead and switch interfaces. We’re going
to go ahead and switch to the USB interface. Okay, now we’ve installed the USB cable.
We’ll go ahead and go back to our connection expert and we can only have our alias for
one connection, so I’m going to go ahead and delete our GPIB connection and now the
instrument, you can see it’s been found on the USB connections. We’ll go ahead and
create our alias. We’ll call it DMM1 again. Okay, and here’s the VISA address for the
USB connection that’s using. We’ll go back to our program, we’ll go ahead and
start it, which initializes the DMM. We’ll go out and measure our block of readings,
and then we can go ahead and close our connection. Okay. So one more time. We’ll go back to
our connection expert and we’ll hook up our LAN cable. Okay, now we have our LAN cable
installed. We’re going to go back to our connection expert and we’re going to delete
our USB alias, and then the connection expert has found our instrument on the LAN interface,
so we’ll go ahead and create our alias for it. So DMM1. Okay. And you can see this is
the actual VISA address for the instrument this time. Go back to our program. We’ll
initialize the instrument, and then we’ll measure a block of readings, and then we’ll
close our connection. As you can see, aliases allow us to update our instrument’s addresses
without changing our program code. This is useful if we’re using LAN and we’re on
different subnets and we need to change IP address, or if we want to change an use a
different interface. Thanks for watching.

Danny Hutson

Leave a Reply

Your email address will not be published. Required fields are marked *