Examples Of Tcl Programs; Using Analog I/O For Motion; Configuration; Description - Newport XPS-Q8 Manual

Universal high-performance motion controller/driver
Table of Contents

Advertisement

XPS-Q8
7.0

Examples of Tcl Programs

Please refer to the XPS Programmer's Manual for the list of XPS API's that are used
with Tcl.
7.1

Using analog I/O for motion

7.1.1

Configuration

Group type
XY
7.1.2

Description

This example opens a TCP connection, kills the XY group, then initializes and homes
the group. Five relative moves of 1 unit each are commanded to the group. Then, the
value of the GPIO2 analog input is read in a continuous loop and sent to the redirected
stdout (refer to Section 4, Principle of a Tcl script redirection to a telnet session) as
long as the voltage of the analog input is greater than 0.2 volt. While above 0.2 volts,
absolute moves are commanded to both axes: the X positioner moves correspond to the
voltage value of the analog input, and the Y positioner moves correspond to the
opposite of the voltage value of the analog input. When the GPIO2 input voltage is
equal to or less han the limit of 0.2 volt, the final move and display occurs. Finally the
program ends by closing the socket.
If the voltage is less than 0.2 volt during the first reading, the program goes directly to
the end without displaying the I/O value or absolute moves of the XY group.
Please see the Section 6, Proposed function for error handling for the code of the
procedure DisplayErrorAndClose.
7.1.3

Tcl code

# Set channel's name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if
{$tcl_argv(0) != 0} {
set
telnetOut [ open "/dev/$tcl_argv(0)" r+]
else
}
{
set
telnetOut stdout
}
# Initialization
set
60
TimeOut
set
group "alignstation"
set
axis1 "alignstation.middle"
set
axis2 "alignstation.base"
set
analogin "GPIO2.ADC1"
# Open socket
set
code [catch "OpenConnection $TimeOut socketID"]
if
{$code != 0} {
puts
$telnetOut "OpenConnection failed => $code"
# Force transfer to channel's output buffer
flush
$telnetOut
Number
Group name
1
alignstation
23
Tcl Manual
Positioner name
alignstation.middle and
alignstation.base
EDH0307En1041 — 10/17

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents