Newport XPS-Q8 Manual

Newport XPS-Q8 Manual

Universal high-performance motion controller/driver
Table of Contents

Advertisement

XPS-Q8
Universal High-Performance
Motion Controller/Driver
Tcl Manual
V1.4.x

Advertisement

Table of Contents
loading

Summary of Contents for Newport XPS-Q8

  • Page 1 XPS-Q8 Universal High-Performance Motion Controller/Driver Tcl Manual V1.4.x...
  • Page 2 Original instructions. No part of this document may be reproduced or copied without the prior written approval of Newport Corporation. This document is provided for information only, and product specifications are subject to change without notice. Any change will be reflected in future publishings.
  • Page 3: Table Of Contents

    XPS-Q8 Tcl Manual Table of Contents 1.0 TCP/IP Communication................1 2.0 Tool Command Language................2 Introduction ..........................2 Tcl scripting language features ....................2 2.2.1 “Hello, World!” example ..................2 2.2.2 Variables ......................3 2.2.3 Command Substitution ..................3 2.2.4 Math Expressions ....................
  • Page 4 XPS-Q8 Tcl Manual 4.0 Principle of a Tcl Script Redirection to a telnet Session ......16 Introduction ........................... 16 “Hello world !” Example ....................... 17 4.2.1 Tcl script example ....................17 4.2.2 Tcl script execution .................... 17 4.2.3 Tcl script execution result .................. 18 5.0 Example of a Tcl Script Redirection to a telnet Session ......
  • Page 5 XPS-Q8 Tcl Manual Jogging and Gathering ......................44 7.9.1 Configuration ..................... 44 7.9.2 Description ......................44 7.9.3 Tcl Code ......................44 7.10 Analog Position Tracking ....................49 7.10.1 Configuration ....................49 7.10.2 Description ....................... 49 7.10.3 TCL Code ......................49 7.11...
  • Page 6 XPS-Q8 Tcl Manual EDH0307En1041 — 10/17...
  • Page 7: Tcp/Ip Communication

    XPS-Q8 NOTE This manual describes how to use Tcl scripts with the XPS-Q8 Controller. Several Tcl script examples have been provided to help illustrate key features of the XPS- The Tcl drivers for the XPS-Q8 Controller have been developed for Tcl 8.4.19 interpreter and includes all XPS-Q8 functions.
  • Page 8: Tool Command Language

    XPS-Q8 Tcl Manual Tool Command Language Introduction Tcl is short for Tool Command Language. Tcl commands perform a variety of functions, such as: output a string, compute a math expression, or display a widget. Tcl casts everything into the mold of a command, even programming constructs like variable assignments and procedure definitions.
  • Page 9: Variables

    XPS-Q8 Tcl Manual 2.2.2 Variables command is used to assign a value to a variable. It requires two arguments: The first is the name of the variable, and the second is the value. Variable names can be any length, and case is recognized. In fact, you can use any character in a variable name.
  • Page 10: Math Expressions

    XPS-Q8 Tcl Manual 2.2.4 Math Expressions The Tcl interpreter itself does not evaluate math expressions. Tcl just performs expr grouping, substitutions and command invocations. The command must be used to parse and evaluate math expressions. Example 1–4: Simple arithmetic. expr ⇒...
  • Page 11: Grouping With Braces And Double Quotes

    XPS-Q8 Tcl Manual Example 1–8: Quoting special characters with backslash. dollar \$foo ⇒ $foo x $dollar ⇒ $foo Only a single round of interpretation is done. The second set command in the example above illustrates an important property of Tcl. The value of dollar does not affect the substitution performed in the assignment to x.
  • Page 12: Square Brackets Do Not Group

    XPS-Q8 Tcl Manual declarations. Double quotes are useful in simple cases like the puts command shown previously. Another common use of quotes is with the format command. This is similar to the C printf function. The first argument to format is a format specifier, which often includes special characters like newlines, tabs, and spaces.
  • Page 13: Grouping Math Expressions With Braces

    XPS-Q8 Tcl Manual Grouping before substitution. The point of this example is to show how the grouping decision for puts’s second argument is made, before the command substitution is done. Even if the result of the nested command contained spaces or other special characters, they would be ignored for the purposes of grouping the arguments to the outer command.
  • Page 14: A Factorial Example

    XPS-Q8 Tcl Manual expr of many math functions supported by the command. The variable c is local to the procedure; it is defined only during execution of Diag. Variable scope is discussed further in Section 7. It is not really necessary to use the variable c in this example. The...
  • Page 15: More About Variables

    XPS-Q8 Tcl Manual while put opening curly braces on the line after a or an statement, you must escape the newline with a backslash: while {$i < $x} \ product ... Always group expressions and command bodies with curly braces.
  • Page 16: Funny Variable Names

    XPS-Q8 Tcl Manual ⇒ var name ⇒ var $name ⇒ the value of var This is a somewhat tricky example. In the last command, $name gets substituted with var. Then, the command returns the value of var, which is the value of var.
  • Page 17: Using Info Exists To Check Whether A Variable Exists

    XPS-Q8 Tcl Manual 2.2.9.3 Using info exists to check whether a variable exists info exists The existence of a variable can be tested with the command. For incr example, because requires that a variable exist, you might have to test for the existence of the variable first.
  • Page 18: Comments

    XPS-Q8 Tcl Manual [expr {sqrt(2.0)}] At this point the value of x is a double-precision floating point value, just as you would expect. If you do this: [expr $x * $x] then you may or may not get 2.0 as the result! This is because Tcl will substitute $x...
  • Page 19: Fine Points

    XPS-Q8 Tcl Manual Grouping decisions are made before substitutions are performed, which means that • the values of variables or command results do not affect grouping. sign, $, causes variable substitution. Variable names can be any length, and • A dollar are sensitive to case used.
  • Page 20: Reference

    XPS-Q8 Tcl Manual This is line two. This is line three." • During command substitution, newlines and semicolons are significant as command terminators. If you have a long command that is nested in square brackets, put a backslash before the newline if you want to continue the command on another line.
  • Page 21: Tcl Script Execution At Boot

    XPS-Q8 Tcl Manual Tcl Script Execution at Boot A Tcl boot script is a program that starts automatically after the controller boot sequence. It is defined in the system.ini configuration file under the GENERAL section. [GENERAL] BootScriptFileName = testarg.tcl BootScriptArguments = arg1, arg2, arg3, arg4, arg5 BootScriptFileName is the file name of the Tcl script.
  • Page 22: Principle Of A Tcl Script Redirection To A Telnet Session

    XPS-Q8 Tcl Manual Principle of a Tcl Script Redirection to a telnet Session Opening a Telnet session is a convenient and easy way to observe Tcl Script responses, as well as pass information to and from the XPS controller. Introduction...
  • Page 23: Hello World !" Example

    XPS-Q8 Tcl Manual “Hello world !” Example 4.2.1 Tcl script example The following Tcl script example shows how to display a message in a telnet window. # 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.
  • Page 24: Tcl Script Execution Result

    XPS-Q8 Tcl Manual 4.2.3 Tcl script execution result The Tcl script execution result is shown on the opened telnet session window: EDH0307En1041 — 10/17...
  • Page 25: Example Of A Tcl Script Redirection To A Telnet Session

    XPS-Q8 Tcl Manual Example of a Tcl Script Redirection to a telnet Session The following example shows the redirection of a Tcl script to a telnet session the telnet window displays the results of the Tcl execution (gets the library and the firmware version).
  • Page 26: Proposed Function For Error Handling

    XPS-Q8 Tcl Manual Proposed Function for Error Handling For convenient error debugging and safe program execution, the response (errors) of each XPS command should be read and tested. To do this, a procedure to “display error and close” can be used. This procedure is defined at the beginning of Tcl scripts. Users simply have to call this procedure after each API.
  • Page 27 XPS-Q8 Tcl Manual # in the telnet window when using APIs # TCLScriptExecuteAndWait or # TCLScriptExecuteAndWait puts $telnetOut "$APIName ERROR => $code : TCP timeout" # Force transfer to channel’s output buffer flush $telnetOut # in the web terminal when using API # TclScriptExecuteAndWait tcl_argv(0) "$APIName ERROR =>...
  • Page 28 XPS-Q8 Tcl Manual This way of error management is also used with Tcl scripts that get generated by the Tcl generator, see Terminal of the XPS web interface. The procedure for displaying errors and closing the TCP connection is as described above. The DisplayErrorAndClose...
  • Page 29: Examples Of Tcl Programs

    XPS-Q8 Tcl Manual Examples of Tcl Programs Please refer to the XPS Programmer’s Manual for the list of XPS API’s that are used with Tcl. Using analog I/O for motion 7.1.1 Configuration Group type Number Group name Positioner name alignstation.middle and alignstation alignstation.base...
  • Page 30 XPS-Q8 Tcl Manual else # Kill group set code [catch "GroupKill $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupKill" $telnetOut return # Initialize group code [catch "GroupInitialize $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut...
  • Page 31 XPS-Q8 Tcl Manual flush $telnetOut puts $telnetOut " move axis1: $move1" flush $telnetOut puts $telnetOut " move axis2: $move2" flush $telnetOut # Move axis 1 code [catch "GroupMoveAbsolute $socketID $axis1 $move1”] {$code != 0} { DisplayErrorAndClose $socketID $code “GroupMoveAbsolute” $telnetOut...
  • Page 32: Using Digital I/O For Motion

    XPS-Q8 Tcl Manual Using Digital I/O for Motion 7.2.1 Configuration Number Group name Positioner name Group type alignstation.middle and alignstation alignstation.base 7.2.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...
  • Page 33 XPS-Q8 Tcl Manual # Initialize group code [catch "GroupInitialize $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut return # Home group code [catch "GroupHomeSearch $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch" $telnetOut return # Move group with 5 relative units { set var } { $var <=...
  • Page 34 XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "GroupMoveAbsolute" $telnetOut return # Move axis 2 code [catch "GroupMoveAbsolute $socketID $axis2 -1"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupMoveAbsolute" $telnetOut return else after after 1000 # Wait 1 second and close socket...
  • Page 35: Gpio1 Test

    XPS-Q8 Tcl Manual GPIO1 Test 7.3.1 Description This example opens a TCP connection. It sets the value to 255 to the mask and the output GPIO1.DO, then gets this output value and assigns it to the variable OA. The program sets the value of 255 to the mask and the value of 0 to the output GPIO1.DO, then gets this output value and assigns it to variable OB.
  • Page 36 XPS-Q8 Tcl Manual # Set output of GPIO1 to 0 0"] code [catch "GPIODigitalSet $socketID $output {$code != 0} { DisplayErrorAndClose $socketID $code "GPIODigitalSet" $telnetOut return # Get value of output of GPIO1 and store it in OB code [catch "GPIODigitalGet $socketID $output OB"]...
  • Page 37: Gathering With Motion

    XPS-Q8 Tcl Manual This is what gets displayed on a telnet window for the above example. Gathering with motion 7.4.1 Configuration Group type Number Group name Positioner name Single axis SINGLE_AXIS SINGLE_AXIS.MY_STAGE 7.4.2 Description This example opens a TCP connection, kills the single axis group, then initializes and homes the group.
  • Page 38 XPS-Q8 Tcl Manual Displacement 1000 NbPoints code # Open TCP socket code [catch "OpenConnection $TimeOut socketID"] {$code != 0} { puts $telnetOut "OpenConnection failed => $code" # Force transfer to channel’s output buffer flush $telnetOut else # Kill group code [catch "GroupKill $socketID $Group"]...
  • Page 39 XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "GroupMoveRelative" $telnetOut return # Stop gathering and save data code [catch "GatheringStopAndSave $socketID"] {$code != 0} { DisplayErrorAndClose $socketID $code "GatheringStopAndSave" $telnetOut return # Close TCP socket code [catch "TCP_CloseSocket $socketID"] When pressing the Gathering display button of the terminal window of the XPS web site interface, the following data is displayed: EDH0307En1041 —...
  • Page 40: External Gathering

    XPS-Q8 Tcl Manual External gathering 7.5.1 Configuration Group type Number Group name Positioner name Single axis SINGLE_AXIS SINGLE_AXIS.MY_STAGE 7.5.2 Description This example opens a TCP connection, kills the single axis group, then initializes and homes the group. The program then configures the parameters for the external gathering (data to be collected: ExternalLatchPosition and GPIO2.ADC1 value).
  • Page 41 XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "GroupKill" $telnetOut return # Initialize group code [catch "GroupInitialize $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut return # Home group code [catch "GroupHomeSearch $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch"...
  • Page 42 XPS-Q8 Tcl Manual after 1000 # Stop external gathering and save data code [catch "GatheringExternalStopAndSave $socketID"] {$code != 0} { DisplayErrorAndClose $socketID $code "GatheringExternalStopAndSave" $telnetOut return # Close TCP socket code [catch "TCP_CloseSocket $socketID"] This is what gets displayed in a Telnet window for the above example and when the trigger in receives a signal every second.
  • Page 43: Position Compare

    XPS-Q8 Tcl Manual Position Compare 7.6.1 Configuration Group type Number Group name Positioner name Single axis SINGLE_AXIS SINGLE_AXIS.MY_STAGE 7.6.2 Description This example opens a TCP connection, kills the single axis group, then initializes and homes the group. With an absolute move, the positioner moves to the start position –15.
  • Page 44 XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "GroupKill" return # Initialize group code [catch "GroupInitialize $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" return # Home group code [catch "GroupHomeSearch $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch"...
  • Page 45: Master-Slave Mode

    XPS-Q8 Tcl Manual # Close TCP socket code [catch "TCP_CloseSocket $socketID"] Master-Slave Mode 7.7.1 Configuration Group type Number Group name Positioner name Single axis SINGLE_AXIS SINGLE_AXIS.MY_STAGE XY.X and XY.Y 7.7.2 Description This example opens a TCP connection, kills the Singles Axis group and the XY group.
  • Page 46 XPS-Q8 Tcl Manual return # Initialize single axis group code [catch "GroupInitialize $socketID $SlaveGroup"] {$code != 0} { DisplayErrorAndClose $socketID $code "Single axis GroupInitialize" $telnetOut return # Home single axis group code [catch "GroupHomeSearch $socketID $SlaveGroup"] {$code != 0} { DisplayErrorAndClose $socketID $code "Single axis...
  • Page 47 XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "SingleAxisSlaveModeEnable" $telnetOut return # Move master positioner # (the slave must follow the master in relation to a ratio) code [catch "GroupMoveRelative $socketID $MasterPositioner $Displacement"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupMoveRelative" $telnetOut...
  • Page 48: Jogging

    XPS-Q8 Tcl Manual Jogging 7.8.1 Configuration Group type Number Group name Positioner name XY.X and XY.Y 7.8.2 Description This example opens a TCP connection, kills the XY group, then initializes and homes the group. It enables the jog mode and sets the parameters to move a positioner in the positive direction with a velocity of 10 units/s for 1.5 seconds.
  • Page 49 XPS-Q8 Tcl Manual code [catch "GroupInitialize $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut return # Home group code [catch "GroupHomeSearch $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch" $telnetOut return # Enable jog mode (group must be ready)
  • Page 50: Jogging And Gathering

    XPS-Q8 Tcl Manual return # Disable jog mode # (constant velocity must be null on all positioners from group) code [catch "GroupJogModeDisable $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupJogModeDisable" $telnetOut return # Close TCP socket code [catch "TCP_CloseSocket $socketID"]...
  • Page 51 XPS-Q8 Tcl Manual C "XY.X.SetpointVelocity" D "XY.X.SetpointAcceleration" Event "Immediate" Action "GatheringRun" # Open TCP socket code [catch "OpenConnection $TimeOut socketID"] {$code != 0} { puts $telnetOut "OpenConnection failed => $code" # Force transfer to channel’s output buffer flush $telnetOut else...
  • Page 52 XPS-Q8 Tcl Manual # Get gathering current acquired point number code [catch "GatheringCurrentNumberGet $socketID Num Max"] {$code != 0} { DisplayErrorAndClose $socketID $code "GatheringCurrentNumberGet" $telnetOut return else puts $telnetOut "Maximum possible number of acquisition per type of data: $Max" # Force transfer to channel’s output buffer...
  • Page 53 XPS-Q8 Tcl Manual 10 50 -10 code [catch "GroupJogParametersSet $socketID $Moteur 50"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupJogParametersSet" $telnetOut return puts $telnetOut " X positioner going in positive direction during sec" flush $telnetOut puts $telnetOut " Y positioner going in negative direction during sec"...
  • Page 54 XPS-Q8 Tcl Manual # Set jog parameters to stop the positioners => constant # velocities are null 0 50 0 code [catch "GroupJogParametersSet $socketID $Moteur 50"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupJogParametersSet"$telnetOut return puts $telnetOut " X and Y positioners stopped"...
  • Page 55: Analog Position Tracking

    XPS-Q8 Tcl Manual 7.10 Analog Position Tracking 7.10.1 Configuration Group type Number Group name Positioner name XY.X and XY.Y 7.10.2 Description This example opens a TCP connection, kills the XY group, then initializes and homes the group. It sets the parameters for the position analog tracking functionality (positioner, analog input, offset, scale, velocity and acceleration) and enables the analog tracking mode.
  • Page 56 XPS-Q8 Tcl Manual # Initialize group code [catch "GroupInitialize $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut return # Home group code [catch "GroupHomeSearch $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch" $telnetOut return # Set analog tracking parameters...
  • Page 57: Backlash Compensation

    XPS-Q8 Tcl Manual 7.11 Backlash Compensation 7.11.1 Configuration Group type Number Group name Positioner name Single axis SINGLE_AXIS SINGLE_AXIS.MY_STAGE 7.11.2 Description This example opens a TCP connection and kills the single axis group. It enables the backlash compensation capability (for this the controller must be in the not initialized state).
  • Page 58 XPS-Q8 Tcl Manual # Kill group code [catch "GroupKill $socketID $Group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupKill" return # Enable backlach compensation ################################################################# # CAUTION : # Group must be “not initialized” and Backlash>0 in the # “stages.ini” file...
  • Page 59: Timer Event And Global Variables

    XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "GroupMoveRelative" $telnetOut return # Disable Backlash (if you want to do trajectory, jogging or # tracking) # CAUTION : to enable backlash, you must call “GroupKill” or # “KillAll” to come back in “not initialized” status...
  • Page 60 XPS-Q8 Tcl Manual # Initialization TCPTimeOut code 0.0001 ISRPeriodSec Positioner "SINGLE_AXIS.MY_STAGE" TimerName "Timer1" TimerPeriodSec EvtParam Action "ExecuteTCLScript" TCLFile "MyScript.tcl" TCLTask "MyTask" GlobalVarNumber Value # Open TCP socket code [catch "OpenConnection $TCPTimeOut socketID"] {$code != 0} { puts $telnetOut "OpenConnection failed => $code"...
  • Page 61 XPS-Q8 Tcl Manual MyScript.tcl # 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.
  • Page 62: Tcl Script With Input Arguments

    XPS-Q8 Tcl Manual DisplayErrorAndClose $socketID $code "EventRemove" $telnetOut return else puts $telnetOut "Timer event deleted" flush $telnetOut # close TCP socket code [catch "TCP_CloseSocket $socketID"] This is what gets displayed on a Telnet window for the above example. For details...
  • Page 63: Tcl Code

    XPS-Q8 Tcl Manual Please see the sections: 4 Principle of a Tcl script redirection to a telnet session. 6 Proposed function for error handling. 7.13.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.
  • Page 64 XPS-Q8 Tcl Manual # Initialize group code [catch "GroupInitialize $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupInitialize" $telnetOut return # Home group code [catch "GroupHomeSearch $socketID $group"] {$code != 0} { DisplayErrorAndClose $socketID $code "GroupHomeSearch" $telnetOut return # Loop until the number of cycles { set i 0} {($i <...
  • Page 65: Service Form

    XPS-Q8 Tcl Manual Service Form Your Local Representative Tel.: __________________ Fax: ___________________ Name: _________________________________________________ Return authorization #: ____________________________________ (Please obtain prior to return of item) Company:_______________________________________________ Address: ________________________________________________ Date: __________________________________________________ Country: ________________________________________________ Phone Number: __________________________________________ P.O. Number: ____________________________________________ Fax Number: ____________________________________________...
  • Page 66 Visit Newport Online at: www.newport.com North America & Asia Europe Newport Corporation MICRO-CONTROLE Spectra-Physics S.A.S 1791 Deere Ave. 9, rue du Bois Sauvage Irvine, CA 92606, USA 91055 Évry CEDEX France Sales Tel.: (800) 222-6440 Sales e-mail: sales@newport.com Tel.: +33 (0)1.60.91.68.68 Technical Support e-mail: france@newport.com...

Table of Contents