get_next_serial(int serial) function takes as a parameter an integer number and returns the smallest serial from a sorted list of opened
controller serials which is strictly greater than the parameter. If there are no such serials a zero is returned.
This function is a convenient shortcut for automatic creation of "axis" type objects without hardcoded serial numbers.
Example:
var
first_serial = get_next_serial(
0
);
var
x = new_axis(first_serial);
var
y = new_axis(get_next_serial(first_serial));
In this example in the first line we obtain a serial, in the second line an axis-type object is created, in the third line we get the next
serial and create an axis for it.
Wait for stop
The command_wait_for_stop(int refresh period) script function waits until the controller stops movement, that is, until the
MVCMD_RUNNING bit in the MvCmdSts member of the structure returned by the get_status() function becomes unset.
command_wait_for_stop script function uses command_wait_for_stop libximc function and takes as a paramater an integer denoting
time delay in milliseconds between successive queries of controller state.
This function is also present as a method of an "axis"-type object.
libximc library functions
Libximc library functions with "get_" prefix read settings from the controller and return the corresponding settings structure. Libximc
library functions with "set_" prefix take as a parameter a settings data structure and write these settings to the controller. There are
two ways to set data structure contents:
1. call the corresponding get-function and modify required fields
// set settings: type 1
var
m = get_move_settings();
m.Speed =
100
;
set_move_settings(m);
2. create an Object and set all of its properties that are present as members of the data structure (case-sensitive).
// set settings: type 2
var
m =
new
Object;
m.Speed =
100
;
m.uSpeed =
0
;
m.Accel =
300
;
m.Decel =
500
;
m.AntiplaySpeed =
10
;
m.uAntiplaySpeed =
0
;
set_move_settings(m);
Please note, that in the first case controller receives an additional command (sent by the get-function before the set-). In the second
case one should initialize all object properties corresponding to structure members. Any missing property will be initialized with zero.
Any property that does not match a structure member name will be ignored. Any property with non-matching type will be typecast
according to EcmaScript rules. All data structures are described in
Communication protocol specification
Examples
This section contains examples of typical tasks which can be easily automated by XILab scripts.
Cyclic movement script
var
first_border = -
10
;
// first border coordinate in mm
var
second_border =
10
;
// second border coordinate in mm
var
mm_per_step =
0.005
;
// steps to distance translation coefficient
var
delay =
100
;
// delay in milliseconds
var
calb = new_calibration(mm_per_step, get_engine_settings().MicrostepMode);
// create calibration structu
re
command_stop();
// send STOP command (does immediate stop)
command_zero();
// send ZERO command (sets current position and encoder value to zero)
while
(
1
) {
// infinite loop
command_move_calb(first_border, calb);
// move towards one border
command_wait_for_stop(delay);
// wait until controller stops moving
command_move_calb(second_border, calb);
// move towards another border
command_wait_for_stop(delay);
// wait until controller stops moving
}
Page 271 / 345
Page 271 / 345
Summary of Contents for 8SMC5-USB
Page 30: ...Linux Page 30 345 Page 30 345 ...
Page 83: ...Connection of magnetic brake to one axis or two axis systems Page 83 345 Page 83 345 ...
Page 87: ...Scheme of buttons connection to the HDB 26 connector Page 87 345 Page 87 345 ...
Page 99: ...Page 99 345 Page 99 345 ...
Page 167: ...Vertical load capacity the maximum vertical load on the stage Page 167 345 Page 167 345 ...
Page 186: ...Click Next Click Continue anyway Page 186 345 Page 186 345 ...
Page 188: ...Page 188 345 Page 188 345 ...
Page 190: ...Page 190 345 Page 190 345 ...
Page 193: ...Page 193 345 Page 193 345 ...
Page 201: ...Select the XILab application in the Programs block Start it Page 201 345 Page 201 345 ...
Page 274: ...7 Files 1 Configuration files 2 Software Page 274 345 Page 274 345 ...
Page 331: ...Motorized Iris Diaphragms 8MID98 Motorized Iris Diaphragm Page 331 345 Page 331 345 ...
Page 338: ...8 Related products 1 Ethernet adapter Page 338 345 Page 338 345 ...
Page 339: ...8 1 Control via Ethernet 1 Overview 2 Administration Page 339 345 Page 339 345 ...