tclvisa – Tcl binding to VISA API

General Information

tclvisa – a Tcl Extension that provides binding to VISA API.

Tcl is a great scripting platform. I found it very useful in automatization of measurement buildings. It works well in both command line-based utilities and graphical interface programs.

Virtual Instrument Software Architecture (VISA) is, generally speaking, measurement instrument contolling API. It provides unified interface for multimeters, power supplies, oscilloscopes etc.

tclvisa allows accessing VISA functionality from Tcl scripts. As a regular Tcl Extension it is linked dynamically to tclsh, wish or any other Tcl-based application. Then user can work with VISA devices via usual Tcl IO commands like puts and gets.

Quick Overview

Here is a small example of tclvisa usage. In this example we open a VISA instrument, send a command, wait for answer and read it, then print answer to console.
# load tclvisa package into Tcl shell
package require tclvisa

# get handle to default resource manager
if { [catch { set rm [visa::open-default-rm] } rc] } {
  puts stderr "Error opening default resource manager\n$rc"

# open device
set visaAddr "ASRL1::INSTR"
if { [catch { set vi [visa::open $rm $visaAddr] } rc] } {
  puts "Error opening instrument `$visaAddr`\n$rc"
  # `rm` handle is closed automatically by Tcl

# Set proper timeout
fconfigure $vi -timeout 500

# Send command to instrument. New line character is added automatically by `puts`.
puts $vi "*CLS"

# Send command to query device identity string
puts $vi "*IDN?"

# Read device's answer. Trailing new line character is removed by `gets`.
set id [gets $vi]

puts "Identity of `$visaAddr` is `$id`"

# close channels
close $vi
close $rm

Platforms Supported

Hypothetically tclvisa works at every platform that provides:

  1. C compiler;
  2. Tcl library;
  3. VISA implementation.

Actually only platform the tclvisa was tested on is Windows.


All downloads can be found here. The binary installation packages are available for Windows only. Unix users can build the library from sources as usually.

Programmer’s Manual

Click here to download tclvisa Programmer's Manual (PDF).


Please use project forum to ask any questions.

Bugs and feature requests can be posted at project bug tracker.