FCScript Expression Functions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

®

FCScript
Expression Functions
Revision 1.7

MotionPRO Page 1 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Table of Contents
................................................................................................................................................................ 1
Overview ............................................................................................................................................................. 5
Expression Step Functions .............................................................................................................................. 6
Axis Related Functions ........................................................................................................................... 6
axis_abort ...........................................................................................................................................................6
axis_imm_abort ..................................................................................................................................................6
axis_stop .............................................................................................................................................................7
axis_imm_stop....................................................................................................................................................7
axis_disable ........................................................................................................................................................8
axis_imm_disable ...............................................................................................................................................9
axis_get_position............................................................................................................................................. 10
axis_set_position ............................................................................................................................................. 10
axis_get_temperature ..................................................................................................................................... 11
Curve Related Functions ...................................................................................................................... 12
curve_x_cross .................................................................................................................................................. 12
curve_y_cross .................................................................................................................................................. 13
curve_grad_cross............................................................................................................................................. 14
curve_tooth_analyze ....................................................................................................................................... 15
curve_tooth_info ............................................................................................................................................. 16
Delay Related Functions ...................................................................................................................... 17
Delay ................................................................................................................................................................ 17
Encoder Related Functions .................................................................................................................. 18
encoder_read .................................................................................................................................................. 18
ext_encoder_read ........................................................................................................................................... 18
Fieldbus Related Functions .................................................................................................................. 19
fb_read_input_bit ........................................................................................................................................... 19
fb_read_output_bit ......................................................................................................................................... 19
fb_write_output_bit ........................................................................................................................................ 19
fb_read_input_integer .................................................................................................................................... 20
fb_read_output_integer .................................................................................................................................. 20
MotionPRO Page 2 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
fb_write_output_integer................................................................................................................................. 20
fb_read_input_number ................................................................................................................................... 21
fb_read_output_number ................................................................................................................................ 21
fb_write_output_number ............................................................................................................................... 21
fb_read_input_string....................................................................................................................................... 22
fb_read_output_string .................................................................................................................................... 22
fb_write_output_string ................................................................................................................................... 22
Math Related Functions ........................................................................................................................ 23
acos .................................................................................................................................................................. 23
asin................................................................................................................................................................... 23
atan .................................................................................................................................................................. 23
cos.................................................................................................................................................................... 24
exp ................................................................................................................................................................... 24
ln ...................................................................................................................................................................... 24
log10 ................................................................................................................................................................ 25
pow .................................................................................................................................................................. 25
sin .................................................................................................................................................................... 25
sqrt................................................................................................................................................................... 26
tan .................................................................................................................................................................... 26
Message Related Functions ................................................................................................................. 27
msg .................................................................................................................................................................. 27
Sensor Related Functions .................................................................................................................... 27
sensor_read ..................................................................................................................................................... 27
String Related Functions ...................................................................................................................... 28
string_add ........................................................................................................................................................ 28
string_append.................................................................................................................................................. 28
string_length.................................................................................................................................................... 28
TCP Client Related Functions .............................................................................................................. 29
tcp_getserialnum............................................................................................................................................. 29
tcp_setserialnum ............................................................................................................................................. 29
tcp_getvariable ................................................................................................................................................ 30
tcp_setvariable ................................................................................................................................................ 30
Timer Related Functions ...................................................................................................................... 31
MotionPRO Page 3 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
timer_read ....................................................................................................................................................... 31
timer_reset ...................................................................................................................................................... 31
timer_start ....................................................................................................................................................... 31
timer_stop ....................................................................................................................................................... 32
Type Related Functions ........................................................................................................................ 33
boolean_to_string ........................................................................................................................................... 33
integer_to_string ............................................................................................................................................. 33
number_to_string............................................................................................................................................ 33
Live Expression Resource Functions ........................................................................................................... 34
Axis Related Functions ......................................................................................................................... 34
axis_get_position............................................................................................................................................. 34
axis_imm_stop................................................................................................................................................. 34
Delay Related Functions ...................................................................................................................... 35
delay_value...................................................................................................................................................... 35
Encoder Related Functions .................................................................................................................. 36
encoder_read .................................................................................................................................................. 36
ext_encoder_read ........................................................................................................................................... 36
Sensor Related Functions .................................................................................................................... 37
sensor_read ..................................................................................................................................................... 37
Timer Related Functions ...................................................................................................................... 38
timer_read ....................................................................................................................................................... 38
Variable Related Functions .................................................................................................................. 39
var_set_int ....................................................................................................................................................... 39
Live Expression Examples ............................................................................................................................. 40
Example 1 ............................................................................................................................................. 40
Example 2 ............................................................................................................................................. 41
Revision History .............................................................................................................................................. 42

MotionPRO Page 4 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Overview
This document describes the custom functions for both the Expression Step and the Live Expression
Resource.

MotionPRO Page 5 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Expression Step Functions
Axis Related Functions
axis_abort

Syntax return_value:boolean axis_abort axis_number:integer

This function aborts the specified axis once this task is reached in the motion task queue, putting the
axis in a halt state. Aborting an axis is the same as stopping an axis but the AbortRate is used instead.
Description The axis is also deadened or disabled after a controlled stop is finished. For all practical purposes, this
is like an E-Stop. If you don't want to wait for previous motion tasks to complete first then call
immAbort() instead - it acts immediately. Returns true if the function was successful else false.

axis_abort 1

set aborted_var [axis_abort axis_var]


Examples
if ( [axis_abort 1] ) {
msg "Axis aborted successfully"
}

axis_imm_abort

Syntax return_value:boolean axis_imm_abort axis_number:integer

This function aborts the specified axis immediately, putting the axis in a halt state. All motion tasks are
Description discarded from the motion taskqueue and a controlled emergency stop is performed as described for
the axis_abort function. Returns true if the function was successful else false.

axis_imm_abort 1

set aborted_var [axis_imm_abort axis_var]


Examples
if ( [axis_imm_abort 1] ) {
msg "Axis aborted successfully"
}

MotionPRO Page 6 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

axis_stop

Syntax return_value:boolean axis_stop axis_number:integer

This function stops the specified axis once this task is reached in the motion task queue. Stopping an
axis involves ramping the velocity down to zero at a rate defined by StopRate. If in torque mode it
Description simply releases all torque (current = 0 Amperes). The axis stays alive (Enabled) however. This means
if positioning mode then it continues to hold the current position. Returns true if the function was
successful else false.

axis_stop 1

set stopped_var [axis_stop axis_var]


Examples
if ( [axis_stop 1] ) {
msg "Axis stopped successfully"
}

axis_imm_stop

Syntax return_value:boolean axis_imm_stop axis_number:integer

This function stops the specified axis immediately. All motion tasks are discarded from the motion task
Description queue and a controlled stop is performed as described for axis_stop function. Returns true if the
function was successful else false.

axis_imm_stop 1

set stopped_var [axis_imm_stop axis_var]


Examples
if ( [axis_imm_stop 1] ) {
msg "Axis stopped successfully"
}

MotionPRO Page 7 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

axis_disable

Syntax return_value:boolean axis_disable axis_number:integer

This function disables the specified axis once this task is reached in the motion task queue. Returns
true if the function was successful else false.
Description NOTE: If the axis_disable is executed when the axis is not stopped the drive will
generate an internal E-Stop which will cause the part program to suspend or stop. In
order for this not to occur an axis_stop followed by a short 20-30 millisecond delay
should be executed before the axis_disable.

axis_stop 1
delay 30
axis_disable 1

axis_stop 1
delay 30
Examples set disabled_var [axis_disable axis_var]

axis_stop 1
delay 30
if ( [axis_disable 1] ) {
msg "Axis disabled successfully"
}

MotionPRO Page 8 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

axis_imm_disable

Syntax return_value:boolean axis_imm_disable axis_number:integer

This function disables the specified axis immediately. All motion tasks are discarded from the motion
task queue and axis is disabled as described in the axis_disable function. Returns true if the function
was successful else false.
Description
NOTE: If the axis_imm_disable is executed when the axis is not stopped the drive will
generate an internal E-Stop which will cause the part program to suspend or stop. In
order for this not to occur an axis_ imm_stop followed by a short 20-30 millisecond
delay should be executed before the axis_ imm_disable.

axis_imm_stop 1
delay 30
axis_imm_disable 1

axis_imm_stop 1
delay 30
Examples set disabled_var [axis_imm_disable axis_var]

axis_imm_stop 1
delay 30
if ( [axis_imm_disable 1] ) {
msg "Axis disabled successfully"
}

MotionPRO Page 9 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

axis_get_position

Syntax return_value:boolean axis_get_position axis_number:integer, pos:number_ref

This function gets the current actual position of the specified axis and puts the value in the variable
Description specified by the second argument pos:number_ref. Returns true if the function was successful else
false.

axis_get_position 1, axis1_pos_var

axis_get_position 2 axis2_pos_var

Examples set return_var [axis_get_position axis_index_var, axis_index_pos_var]

if ([axis_get_position 1, axis1_pos_var] ) {
msg "Axis 1 position was read successfully"
}

axis_set_position

Syntax return_value:boolean axis_set_position axis_number:integer,new_pos:number

This function sets the current actual position of the specified axis with the value specified by the second
Description
argument new_pos:number. Returns true if the function was successful else false.

axis_set_position 1, 50.5

axis_set_position 1, axis1_pos_var

axis_set_position 2 axis2_pos_var
Examples
set return_var [axis_set_position axis_index_var, axis_index_pos_var]

if ([axis_set_position 1, axis1_pos_var] ) {
msg "Axis 1 position was set successfully"
}

MotionPRO Page 10 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

axis_get_temperature

return_value:boolean axis_get_temperature axis_number:integer, temp_sensor_number: integer,


Syntax
temp_value:number_ref

This function gets the current temperature in degrees celsius of the specified temprarture sensor of the
specified axis. Returns true if the function was successful else false.

Description Valid temp_sensor_number: (1-3)


1 -- Ambient/Internal Drive Temperature
2 -- Heat Sink Drive Temperature
3 -- Motor Temperature

axis_get_temperature 1, 1, axis1_internal_temp_var

axis_get_temperature 1, 2, axis1_heatsink_temp_var

axis_get_temperature 1, 3, axis1_motor_temp_var
Examples
set return_var [axis_get_temperature axis_index_var, sensor_index_var, temp_var]

if ([axis_get_ temperature 1, 1, axis1_internal_temp_var] ) {


msg "Axis 1 internal drive temprature was read successfully"
}

MotionPRO Page 11 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Curve Related Functions
The FCScript language supports five different curve analysis functions. The curve_grad_cross, curve_x_cross,
and curve_y_cross functions can be used to look at a specified curve and determine where the curve crosses a
certain value. The curve_tooth_analyze and curve_tooth_info functions are used in conjunction to acquire
information about teeth in a curve.

curve_x_cross

Syntax return_value:boolean curve_x_cross curve_id:string,x_location:number,at_y:number_ref

This function is used to determine where a specified curve crosses a certain x-axis value. The
curve_id argument is the Monitor Name of curve to be analyzed (must be in quotation marks and is
case sensitive). The x_location argument is the x-axis value that specifies the desired location of the
Description
crossing point of the curve. The at_y argument (returned parameter value) is the global variable name
where the crossing point of the curve at the x_location will be returned. Returns true if the function was
successful else false.

curve_x_cross “graph1”,15, crossing_force_var

curve_x_cross “graph2”, x_var, crossing_force_var

curve_x_cross “graph2” x_var crossing_force_var

set return_var [curve_x_cross “graph4”, 37, crossing_force_var]


Examples
if ( [curve_x_cross "graph4", 37, crossing_force_var] ) {
msg "curve_x_cross function was successful"
} else {
msg "curve_x_cross function was not successful"
}

MotionPRO Page 12 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

curve_y_cross

return_value:boolean curve_y_cross curve_id:string, y_level:number, x_start:number,


Syntax
search_direction: number, at_y:number_ref

This function is used to determine where a specified curve crosses a certain y-axis value. The
curve_id argument is the Monitor Name of curve to be analyzed (must be in quotation marks and is
case sensitive). The y_level argument is the y-axis value that specifies the desired location of the
crossing point of the curve. The x_start argument is the x-axis value that specifies the starting point to
Description find the crossing point of the curve. The search_direction argument is the direction in which the
software will search, from the x_start, to find the crossing point. Entering +1 will search in the positive
x-direction; entering -1 will search in the negative x-direction. The at_y (returned parameter value)
argument is the global variable name where the crossing point of the curve at the y_level will be
returned. Returns true if the function was successful else false.

curve_y_cross "graph1", 200, 15, +1, crossing_position_var

curve_y_cross "graph2", y_var, x_start_var, -1, crossing_position_var

curve_y_cross "graph2" y_var x_start_var -1 crossing_position_var

Examples set return_var [curve_y_cross "graph1", 200, 15, +1, crossing_position_var]

if ([curve_y_cross "graph1", 200, 15, +1, crossing_position_var]) {


msg "curve_y_cross function was successful"
} else {
msg "curve_y_cross function was not successful"
}

MotionPRO Page 13 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

curve_grad_cross

return_value:boolean curve_grad_cross curve_id:string, x0:number, k_slope:number,


Syntax
at_x:number_ref, at_y:number_ref

This function compares a curve specified by name to a gradient line defined by the user. It determines
whether the curve crosses the gradient line and, if so, the X and Y coordinate where this crossing
occurs. It does not perform limit comparison or affect the part status in any way. The user is
responsible for taking the information from this function and performing additional actions. The
curve_id argument is the Monitor Name of curve to be analyzed (must be in quotation marks and is
Description
case sensitive). The x0 argument specifies the origin of the gradient line along the X axis. The line is
infinite in length. The k_slope argument specifies the slope of the gradient line in Y units over X units.
The at_x (Returned parameter value) argument specifies the point along the X axis where curve
crosses the gradient line. The at_y (Returned parameter value) argument specifies the point along the
Y axis where curve crosses the gradient line. Returns true if the function was successful else false.

curve_grad_cross "graph1", 10, 0.75, at_x_var, at_y_var

curve_grad_cross "graph1" 10 0.75 at_x_var at_y_var

set return_var [curve_grad_cross "graph1", 10, 0.75, at_x_var, at_y_var]


Examples
if ([curve_grad_cross "graph1", 10, 0.75, at_x_var, at_y_var]) {
msg " curve_grad_cross function was successful"
} else {
msg " curve_grad_cross function was not successful"
}

MotionPRO Page 14 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
curve_tooth_analyze

return_value:integer curve_tooth_analyze curve_id:string ,options:string, begin:number,


Syntax
tooth_width:number, number_teeth:integer

This function performs all the data analysis on a specified curve that has been acquired. The curve_id
argument is the Monitor Name of curve to be analyzed (must be given in quotation marks and is case
sensitive). The options argument is not used at this time and its value is ignored. The begin argument
is used to tell where in the curve to start processing. The tooth_width is the total width of the of the
tooth (wave period). The number_teeth argument is to tell how many teeth to analyze from the
Description
beginning location. There is a maximum limit of 1000 teeth that can be analyzed. If you specify more
than 1000 teeth, the extra teeth will not be analyzed and the information will not be available. The
function returns the actual number of teeth analyzed.

When this function is called, it performs all the analysis and sets the results aside for querying by the
curve_tooth_info function.

Examples curve_tooth_analyze "graph1", “”, 0.75, 5.5, 25

MotionPRO Page 15 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
curve_tooth_info

Syntax return_value:number curve_tooth_info curve_id:string ,query:string, tooth:integer

This function queries the information about a curve from a previously ran curve_tooth_analyze
function call. The curve_id argument is the Monitor Name of the curve previously analyzed from which
you are extracting information (must be supplied in quotation marks and is case sensitive). The query
argument is the keyword that specifies what information that will be returned. The following is a list of
supported keywords:

max_p2v Maximum peak-to-valley among all teeth.


min_p2v Minimum peak-to- valley among all teeth.
avg_p2v Average peak-to- valley among all teeth.
Description max_p2v_tooth Tooth # where maximum peak-to- valley occurred (+/- 1 tooth accuracy).
This number falls with 1 to N, where N is the number of teeth analyzed.
min_p2v_tooth Tooth # where minimum peak-to- valley occurred (+/- 1 tooth accuracy).
This number falls with 1 to N, where N is the number of teeth analyzed.
tooth_p2v The peak-to-valley of a tooth specified by {tooth #} parameter.
clear Clears and releases memory used to hold analysis information for specified
curve. Although not required, it is a good idea to clear the information when
you’re done using it.
The tooth argument is the number of the tooth that that the keyword “tooth_p2v” gathers information
about. Otherwise this argument is ignored. Returns the information related to the supplied keyword.

Set p2v [curve_tooth_info "graph1", “max_p2v”, 0]

Set p2v [curve_tooth_info "graph1", “min_p2v”, 0]

Set p2v [curve_tooth_info "graph1", “avg_p2v”, 0]

Set p2v [curve_tooth_info "graph1", “max_p2v_tooth”, 0]


Examples
Set p2v [curve_tooth_info "graph1", “min_p2v_tooth”, 0]

Set p2v [curve_tooth_info "graph1", “tooth_p2v”, 5]

curve_tooth_info "graph1", “clear”, 0

MotionPRO Page 16 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Delay Related Functions

Delay

Syntax return_value:boolean delay delay_number:integer

This function delays for delay_number of milliseconds. Returns true if the function was successful else
Description
false.

delay 100

delay ( 500 + time_delay_var )

set return_var [delay time_delay_var]


Examples
if ([delay time_delay_var]) {
msg "delay function was successful"
} else {
msg "delay function was not successful"
}

MotionPRO Page 17 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Encoder Related Functions

encoder_read

Syntax return_value:boolean encoder_read encoder_number:integer, reading:number_ref

This function gets the current encoder reading of the specified encoder and puts the value in the
Description variable specified by the second argument reading:number_ref. Returns true if the function was
successful else false.

encoder_read 1, encoder1_var

encoder_read 2 encoder2_var

Examples set return_var [encoder_read encoder_index_var, encoder_index_reading_var]

if ([encoder_read encoder_index_var, encoder_index_reading_var]) {


msg "Encoder 1 was read successfully"
}

ext_encoder_read

Syntax return_value:boolean ext_encoder_read ext_encoder_number:integer, reading:number_ref

This function gets the current encoder reading of the specified encoder and puts the value in the
Description variable specified by the second argument reading:number_ref. Returns true if the function was
successful else false.

ext_encoder_read 1, ext_encoder1_var

ext_encoder_read 2 ext_encoder2_var

Examples set return_var [ext_encoder_read ext_encoder_index_var, ext_encoder_index_reading_var]

if ([ext_encoder_read ext_encoder_index_var, ext_encoder_index_reading_var]) {


msg "External Encoder 1 was read successfully"
}

MotionPRO Page 18 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Fieldbus Related Functions
fb_read_input_bit

Syntax return_value:boolean fb_read_input_bit input_number:integer

This function reads a fieldbus input bit at position index specified by the input_number argument (1
Description
through N). Returns a boolean value representing the bit’s state.

set input1_var [fb_read_input_bit 1]


Examples
set input5_var [fb_read_input_bit 5]

fb_read_output_bit

Syntax return_value:boolean fb_read_output_bit output_number:integer

This function reads a fieldbus output bit at position index specified by the output_number argument (1
Description
through N). Returns a boolean value representing the bit’s state.

set output1_var [fb_read_output_bit 1]


Examples
set output5_var [fb_read_output_bit 5]

fb_write_output_bit

Syntax fb_write_output_bit output_number:integer ,new_value:boolean

This function writes a fieldbus output bit at position index specified by the output_number argument (1
Description
through N) with a value specified by the new_value argument. Returns nothing.

fb_write_output_bit 1, 0
Examples
fb_write_output_bit 5 1

MotionPRO Page 19 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
fb_read_input_integer

Syntax return_value:integer fb_read_input_integer input_number:integer

This function reads a fieldbus input integer at position index specified by the input_number argument (1
Description
through N). Returns the fieldbus integer value.

set input1_var [fb_read_input_integer 1]


Examples
set input5_var [fb_read_input_integer 5]

fb_read_output_integer

Syntax return_value:integer fb_read_output_integer output_number:integer

This function reads a fieldbus output integer at position index specified by the output_number argument
Description
(1 through N). Returns the fieldbus integer value.

set output1_var [fb_read_output_integer 1]


Examples
set output5_var [fb_read_output_integer 5 ]

fb_write_output_integer

Syntax fb_write_output_integer output_number:integer, new_value:integer

This function writes a fieldbus output integer at position index specified by the output_number
Description
argument (1 through N) with a value specified by the new_value argument. Returns nothing.

fb_write_output_integer 1, 948
Examples
fb_write_output_integer 5 362

MotionPRO Page 20 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
fb_read_input_number

Syntax return_value:number fb_read_input_number input_number:integer

This function reads a fieldbus input number at position index specified by the input_number argument
Description
(1 through N). Returns the fieldbus number value.

set input1_var [fb_read_input_number 1]


Examples
set input5_var [fb_read_input_number 5]

fb_read_output_number

Syntax return_value:number fb_read_output_number output_number:integer

This function reads a fieldbus output number at position index specified by the output_number
Description
argument (1 through N). Returns the fieldbus number value.

set output1_var [fb_read_output_number 1]


Examples
set output5_var [fb_read_output_number 5]

fb_write_output_number

Syntax fb_write_output_number output_number:integer, new_value:number

This function writes a fieldbus output number at position index specified by the output_number
Description
argument (1 through N) with a value specified by the new_value argument. Returns nothing.

fb_write_output_number 1, 136.948
Examples
fb_write_output_number 1 7.285

MotionPRO Page 21 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
fb_read_input_string

Syntax return_value:string fb_read_input_string input_number:integer

This function reads a fieldbus input string at position index specified by the input_number argument (1
Description through N). Returns the fieldbus string.
Note: only input_number = 1 is supported as of this writing.

Examples msg [ fb_read_input_string 1 ]

fb_read_output_string

Syntax return_value:string fb_read_output_string output_number:integer

This function reads a fieldbus output string at position index specified by the output_number argument
Description (1 through N). Returns the fieldbus string.
Note: only output_number = 1 is supported as of this writing.

Examples msg [ fb_read_output_string 1 ]

fb_write_output_string

Syntax fb_write_output_string output_number:integer, new_value:string

This function writes a fieldbus output string at position index specified by the output_number argument
Description (1 through N) with a value specified by the new_value argument. Returns nothing.
Note: only output_number = 1 is supported as of this writing.

fb_write_output_string 1, "Test"
Examples
fb_write_output_string 1 "Test"

MotionPRO Page 22 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Math Related Functions

acos

Syntax return_value:number acos x:number

Description This function computes the arc-cosine of the x argument (specified in radians). Returns the result.

Examples set result_var [acos 1.5]

asin

Syntax return_value:number asin x:number

Description This function computes the arc-sine of the x argument (specified in radians). Returns the result.

Examples set result_var [asin 1.5]

atan

Syntax return_value:number atan x:number

Description This function computes the arc-tangent of the x argument (specified in radians). Returns the result.

Examples set result_var [atan 1.5]

MotionPRO Page 23 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
cos

Syntax return_value:number cos x:number

Description This function computes the cosine of the x argument (specified in radians). Returns the result.

Examples set result_var [cos 1.5]

exp

Syntax return_value:number exp x:number

Description This function computes the natural exponential of the x argument. Returns the result.

Examples set result_var [exp 1.5]

ln

Syntax return_value:number ln x:number

Description This function computes the natural logarithm of the x argument. Returns the result.

Examples set result_var [ln 1.5]

MotionPRO Page 24 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
log10

Syntax return_value:number log10 x:number

Description This function computes the base-10 logarithm of the x argument. Returns the result.

Examples set result_var [log10 1.5]

pow

Syntax return_value:number pow x:number, y:number

Description This function computes the x argument raised to the power of the y argument. Returns the result.

Examples set result_var [pow 1.5, 2]

sin

Syntax return_value:number sin x:number

Description This function computes the sine of the x argument (specified in radians). Returns the result.

Examples set result_var [sin 1.5]

MotionPRO Page 25 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
sqrt

Syntax return_value:number sqrt x:number

Description This function computes the square-root of the x argument. Returns the result.

Examples set result_var [sqrt 25.7]

tan

Syntax return_value:number tan x:number

Description This function computes the tangent of the x argument (specified in radians). Returns the result.

Examples set result_var [tan 1.5]

MotionPRO Page 26 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Message Related Functions

msg

Syntax msg text:string

Description This function logs a message text to the event log for debugging or display purposes. Returns nothing.

Examples msg "This is a message."

Sensor Related Functions

sensor_read

Syntax return_value:boolean sensor_read sensor_number:integer, reading:number_ref

This function gets the current sensor reading of the specified sensor and puts the value in the variable
Description specified by the second argument reading:number_ref. Returns true if the function was successful else
false.

sensor_read 1, sensor1_var

sensor_read 2 sensor2_var

Examples set return_var [sensor_read sensor_index_var, sensor_index_reading_var]

if ([sensor_read sensor_index_var, sensor_index_reading_var]) {


msg "Sensor 1 was read successfully"
}

MotionPRO Page 27 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
String Related Functions

string_add

Syntax return_value:string string_add string1:string, string2:string

Description This function computes the combined string of string1 followed by string2. Returns the resulting string.

Examples msg [ string_add "This is", "a message"]

string_append

Syntax string_append to_string:string_ref, append_string

Description This function appends the string append_string to the string variable to_string. Returns nothing.

set error_msg "Error: "


string_append error_msg, "This is an error."
Examples
msg error_msg

string_length

Syntax return_value:integer string_length string1:string

Description This function computes the total character length of string string1. Returns the result.

Examples set length_var ( [ string_length "This is a message." ] )

MotionPRO Page 28 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
TCP Client Related Functions
tcp_getserialnum

Syntax return_value:boolean tcp_getserialnum ipaddr:string, port:string, serialnum:string_ref

This funciton sends a getserialnum Command Server command via an ethrnet TCP message to a
remote MotionPRO. The remote MotionPRO is specified by the IP address and port number specified.
Description This function gets the remote MotionPRO’s current part serial number and puts it in the expression
string variable specified by the argument serialnum:string_ref. Returns true if the function was
successful else false.

var serialnum:string
tcp_ getserialnum "192.168.1.107" "9750" serialnum

Examples if (not [tcp_ getserialnum "192.168.1.108" "9750" serialnum ] )


{
msg "tcp_getserialnum failed."
}

tcp_setserialnum

Syntax return_value:boolean tcp_setserialnum ipaddr:string, port:string, serialnum:string

This funciton sends a setserialnum Command Server command via an ethrnet TCP message to a
remote MotionPRO. The remote MotionPRO is specified by the IP address and port number specified.
Description
This function sets the remote MotionPRO’s current part serial number with the string specified by the
argument serialnum:string. Returns true if the function was successful else false.

var serialnum:string
set serialnum “ABC123”
tcp_ setserialnum "192.168.1.107" "9750" serialnum
tcp_ setserialnum "192.168.1.108" "9750" “XYZ789”
Examples
if (not [tcp_ setserialnum "192.168.1.107" "9750" serialnum ] )
{
msg "tcp_setserialnum failed."
}

MotionPRO Page 29 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

tcp_getvariable

Syntax return_value:boolean tcp_getvariable ipaddr:string, port:string, variablename:string, value:number_ref

This funciton sends a getvariable Command Server command via an ethrnet TCP message to a
remote MotionPRO. The remote MotionPRO is specified by the IP address and port number specified.
Description This function gets the current value of the remote variable specified by variablename and puts the
value in the local variable specified by the fourth argument value:number_ref. Returns true if the
function was successful else false.

tcp_getvariable "192.168.1.107" "9750" "Final_Position" Remote_Final_Position

if (not [ tcp_getvariable "192.168.1.108" "9750" "Final_Position" Remote_Final_Position ] )


Examples
{
msg "tcp_getvariable failed."
}

tcp_setvariable

Syntax return_value:boolean tcp_setvariable ipaddr:string, port:string, variablename:string, value:number

This funciton sends a setvariable Command Server command via an ethrnet TCP message to a
remote MotionPRO. The remote MotionPRO is specified by the IP address and port number specified.
Description This function sets the current value of the remote variable specified by variablename and puts the
value specified by a constent number or a local variable specified by the fourth argument
value:number_ref. Returns true if the function was successful else false.

tcp_setvariable "192.168.1.107" "9750" "Number_of_Tries" 6

tcp_setvariable "192.168.1.108" "9750" "Final_Position" Final_Pos

Examples if (not [tcp_setvariable "192.168.1.109" "9750" "Final_Position" Final_Pos ] )


{
msg "tcp_setvariable failed."
}

MotionPRO Page 30 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Timer Related Functions

timer_read

Syntax return_value:boolean timer_read timer_number:integer, reading:number_ref

This function gets the current timer reading of the specified timer and puts the value in the variable
Description specified by the second argument reading:number_ref. Returns true if the function was successful else
false.

timer_read 1 timer1_var

timer_read 2 timer2_var

Examples set return_var [timer_read timer_index_var timer_index_reading_var]

if ([timer_read timer_index_var timer_index_reading_var]) {


# Do something here
}

timer_reset

Syntax timer_reset timer_number:integer

This function resets the specified timer timer_number, numbered 1-4. The corresponding timer must be
Description
enabled on the Setup tab of the System Setup screen. Returns nothing.

Examples timer_reset 1

timer_start

Syntax timer_start timer_number:integer

This function starts the specified timer timer_number, numbered 1-4. The corresponding timer must be
Description
enabled on the Setup tab of the System Setup screen. Returns nothing.

Examples timer_start 1

MotionPRO Page 31 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

timer_stop

Syntax timer_stop timer_number:integer

This function stops the specified timer timer_number, numbered 1-4. The corresponding timer must be
Description
enabled on the Setup tab of the System Setup screen. Returns nothing.

Examples timer_stop 1

MotionPRO Page 32 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Type Related Functions

boolean_to_string

Syntax return_value:string boolean_to_string v:boolean

This function converts a boolean value v to a string as either “true” or “false”. Returns the resulting
Description
string.

Examples msg [boolean_to_string is_finished_var ]

integer_to_string

Syntax return_value:string integer_to_string v:integer

Description This function converts an integer value v to a string. Returns the resulting string.

Examples msg [integer_to_string final_pos_var ]

number_to_string

Syntax return_value:string number_to_string v:boolean, dec_places:integer

This function converts a number value v to a string formatted with dec_places number of decimal
Description
places. Returns the resulting string.

Examples msg [number_to_string final_force_var, 2 ]

MotionPRO Page 33 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Live Expression Resource Functions

Axis Related Functions

axis_get_position

Syntax return_value:boolean axis_get_position axis_number:integer, pos:number_ref

This function gets the current actual position of the specified axis and puts the value in the variable
Description specified by the second argument pos:number_ref. Returns true if the function was successful else
false.

axis_get_position 1, axis1_pos_var

axis_get_position 2 axis2_pos_var

Examples set return_var [axis_get_position axis_index_var, axis_index_pos_var]

if ([axis_get_position 1, axis1_pos_var] ) {
# Do something here
}

axis_imm_stop

Syntax return_value:boolean axis_imm_stop axis_number:integer

This function stops the specified axis immediately. All motion tasks are discarded from the motion task
Description queue and a controlled stop is performed as described for axis_stop function. Returns true if the
function was successful else false.

axis_imm_stop 1

set stopped_var [axis_imm_stop axis_var]


Examples
if ( [axis_imm_stop 1] ) {
msg "Axis stopped successfully"
}

MotionPRO Page 34 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Delay Related Functions

delay_value

Syntax return_value:number delay_value delay_number:number, input_number:number

Description
This function delays for delay_number of milliseconds before it returns the input_number.

Examples set delayed_var [ delay_value 100, current_var ]

MotionPRO Page 35 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Encoder Related Functions

encoder_read

Syntax return_value:boolean encoder_read encoder_number:integer, reading:number_ref

This function gets the current encoder reading of the specified encoder and puts the value in the
Description variable specified by the second argument reading:number_ref. Returns true if the function was
successful else false.

encoder_read 1, encoder1_var

encoder_read 2 encoder2_var

Examples set return_var [encoder_read encoder_index_var, encoder_index_reading_var]

if ([encoder_read encoder_index_var, encoder_index_reading_var]) {


# Do something here
}

ext_encoder_read

Syntax return_value:boolean ext_encoder_read ext_encoder_number:integer, reading:number_ref

This function gets the current encoder reading of the specified encoder and puts the value in the
Description variable specified by the second argument reading:number_ref. Returns true if the function was
successful else false.

ext_encoder_read 1, ext_encoder1_var

ext_encoder_read 2 ext_encoder2_var

Examples set return_var [ext_encoder_read ext_encoder_index_var, ext_encoder_index_reading_var]

if ([ext_encoder_read ext_encoder_index_var, ext_encoder_index_reading_var]) {


# Do something here
}

MotionPRO Page 36 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Sensor Related Functions

sensor_read

Syntax return_value:boolean sensor_read sensor_number:integer, reading:number_ref

This function gets the current sensor reading of the specified sensor and puts the value in the variable
Description specified by the second argument reading:number_ref. Returns true if the function was successful else
false.

sensor_read 1 sensor1_var

sensor_read 2 sensor2_var

Examples set return_var [sensor_read sensor_index_var sensor_index_reading_var]

if ([sensor_read sensor_index_var sensor_index_reading_var]) {


# Do something here
}

MotionPRO Page 37 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Timer Related Functions

timer_read

Syntax return_value:boolean timer_read timer_number:integer, reading:number_ref

This function gets the current timer reading of the specified timer and puts the value in the variable
Description specified by the second argument reading:number_ref. Returns true if the function was successful else
false.

timer_read 1 timer1_var

timer_read 2 timer2_var

Examples set return_var [timer_read timer_index_var timer_index_reading_var]

if ([timer_read timer_index_var timer_index_reading_var]) {


# Do something here
}

MotionPRO Page 38 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®
Variable Related Functions

var_set_int

Syntax return_value:boolean var_set_int variable_name:string, input:integer

This function sets an integer type global variable with the name specified by the string to the specified
integer constant. Returns true if the function was successful else false.
Description
NOTE: This function is used to set a variable in a Live Expression without making a link to the
variable in the Signal Plane. This is needed to avoid cycles in the Signal Plane graph.

var_set_int “variable1” 0

var_set_int “variable2” 1

Examples set return_var [var_set_int “variable1” 0]

if ([var_set_int “variable1” 0]) {


# Do something here
}

MotionPRO Page 39 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Live Expression Examples

Example 1
Live Expression that calculates rate of change.

sensor_read 1 Force_A
axis_get_position 1 Position_A
set Force_B [ delay_value 100 Force_A ]
set Position_B [ delay_value 100 Position_A ]
set Force_Delta ( Force_B - Force_A )
set Position_Delta ( Position_B - Position_A )
set Rate_Of_Change ( Force_Delta / Position_Delta )

MotionPRO Page 40 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Example 2
Live Expression that calculates rate of change and checks it against a limit then stops the axis when it reaches
the target force.

sensor_read 1 Force_A
axis_get_position 1 Position_A
set Force_B [ delay_value 100 Force_A ]
set Position_B [ delay_value 100 Position_A ]
set Force_Delta ( Force_B - Force_A )
set Position_Delta ( Position_B - Position_A )
set Rate_Of_Change ( Force_Delta / Position_Delta )

if (CheckROC == 1) {
if (Rate_Of_Change > ROC_Limit) {
sensor_read 1 Start_Force
axis_get_position 1 Start_Position
set Target_Force ( Start_Force + Force_Offset )
set CheckROCDone 1
set PressToForce 1
var_set_int "CheckROC" 0
}
}

if (PressToForce == 1) {
sensor_read 1 force
if ( force >Target_Force) {
axis_imm_stop 1
set PressToForceDone 1
var_set_int "PressToForce" 0
}
}

MotionPRO Page 41 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.
®

Revision History
Revision Date Author Changes
1.0 03-18-2010 RCM Created.
1.1 04-16-2010 RCM Added Live Expression functions axis_imm_stop and
var_set_int. Added Example 2 and did some reformatting.
1.2 05-14-2010 RCM Changed the format of the Expression function timer_read.
Added Live Expression functions timer_read, encoder_read,
and ext_encoder_read.
1.3 09-02-2010 RCM Changed the format of the Expression function curve_y_cross
by changing argument search_forward: boolean to
search_direction: number.
1.4 11-17-2010 RCM Added TCP Client related functions tcp_getserialnum,
tcp_setserialnum, tcp_getvariable, and tcp_setvariable.
1.5 02-01-2012 RCM Added notes to the descriptions of axis_disable and
axis_imm_disable.
1.6 06-11-2013 SWP Added notes to the descriptions of curve_tooth_analyze and
curve_tooth_info.
1.7 01-10-2014 RCM Added Axis function axis_get_temperature.

MotionPRO Page 42 of 42

11429 Grand River Road • P.O. Box 748 • Brighton, Michigan 48116 • (810) 229-9334 • FAX (810) 229-8125
E-Mail Address: promess@promessinc.com • Web Site: www.promessinc.com
Copyright © 2014 Promess Incorporated. All rights reserved.

You might also like