Using NI’s LabView with ASI Controllers
Both ASI’s MS-2000 and TG-1000 controllers communicate with the host computer by sending and receiving serial commands (most often the physical wire is a USB cable, but on the host computer a serial COM port is created). Using the controller in National Instruments’ LabVIEW™ software is as simple as sending appropriate commands over the serial port. ASI provides an instrument driver to facilitate this.
Refer to the programming manuals for your controller to see the full serial command set of your controller.
Refer to the programming manuals for your controller to see the full serial command set of your controller. There are a few minor differences between the MS-2000 and TG-1000 command sets, but these VIs can be used for both types of controllers despite containing “TG-1000” in the name.
Installation Contents
This package contains an instrument driver written in LabVIEW™ 2011 to communicate with ASI controllers. Even though ASI’s drivers are not part of National Instrument’s “Instrument Driver Network” they have been designed to act the same way, so these instructions are similar to those found at http://www.ni.com/devzone/idnet/inetinst.htm.
- Locate the instrument driver folder at
\instr.lib folder, where is the install directory. The install directory can be identified from within LabView under Tools >> Options, then under Paths and Default Directory. An example location is C:\Program Files (x86)\National Instruments\LabVIEW 2011\instr.lib. - Exit LabView if it is running.
- Download the driver archive, unzip it, and copy it into the instr.lib folder. The contents of
\instr.lib\ASI TG-1000 should be:
- Examples [example high-level VIs]
- Private [VIs that should not be called directly]
- Public [low-level and mid-level VIs for end use]
- ASI TG-1000 Readme.html
- ASI TG-1000.aliases
- ASI TG-1000.lvlib
- ASI TG-1000.lvproj
- Launch LabView.
- Open any block diagram and open the functions palette. The ASI TG-1000 VIs should be found under Instrument I/O >> Instr Drivers >> ASI TG-1000.
Driver Contents
Much like other instrument or data acquisition VIs, these VIs “pass through” an instrument handle and error wires to make it easy to enforce execution order. The high-level VI should start with Initialize.vi and end with Close.vi,and perform any communication between them using the provided instrument handle.
Feel free to look into the VIs to see how they operate. They are found in the Public folder within instr.lib, though the easiest way to access them is the functions palette under Instrument I/O, then Instr Drivers, then ASI TG-1000.
Only a small subset of controller features is exposed in the provided VIs. However it is easy to make your own VIs using whatever serial commands are required for your application. A full listing of serial commands can be found at Applied Scientific Instrumentation documents (www.asiimaging.com/docs/products/serial_commands).
Please contact ASI if you find bugs or would like to see other features added!
Basic VIs
- Initialize.vi – creates the instrument handle and opens the serial port
- Close.vi – closes the instrument handle and disconnects from the serial port
Action VIs
- Halt all Commands.vi – Sends the controller a halt command
- Move Axis to Position.vi – Moves a single axis to the specified absolute position. Uses internal axis units
- Move Axis Relative.vi – Moves a single axis by a relative amount. Uses internal axis units
- Move Axes to Positions.vi – Moves multiple axes to the specified positions. Uses internal axis units
- Move Axes To Zero.vi – Moves the specified axes to zero, analogous to the home button but only for those axes
- Move to Position from File.vi – Opens a file created by Save Current Position to File.vi and moves to that location. Ignores axes not specified
Status VIs
- Get Current Position.vi – Gets the current position of an axis. Uses internal axis units
- Get Current Positions.vi – Gets the current positions of multiple axes. Uses internal axis units
- Get Axes Status.vi – Gets the status byte for the axis. Use Status Byte to Code.vi to convert that to a user-readable string
- Save Current Position to File.v – Creates a file storing the current position of specified axes, for later use by Move to Position from File.vi
Utility VIs
- Send Serial Command.vi – Sends an arbritrary serial command to the controller and optionally gets the response
- Parse Serial Response.vi – Parses a controller response according to the expected type (e.g. string or number) and command syntax
- Convert Double to String.vi – Converts LabView floating point variable to a string for use with Send Serial Command.vi
- Status Byte to Code.vi – Converts the status byte retrieved by Get Axes Status.vi into a user-readable string
- Axis Enum to String.vi – Converts the enum representation of the axis name (preferred within LabView) to the corresponding string
- Axis String to Enum.vi – Converts a string representation of the axis name to the preferred enum representation
Example High-Level VIs (Not in the Functions Palette)
- Monitor Positions + Console.vi – Uses most or all of the above VIs to perform the following functions:
- continuously query and display axis positions
- move any axis to a new position
- save and recall positions to/from files
- send arbitrary serial command and view the response
- Get Axis Speed.vi – gets the speed of the specified axis. This VI includes Initialize and Close already; remove these when used as part of larger VI.
- Set Axis Speed.vi – sets the speed of the specified axis. This VI includes Initialize and Close already; remove these when used as part of larger VI.
- Get Comm Version.vi – Returns the firmware version (on TG-1000, of the comm card). This is intended to be used within a larger VI which has Initialize and Close, just like the other library VIs.
- Get Build Name.vi – Returns the build name (on TG-1000, of the comm card). This is intended to be used within a larger VI which has Initialize and Close, just like the other library VIs.
- Zero Axis.vi – sets the position of the specified axis to be zero (it changes the coordinate system). This VI includes Initialize and Close already; remove these when used as part of larger VI.
Troubleshooting Hints
To figure out what comm port Windows has assigned the USB to serial adapter so you can set it in the VIs: Open Device Manager and look under Ports (COM & LPT). You should see an entry labeled “USB to UART bridge” that goes away when you unplug the controller’s USB cable. Once you identify the port, set it in LabView.
To rule out problems not related to LabView, make sure that you can communicate with the controller using some other program (e.g. ASI Console or Micro-Manager). This can also serve as a check on the port and baud rate settings.
Only one program can use the serial port at a time, so you if you are using another program to communicate with the controller (e.g. ASI Console or Micro-Manager), be sure to exit it before running LabView.
Make sure that the baud rate is set correctly in Initialize.vi. The default of the LabView driver is 115200 baud which is correct for TG-1000 controllers. For MS-2000 controllers the baud rate is selected by jumpers on the back panel and is most commonly either 9600 baud or 115200 baud. See the MS-2000 Operations manual for details on changing the baud rate.
If the port selection control “VISA resource name” does not show a list of comm ports, make sure that NI-VISA is correctly installed.
Assistance
For assistance with this software, feel free to call (541) 461-8181 ext 118, in the United States and Canada. From outside the United States and Cnada call to (800) 706-2284.
You may also send an e-mail to SUPPORT or Jon Daniels