This is version 1.
It is not the current version, and thus it cannot be edited.
[Back to current version]
[Restore this version]
A Simple Driver Example
In this simple example the programmer does not need to define
action scripts. The needed scripts are already in stdsct.tcl.
Before presenting the driver, we look at the command we need
in the configuration file for any device using this driver:
makenv tem ls336
or, if for some reason you want to give the name of the controller
explicitely,
makenv tem ls336 _tem
This command looks if the driver script ~/sea/tcl/drivers/ls336.tcl
exists, if not, it tries to look for a driver of an older type.
It remembers the object name (tem) and the controller name (_tem).
If no controller name is given an underscore character is prepended
to the object name to set the controller name.
Now we look at the driver file ~/sea/tcl/drivers/ls336.tcl:
namespace eval ls336 {} {
}
proc stdConfig::ls335 {} {
controller std sendterminator=\r timeout=5
controllerDesc "LakeShore 336 controller"
prop startcmd "*IDN?"
obj LS336 -float rd
prop readcmd "KRDG?A"
prop readfmt "%g"
kids "LS336 settings" {
node set -float wr
prop readcmd "SETP?1"
prop readfmt "%g"
prop writecmd "SETP 1,%g"
}
}
Explanation, line by line
controller std sendterminator=\r timeout=5
The controller object is defined with the name specified in
the makenv command, specifying the characteristics
of the protocol.
controllerDesc "LakeShore 336 controller"
A description of the controller object.
prop startcmd "*IDN?"
The command prop creates a property to the last defined
node, which is in this case the controller node.
The property startcmd defines a command which is sent
after initialization. Ideally this is a command requesting
the instrument type, software version number and possibly
a serial number.
After an interruption of the connection, this command is sent
again in order to check that the device is still the same.
obj LS336 -float rd
This creates the object with the name specified in the makenv
command. Its value is a float, and it is a rd node, which means,
it is a value read from the hardware device at regular intervals,
by default every 5 seconds. It is read only.
prop readcmd "KRDG?A"
We define a property of the object node: readcmd.
This is the command to be sent to get the value, in this case
the temperature of channel A.
prop readfmt "%g"
This is the format for converting the result to a floatin gpoint value.
In this case it is a normal floating point value. For
This particular version was published on 14-Sep-2010 07:08:39 UTC by MarkusZolliker.
|