Tcl ADB I/O documentation

version 1.0
June 13, 1999
Michael Halle
mhalle@media.mit.edu

Tcladbio is a Tcl extension for interfacing to the ADB I/O data acquisition and control box from Beehive Technologies, Inc. The ADB I/O system provides four relay switches, up to four digital I/O ports, and up to four analog inputs, all controllable by the ADB bus on Macintosh computers. An additional device is available which provides a USB to ADB converter.

Tcl is an interpreted, embeddable scripting language that runs on Unix,Windows, and the Mac. Tcl is freely available from Scriptics. Tcl's UI system, Tcl/Tk, provides a powerful, easy-to-use mechanism for developing cross-platform user interfaces. Tcl/Tk also provides network facilities so that devices can be controlled remotely. In fact, using Scriptics' Tcl-based http server, the ADB I/O box and Tcladbio can be the basis of a web-based data acquisition system.

Tcladbio allows access to all of the ADB I/O control facilities from Tcl. The status of the device can be queried or set. Tcladbio is implemented on top of a C library based on the one provided by Beehive. Tcladbio runs on Macs with 68020 or higher processors or PowerPCs.

Download

Tcladbio1.0dist.sit.hqx

Installation

Installation is simple.

First, install Tcl/Tk, version 8.0.5 or higher, on your Mac.

Then, download and unstuff the Tcladbio distribution.

Finally, place the Tcladbio and ADB I/O shared libraries appropriate for your machine in the "Tool Command Language" folder in your Extensions folder. That's it!

Command syntax

Tcladbio is loaded into the Tcl interpreter with the following command:

package require Tcladbio

This command automatically creates a single Tcl command, adbio, in the interpreter.

The syntax of the Tcl ADB I/O bindings differs a little from that of the bindings for other languages. adbio has three subcommands, which will be described in turn below.

Listunits

adbio listunits [includeadb]

adbio listunits lists the available ADB I/O units on the current machine. The command returns a list of accessible unit numbers. The number of a unit on the bus is configured using jumpers inside the ADB I/O box. If the optional third argument includeadb is included, the list consists of pairs of values, where each pair is the unit number and ADB address of the device.

In case of error, listunits returns the numerical error from the ADB I/O box.

Set

adbio set flags....

adbio set controls the port configuration and values of the ADB I/O ports. The command has an extensive syntax; not all options work on all ports. In case of error, adbio set returns a numerical error code. Option flags are from the following list ([]'s indicate optional arguments):

-port <a|b>
Specifies the ADB I/O port to control. Must be either "a" or "b".

[-unit <unitnum>]
If specified, a given unit is selected. Units are numbered from 1 to 4. The default is 1.

[-channel <chan>]
Selects the channel of the device to set. If specified, only one channel value will be set. If not specified, all channels on the given port will be set. Channels are numbered from 1 through 4.

[-value <val>]
Sets the value of a given channel or channels. If a channel number is give, <val> is a single integer number. If a channel is not specified, <val> can be either one number of a list of four numbers. If <val> is a single number, that number applies to all channels . If <val> is a list, each value in the list applies to a channel (the first value in the list is applied to channel number 1, and so on). If a value is not specified, the current value of the channel is used.

[-direction <dir>]
Configures a port for input or output. Just like with -value, <dir> can be either one value or a four element list. If a channels' direction is "1", the channel is configured for input. If the direction is "0", it's an output channel . If direction is not specified, the current direction is used.

[-delay <delay>]
Channels on port A can be configured to return to their previous state after a certain amount of time. The -delay flag sets this time. <delay> is given in tenths of seconds, from 1 to 255. If delay is not specified, the channel will not return to its previous state. -delay has an interesting interaction with -value. If -value is specified, the value of the channel will be changed to match <val> and then return to its previous state after delay. If -value is not specified, the current is value is used, so the channel will change to its opposite value after the given delay. <delay> can be either one value or a list of four values, as described under -value.

[-mode <mode>]
Selects the port configuration (port B only) for analog or digital I/O. <mode> has the following values:

Get

adbio get flags....

adbio get returns the value of a given channel, or the configuration of an entire port. Any error results in a numerical error code being reported. Flags are from the following list:

-port <a|b>
Specifies which port to query. The port must be either "a" or "b".

[-unit <unit>]
Specifies which ADB I/O box to query (see the description under set).

[-channel <channel>]
Specifies the channel on the given port to query. If -channel is given, adbio get returns a single value, the value of the given channel. If -channel is not given, adbio get returns a list of nine elements, including the values of all four channels of the given port, the direction of the channels, and the mode of the port (see description of these values under set).

Copyright

Tcladbio is Copyright 1999 Michael Halle. Tcladbio is not public domain. Tcladbio is available, free of charge, for any purpose, as long as the original copyright notices are left intact. Do with it what you will, just don't represent it as your own.This software is provided "as is," without warranty, and without any guarantee of performance.