Integrated Simulation and Verification
UG-NX Preview Version
Last update: July 01, 2002
Тут материал для
вас может быть очень старый, но я привык им пользоваться. На английском. Мне так понятней. :( Самое главное - это зная и
понимая как и что было построено изначально, можно понять как то будет
работать в будущем, после улучшений и модернизации.
|
S&V Commands for Machine Tool Driver
The Machine Tool Driver (MTD) calls S&V commands in order to communicate the simulation instructions to the simulation engine. There are two kinds of S&V commands. The first kind is a TCL extension commands which are referred as Basic S&V commands. Those commands are very close combined with the S&V events and consist of fundamental simulation commands to control the machine tool behavior. Those commands offer a great flexibility and control to MTD writer.
The second kind of S&V commands are the High Level S&V commands. This kind of commands uses the basic S&V commands to create new commands that are often used by the MTD writer. For example, the high level commands are responsible for linear approximation, interpolation, mapping of machine axis and devices. The High Level S&V commands suppose to simplify the task of writing a new driver.
Currently the basic S&V commands are implemented in C while the high level commands are TCL procedures. This could change in the future without effecting the way it is currently used.
Coordinate Systems Used in MTD
In the machine tool driver there are different coordinate systems that are used in definition of the S&V commands. The following is a brief explanation of those coordinate systems:
MCS - The CAM Machine Coordinate System. The NC program is output i.r.t this coordinate system.
ZCS - The workpiece Zero Coordinate System. Its attached to a fixed point on the workpiece. This is the origin of the part program. The MCS coincides with this coordinate system. MCS is for programming. The ZCS is for simulation. ZCS can changed during simulation by MTD.
Depends where ZCS is attached, it could be a static system but could be also placed on a part mounted on a rotary table and therefore moves when the part rotates. Normally ZCS are attached to stationary devices and don’t move during machining.
ACS - The Absolute Coordinate System of the CAM setup part file.
XCS - The aXis Coordinate System. Each axis of the machine has a coordinate system attached to it. Conceptually this coordinate system is firmly attached to the point where the machine element based on it is mounted but not necessarily. The degree of freedom is defined i.r.t. one of XCS main axis.
The machine axes normally when they are dependent they don't effect each other along their degree of freedom (for example orthogonal linear axes). However, there might be cases that they may effect each other and has to be taken into account. For example, collinear axis (i.e., two linear axes one mounted on the other and moves at the same direction or linear axis that is mounted on a rotary table that moves when the table rotate.
TCS - The tool coordinate system. This coordinate system is firmly attached to the mounting point of the tool. The tool length is expressed in this coordinate system. We consider the tool tip junction as the TCS. The X axis of TCS points in direction of the tool length (this to be consistent with Genius definitions)
MTCS – The Machine Tool Coordinate System. This is an abstract coordinate system defined on every machine. It is not firmly attached to any point on the machine. It used as a reference system to move or mount tool, heads and other machine devices. This has to be in sync with what is defined on the real machine tool. Normally MTCS axes are aligned with the physical machine axes. However, this will not be enforced by the system. One MTCS must be defined per machine tool.
RCS - A Reference Coordinate System. Later it will be referred also as reference junction. This is the reference coordinate system that is used to position a K-component in a specific position. This system is used in conjunction with the high level S&V motion commands.
Figure: Few Coordinate systems used in MTD
The Basic S&V commands are mapped to fundamental actions that update the machine tool model and generate graphical, audio and any other feedback. We distinguish between six categories of commands.
The following is the list of basic S&V commands. A description of those commands follows according to command category:
SIM_activate_tool - set specified tool as the current active tool.
SIM_ask_axis_dof_junction - returns name of the NC axis junction
SIM_ask_axis_position - return the axis current position in axis coordinate system
SIM_ask_cording_tol - get the cording tolernace for analytical curves (i.e, arc, spline)
SIM_ask_init_junction_xform - get the initial junction transformation i.r.t absolute coordinate system
SIM_ask_is_junction_exist - check if a junction exists
SIM_ask_junction_xform - get the junction transformation in current machine state i.r.t absolute coordinate system
SIM_ask_kim_comp_name_by_id - get component name by its class and id
SIM_ask_mtcs_junction - returns name of the MTCS junction
SIM_ask_mtd_units - return the current MTD units
SIM_ask_tool_offsets - get the specified tool offsets
SIM_create_junction - create a new junction
SIM_delete_junction - delete an existing junction
SIM_end_of_simulation - create and send end of simulation event
SIM_feedback_message - send message to the message window
SIM_mount_kim_comp - mount specified component
SIM_mount_tool - mount specified tool
SIM_move_linear_axis - move one linear axis in axis coordinate system.
SIM_move_rotary_axis - move one rotary axes in axis coordinate system.
SIM_msg_user_feedback - add feedback event that calls a user TCL procedure when event is processed.
SIM_mtd_init - initialize machine tool driver
SIM_mtd_reset - exit machine tool driver
SIM_set_channel - set the current channel
SIM_set_coolant - turn on/off the coolant
SIM_set_current_zcs_junction - set the current ZCS junction
SIM_set_cutting_mode - set the current cutting mode
SIM_set_feed - set the current feedrate
SIM_set_mtd_units - sets the input units of the S&V commands
SIM_set_parameter - set engine parameter
SIM_set_speed - set the current speed
SIM_start_of_simulation - create and send start of simulation event
SIM_step - create a sub-step event to perform intermidiate update of the machine state.
SIM_transform_matrix_acs_to_mtcs - transform specified matrix in absolute to mtcs coordinate system
SIM_transform_offset_acs_to_mtcs - transform specified offset in absolute to mtcs coordinate system
SIM_unmount_kim_comp - unmount specified component
SIM_unmount_tool - unmount tool
SIM_update - create a step event to update the state of the machine with all prior events
SIM_move_linear_axis
Syntax:
SIM_move_linear_axis <duration> <axis> <value>
Description:
Move the specified linear axis with specified value along its degree of freedom.
Parameters:
duration: the time in seconds it takes to execute this command by the machine.
Axis: name of actual linear NC axis
value: axis position in axis coordinate system.
Output:
none
Example:
SIM_move_linear_axis 10.5 X 25.4
SIM_move_rotary_axis
Syntax:
SIM_move_rotary_axis <duration> <axis> <value>
Description:
Move the specified rotary axis with specified value around its degree of freedom. The motion to the target position will be done along the shortest distance.
Parameters:
duration: the time in seconds it takes to execute this command by the machine.
axis: name of actual rotary NC axis
value: axis position in radians.
Output:
none
Example:
SIM_move_rotary_axis 36.23 A 0.7
SIM_mount_kim_comp
Syntax:
SIM_mount_kim_comp <duration> <comp1> <jct1> <comp2> <jct2>
Description:
Mount the specified component on target component. The two specified junctions determine the orientation of the mounted component. The transformation that it takes to make jct1 to coincide with jct2 is the transformation applied to comp1.
comp1 and comp2 must be a valid K-components.
If comp1 is already mounted on other component, it will be first unmounted from that component.
If comp2 is not specified, comp1 is mounted on the unmounted node of current KIM.
Parameters:
duration: the duration in seconds that it takes to mount comp1 on comp2.
comp1: the source K-component
jct1: the source junction.
comp2: the target K-component
jct2: the target junction
Output:
none
Example:
SIM_mount kim_comp 25 DEVICE_1 MNT1_JCT MACHINE_BASE1 BASE1_JCT
SIM_unmount_kim_comp
Syntax:
SIM_unmount_kim_comp <duration> <comp>
Description:
Unmount the specified K component from the current KIM model. The unmounted component is added to the unmounted components root node.
Parameters:
duration: the duration in seconds that it takes to unmount component.
comp: the component name
Output:
none
Example:
SIM_unmount_kim_comp 15 DEVICE_1
SIM_mount_tool
Syntax:
SIM_mount_tool <duration> <tool_id_class> <tool_id> <comp> <jct>
Description:
Mount the specified tool on a target component. The system looks for the tool assembly model in the resource tool library. Then a mounting junction and tool tip junction are created at their standard locations (see Genius for details). The tool is mounted on the comp such that the tool-mounting junction coincides with component junction jct. If tool assembly not found, a solid assembly of the tool is created on the fly.
The tool can be identified in the following five different ways according to the tool_id_class:
TOOL_NUMBER
LIBRARY_REF
CATALOG_NUMBER
UG_NAME
COMP_NAME
The tool_id is specified according to the specified tool_id_class.
Parameters:
duration: the duration in seconds that it takes to mount a tool on the machine.
tool_id_class: the class by which the tool id is specified. See list of classes in description.
tool_id: the tool id according to the tool_id_class.
comp: the target K-component name.
jct: the target junction
Output:
The K component name that represents the tool that has been created is returned in the global TCL variable mom_sim_result.
Example:
SIM_mount_tool 15 LIBRARY_REF UGT0201005 SPINDLE SPINDLE_JCT
SIM_unmount_tool
Syntax:
SIM_unmount_tool <duration> <tool_name>
Description:
Unmount the specified tool name from the current KIM model. Note that tool name is the name of the K-component returned when the tool was mounted.
Parameters:
duration: the duration in seconds that it takes to unmount a tool on the machine.
tool_name: the K-component that represents the tool.
Output:
none
Example:
SIM_unmount_tool 15 SIM_UGT0201005
SIM_feedback_message
Syntax:
SIM_feedback_message <label> <message>
Description:
Send a message to the info window. The system also uses this command to communicate messages to dedicated processors. In this case the label is used as a reserved keyword. The label cannot start with the $ sign unless its used as a reserved keyword.
Parameters:
label: a label name or a reserved keyword (when prefixed by $ sign)
message: the message
Output:
none
Example:
SIM_feedback_message "DEBUG:" "Running test 1"
SIM_msg_user_feedback
Syntax:
SIM_msg_user_feedback <proc>
Description:
This function send a message to the feedback processor to call the specified TCL procedure when the event is processed. All events created during the processing of the TCL procedure will be appended to the current NC channel.
Parameters:
proc: name of TCL procedure that exists in current TCL interpreter context.
Output:
none
Example:
SIM_msg_user_feedback my_tcl_proc
SIM_update
Syntax:
SIM_update <label>
Description:
Create a step event which indicates end of action (e.g. end of linear move or end of circular move). All (non-control) events prior to this event are executed simultaneously.
Parameters:
label: an optional label to identify that step. Mainly used for debugging.
Output:
none
Example:
SIM_update end_of_circle1
SIM_step
Syntax:
SIM_step <label>
Description:
Create a substep event which indicates end of an intermediate action. For example, approximation segments of a circular motion are defined as such. Also, any intermediate interpolation segments of linear motion ends with substep event. All (non-control) events prior to this event are executed simultaneously.
Parameters:
label: an optional label to identify that substep. Mainly used for debugging.
Example:
SIM_step LINE_INTER
SIM_ask_axis_position
Syntax:
SIM_ask_axis_position <axis>
Description:
Returns the current axis position. Axis can be linear or rotational. The current position is the position of the axis after all input events prior to this event have been processed. Coordinates are returned in axis coordinates.
Parameters:
axis: name of actual axis
Output:
The TCL variable mom_sim_result is set with the current axis position. For rotary axis, output is returned in radian.
Example:
SIM_ask_axis_position X
set x_position $mom_sim_result
SIM_ask_is_junction_exist
Syntax:
SIM_ask_is_junction_exist <jct_name>
Description:
Returns whether the specified junction exists or not.
Parameters:
jct_name: the name of the junction
Output:
The TCL variable mom_sim_result is set to 1 if junction exists or 0 if not.
Example:
SIM_ask_is_junction_exist WORK_ZCS
If {$mom_sim_result == 0} {
issue an error…
}
SIM_ask_junction_xform
Syntax:
SIM_ask_junction_xform <jct_name>
Description:
Returns the transformation of the specified junction. The first three arguments returned are the offset and the rest is the transformation. This transformation transforms from the ACS coordinate system to the junction coordinate system. This way we are consistence with the UG MSYS.
The transformation returned is of the current state of the junction after all events in the input buffer have been processed.
Parameters:
jct_name: the name of the junction
Output:
the rotation transformation (M00 M01 M02 ...) is returned in mom_sim_result TCL variable. The translation vector(V0 V1 V2) is returned in mom_sim_result1 variable.
Example:
In the following example the position defined i.r.t wrk_jct junction is transformed to ACS coordinate system:
SIM_ask_junction_xform $wrk_jct #get transformation
set xfm_to_acs [MatInvertL $mom_sim_result] #invert matrix to get transformation from junction to ACS
set acs_position [MatMultVectorL $xfm_to_acs $position] #transform vector
set acs_position [VAddL $acs_position $mom_sim_result1] #translate vector
SIM_ask_init_junction_xform
Syntax:
SIM_ask_init_junction_xform <jct_name>
Description:
Returns the transformation of the specified junction. The first three arguments returned are the offset and the rest is the transformation. This transformation transforms from the ACS coordinate system to the junction coordinate system. This way we are consistence with the UG msys.
The transformation returned is of the initial state of the junction before simulation started.
Parameters:
jct_name: the name of the junction
Output:
the rotation transformation (M00 M01 M02 ...) is returned in mom_sim_result TCL variable. The translation vector(V0 V1 V2) is returned in mom_sim_result1 variable.
Example:
In the following example the position defined i.r.t wrk_jct junction is transformed to ACS coordinate system:
SIM_ask_junction_xform $wrk_jct #get transformation
set xfm_to_acs [MatInvertL $mom_sim_result] #invert matrix to get transformation from junction to ACS
set acs_position [MatMultVectorL $xfm_to_acs $position] #transform verctor
set acs_position [VAddL $acs_position $mom_sim_result1] #translate vector
SIM_ask_kim_comp_name_by_id
Syntax:
SIM_ask_kim_comp_name_by_id <class> <id>
Description:
Return the KIM component name that belongs to the specified class with the specified id. Currently only the TOOL class is allowed.
Parameters:
class: class name
id: component ID.
Output:
the name of component is returned in mom_sim_result variable
Example:
SIM_ask_kim_comp_name_by_id "TOOL" $tool_ug_name
set t_name $mom_sim_result
SIM_unmount_tool "2.0" $t_name
SIM_ask_mtcs_junction
Syntax:
SIM_ask_mtcs_junction
Description:
Returns the name of the junction of the machine tool coordinate system(MTCS)
Parameters:
none
Output:
the name of the MTCS junction is returned in mom_sim_result variable
Example:
SIM_ask_mtcs_junction
set wrk_jct $mom_sim_result
SIM_ask_axis_dof_junction
Syntax:
SIM_ask_axis_dof_junction <axis>
Description:
Returns the name of junction that the NC axis is referencing for the definition of the axis degree of freedom (DOF).
Parameters:
axis: name of the actual axis
Output:
the junction name is returned in mom_sim_result variable
the axis direction of the DOF is returned in mom_sim_result1 variable when
direction of x positive is 1
direction of y positive is 2
direction of z positive is 3
direction of x negative is -1
direction of y negative is -2
direction of z negative is -3
Example:
SIM_ask_axis_dof_junction $axis
set axis_jct $mom_sim_result
set axis_num $mom_sim_result1
SIM_ask_tool_offsets
Syntax:
SIM_ask_tool_offsets <tool_name>
Description:
Returns the tool offsets. The offsets in X,Y and Z define the vector from the origin of the tool mounting junction to the origin of the tool tip absolute coordinate system(ACS).
Parameters:
tool_name: the K-component name of the tool
Output:
the list of tool offsets (in x,y, and Z) are returned in mom_sim_result variable
Example:
set offsets [SIM_ask_tool_offsets $tool_name]
SIM_ask_cording_tol
Syntax:
SIM_ask_cording_tol
Description:
Returns the tolerance used for linear approximation of circular and splinar motions.
Parameters:
none
Output:
The cording tolerance is returned in mom_sim_result variable
Example:
set tol [SIM_ask_cording_tol]
SIM_ask_mtd_units
Syntax:
SIM_ask_mtd_units
Description:
Returns the units of the machine tool driver. The interface to and from S&V commands is with those units.
Parameters:
none
Output:
The units "MM" or "INCH" is returned in mom_sim_result variable
Example:
set units [SIM_ask_mtd_units]
SIM_set_parameter
Syntax:
SIM_set_parameter <duration> <label> <text> <unit>
Description:
A general command to set a simulation engine parameter that the processor can make use of it or the MTD wants to track.
Parameters:
duration: The time in seconds it takes to execute this command by the machine.
label: label identifier for the parameter.
text: value of parameter
unit: the units of the parameter value. The supported units are: MM,INCH, SEC, MM_PER_MIN, REV_PER_MIN, INCH_PER_MIN, M_PER_SEC_POW2, MM_PER_REV, INCH_PER_REV and MM_PER_100REV
Output:
none
Example:
SIM_set_parameter 0 feed 1000 MM_PER_MIN
SIM_mtd_init
Syntax:
SIM_mtd_init <mode>
Description:
Initialize machine tool driver and set it one of the three MTD modes. The supported modes are:
NC_CONTROLLER_SIM_EVENT_HANDLER is the sim event mode where sim events are generated and processed to execute the simulation tasks.
NC_CONTROLLER_MTD_EVENT_HANDLER is the direct mode where the simulation are blended with the post generation code.
NC_CONTROLLER_PLUGIN is the plugin mode where a dedicated pulgin program parses the NC program and execute S&V commands.
Parameters:
mode: one of the three MTD modes.
Output:
none
Example:
SIM_mtd_init NC_CONTROLLER_SIM_EVENT_HANDLER
SIM_mtd_reset
Syntax:
SIM_mtd_reset
Description:
Exit the machine tool driver and performs the corresponding cleanup.
Parameters:
none
Output:
none
Example:
SIM_mtd_reset
SIM_transform_offset_acs_to_mtcs
Syntax:
SIM_transform_offset_acs_to_mtcs <abs_xval> <abs_yval> <abs_zval>
Description:
Transform the position in absolute coordinate system to machine tool coordinate system.
Parameters:
abs_xval,abs_yval,abs_zval – the input position in ACS.
Output:
The variable mom_sim_result contains the transformed offset.
Example:
Example to find the origin of a junction in MTCS
SIM_ask_junction_xform $JNC_name
listToVector offset $mom_sim_result1 3
SIM_transform_offset_acs_to_mtcs $offset(1) $offset(2) $offset(3)
set mtcs_offset $mom_sim_result
SIM_transform_matrix_acs_to_mtcs
Syntax:
SIM_transform_matrix_acs_to_mtcs <m00> <m01> <m02> <m10> <m11> <m12> <m20> <m21> <m22>
Description:
Returns the transformation that transform from coordinate system specified to the machine tool coordinate system (MTCS). The specified transformation is the transformation from ACS to the specific coordinate system that this matrix represents. For example, the specified transformation could be the transformation of the ZCS junction and the returned matrix is the matrix that transforms from ZCS to MTCS.
Parameters:
<m00..m22> the source matrix transformation
Output:
the result transformation matrix (M00 M01 M02 ..) is returned in mom_sim_result variable
Example:
Example to transform from junction coordinate system to MTCS
SIM_ask_junction_xform $JNC_name
listToVector abs_matrix $mom_sim_result 9
listToVector abs_offset $mom_sim_result1 3
SIM_transform_offset_acs_to_mtcs $abs_offset(1) $abs_offset(2) $abs_offset(3)
set offset_zcs_to_mtcs $mom_sim_result
SIM_transform_matrix_acs_to_mtcs $abs_matrix(1) $abs_matrix(2) $abs_matrix(3) $abs_matrix(4) $abs_matrix(5) $abs_matrix(6) $abs_matrix(7) $abs_matrix(8) $abs_matrix(9)
set matrix_zcs_to_mtcs $mom_sim_result
SIM_create_junction
Syntax:
SIM_create_junction <name> <dest_name> <orgX> <orgY> <orgZ> <vecXx> <vecXy> <vecXz> <vecYx> <vecYy> <vecYz> <vecZx> <vecZy> <vecZz>
Description:
Create a junction and attach it to specified component. The origin and coordinate system axes direction in absolute coordinate system are specified. The junction is created immediately.
Parameters:
name: name of junction to be created
dest_comp: name of K-component where the junction is attached.
orgX…: the origin of the junction coordinate system in ACS
vecXx…: the unit vectors of the X,Y and Z axes of the coordinate system.
Output:
none
Example:
Create a junction that coincides with current MCS:
set origin0 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(0) ]
set origin1 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(1) ]
set origin2 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(2) ]
SIM_create_junction CURRENT_ZCS_JCT TABLE $origin0 $origin1 $origin2 $mom_msys_matrix(0) $mom_msys_matrix(1) $mom_msys_matrix(2) $mom_msys_matrix(3) $mom_msys_matrix(4) $mom_msys_matrix(5) $mom_msys_matrix(6) $mom_msys_matrix(7) $mom_msys_matrix(8)
SIM_delete_junction
Syntax:
SIM_delete_junction <name>
Description:
Delete specified junction from KIM. This command is executed immediately.
Parameters:
Name: junction name
Output:
none
Example:
SIM_start_of_simulation
Syntax:
SIM_start_of_simulation
Description:
Create an event that indicates start of simulation
Parameters:
none
Output:
none
Example:
SIM_end_of_simulation
Syntax:
SIM_end_of_simulation
Description:
Create an event that indicates end of simulation.
Parameters:
none
Output:
none
Example:
Syntax:
SIM_activate_tool <tool_name>
Description:
Make the specified tool current. The tool has to be already mounted before this command is issued.
Parameters:
tool_name: the name of the K-component that represents the tool.
Output:
none
Example:
After mounting the tool, make it current:
SIM_mount_tool "15" "UG_NAME" $tool_name "SPINDLE" "SPINDLE_JCT"
set tool_name $mom_sim_result
if {$tool_name != ""} {
SIM_activate_tool $tool_name
}
SIM_set_current_zcs_junction
Syntax:
SIM_set_current_zcs_junction <jct_name>
Description:
Set the current ZCS junction
Parameters:
zcs_jct: the name of the ZCS junction to make current
Output:
none
Example:
SIM_set_mtd_units
Syntax:
SIM_set_mtd_units <units>
Description:
Set the machine tool driver units. All dimensional value to/from S&V commands are in this unit.
Parameters:
units: MM or INCH
Output:
none
Example:
SIM_set_feed
Syntax:
SIM_set_feed <value> <unit> <duration>
Description:
Set the current machine tool feedrate.
Parameters:
value: feedrate value
unit: one of the following values: MM_PER_MIN, INCH_PER_MIN, MM_PER_REV, INCH_PER_REV, MM_PER_100REV
duration: (optional argument) the time it takes the machine tool to execute this command
Output:
none
Example:
SIM_set_speed
Syntax:
SIM_set_speed <value> <unit> <duration>
Description:
Set the current machine tool speed.
Parameters:
value: speed value
unit: only REV_PER_MIN is currently supported
duration: (optional argument) the time it takes the machine tool to execute this command
Output:
none
Example:
SIM_set_coolant
Syntax:
SIM_set_coolant <value> <duration>
Description:
Set the current machine tool coolant state.
Parameters:
value: ON or OFF
duration: (optional argument) the time it takes the machine tool to execute this command
Output:
none
Example:
SIM_set_cutting_mode
Syntax:
SIM_set_cutting_mode <mode>
Description:
Set cutting mode CUT or RAPID
Parameters:
mode: CUT or RAPID
Output:
none
Example:
SIM_set_channel
Syntax:
SIM_set_channel <channel_id>
Description:
Set the current NC channel number where the events will be sent. By default all events are sent to the same default channel. Four-axis lath is an example of application that requires two NC channels.
Currently the system supports only one channel.
Parameters:
Channel_id: the channel number.
Output:
none
Example:
The following is the list of High Level S&V commands. A description of those commands follows.
To have access to those commands, the TCL file sim_high_level_sv_commands.tcl has to be sourced first.
SIM_ask_current_ref_junction - returns the current reference junction
SIM_ask_current_zcs_junction - returns the name of current ZCS junction
SIM_ask_intermediate_update - returns whether or not intermediate updates is set.
SIM_ask_junction_origin_mtcs - returns the current or initial junction origin in MTCS coordinate system
SIM_ask_last_position_mtcs - returns the last reference junction position in MTCS
SIM_ask_last_position_zcs - returns the last reference junction position in ZCS
SIM_ask_linear_axes_config - return the current linear axes configuration
SIM_ask_linear_axes_map - returns the linear axes mapping (logical to physical axis mapping)
SIM_ask_offsets_mtcs - return offsets between two junctions in MTCS coordinates
SIM_ask_rotary_axes_config - returns the current rotary axes configuration )
SIM_ask_rotary_axes_map - returns the rotary axes mapping (logical to physical axis mapping)
SIM_convert_sim_to_mtd_units - converts a specified value from current part/simulation units to MTD units
SIM_invoke - a shell for invoking S&V commands. This avoids command invocation if S&V not active.
SIM_macro_append_sv_cmd - add a s&v command to macro
SIM_macro_call - call a predefined macro
SIM_macro_def - start a definition of new macro
SIM_macro_delete - delete an existing macro
SIM_macro_delete_all - delete all_macros
SIM_macro_end - end definition of a macro
SIM_move_circular_mtcs - move axes in circular mode where coordinates are in MTCS
SIM_move_circular_zcs - move axes in circular mode where coordinates are in ZCS
SIM_move_linear_mtcs - move axes in linear mode where coordinates are in MTCS
SIM_move_linear_zcs - move axes in linear mode where coordinates are in ZCS
SIM_set_current_ref_junction - sets the current reference junction
SIM_set_duration_callback_fct - sets callback TCL function to compute duration of a delta motion
SIM_set_intermediate_update - issue(or not) update axes command after each motion command
SIM_set_linear_axes_config - set the current linear axes configuration
SIM_set_linear_axes_map - set the linear axes mapping (logical to physical axis mapping)
SIM_set_rotary_axes_config - set the current rotary axes configuration
SIM_set_rotary_axes_map - set the rotary axes mapping (logical to physical axis mapping)
SIM_transform_mtcs_to_zcs - transform point from MTCS to ZCS coordinate system
SIM_transform_zcs_to_mtcs - transform point from ZCS to MTCS coordinate system
SIM_update_current_zcs - set current ZCS junction and update ZCS <-> MTCS transformations
High Level S&V Command Syntax
SIM_ask_current_ref_junction
Syntax:
SIM_ask_current_ref_junction
Description:
Returns the name of current reference junction
Parameters:
None
Output:
The function returns the name of the reference junction
Example:
SIM_ask_current_zcs_junction
Syntax:
SIM_ask_current_zcs_junction
Description:
Returns the name of current ZCS junction
Parameters:
none
Output:
The function returns the name of current ZCS junction.
Example:
SIM_ask_current_zcs_junction
Syntax:
SIM_ask_intermediate_update
Description:
Returns whether or not S&V commands will be followed by SIM_update command. By default the system issues a SIM_update command at the end of the high level S&V move commands.
Parameters:
none
Output:
The function returns the current state 1 (yes) and 0 of this flag.
SIM_ask_junction_origin_mtcs
Syntax:
SIM_ask_junction_origin_mtcs <jct_name> <state>
Description:
Returns the origin of the specified junction in the current state of the KIM model if state is CURRENT. If state is set to INITIAL, the origin of the initial state of the junction (before simulation starts) is returned.
Parameters:
jct_name: the name of the junction
state: in what state of KIM model data is requested: INITIAL or CURRENT
Output:
The function returns the junction origin in MTCS as a list of x,y and z coordinates
Example:
set origin [SIM_ask_junction_origin_mtcs JNCT_HEAD_1 INITIAL]
SIM_ask_last_position_mtcs
Syntax:
SIM_ask_last_position_mtcs
Description:
Returns the last position of the reference junction in machine tool coordinate system.
Parameters:
None
Output:
The function returns last position as a list of x,y and z coordinates
Example:
set last_position [SIM_ask_last_position_mtcs]
SIM_ask_last_position_zcs
Syntax:
SIM_ask_last_position_zcs
Description:
Returns the last position of the reference junction in ZCS coordinate system.
Parameters:
None
Output:
The function returns last position as a list of x,y and z coordinates
Example:
set last_position [SIM_ask_last_position_zcs]
SIM_ask_linear_axes_config
Syntax:
SIM_ask_linear_axes_config
Description:
Returns the current list of logical NC axes that will participate in executing the next linear motion command.
Parameters:
none
Output:
The function returns list of NC axes names.
Example:
SIM_ask_linear_axes_map
Syntax:
SIM_ask_linear_axes_map
Description:
Returns a table that maps logical linear axes to physical axes.
Parameters:
none
Output:
The function returns a table of couples. The first member of a couple is the logical axis and the second one is the physical name.
Example:
SIM_ask_offsets_mtcs
Syntax:
SIM_ask_offsets_mtcs <from_jct> <to_jct> <state>
Description:
Return offsets between two junctions in machine tool coordinate system. The offset could be returned i.r.t to the CURRENT state of the KIM model or in its INITIAL state.
Parameters:
from_jct: return offset from this junction name
to_jct: to this junction name
state: CURRENT or INITIAL
Output:
The offset between the two junctions is returned as a list of x,y and z coordinates.
Example:
set vector [ SIM_ask_offsets_mtcs $from_jct $to_jct CURRENT ]
SIM_ask_rotary_axes_config
Syntax:
SIM_ask_rotary_axes_config
Description:
Returns the current list of logical NC axes that will participate in executing the next rotary motion command.
Parameters:
none
Output:
The function returns list of NC axes names.
Example:
SIM_ask_rotary_axes_map
Syntax:
SIM_ask_rotary_axes_map
Description:
Returns a table that maps logical rotary axes to physical axes.
Parameters:
none
Output:
The function returns a table of couples. The first member of a couple is the logical axis and the second one is the physical name.
Example:
SIM_convert_sim_to_mtd_units
Syntax:
SIM_convert_sim_to_mtd_units <value>
Description:
Converts a specified value from current part/simulation units to MTD units
Parameters:
value:
Output:
The function returns the value in MTD units.
Example:
Convert X coordinate of MCS to MTD units.
set origin0 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(0) ]
SIM_invoke
Syntax:
SIM_invoke <S&V command>
Description:
This is a wrapper to S&V commands that validates that MTD has been initialized before the S&V command is issued. This can be useful in posts that issue S&V commands.
Parameters:
S&V command with its arguments
Output:
none
Example:
SIM_invoke SIM_move_linear_mtcs Z $tool_change_pos(2)
SIM_macro_append_sv_cmd
Syntax:
SIM_macro_append_sv_cmd <S&V command>
Description:
Append S&V command to the current macro definition.
Parameters:
S&V command and its arguments
Output:
none
Example:
See example in SIM_macro_call
SIM_macro_call
Syntax:
SIM_macro_call <macro_name>
Description:
Call a predefined macro. All the S&V commands associated with the macro are executed sequentially.
Parameters:
macro_name: the name of existing macro
Output:
none
Example:
This example show how to define a macro (cycle_200) and how to invoke it. This macro is one of the DMU50 drilling cycles.
# start macro cycle_200 definition
SIM_MTD_macro_def cycle_200
# change to rapid mode
SIM_macro_append_sv_cmd " SIM_set_cutting_mode RAPID"
# move rapid delta Z to $mom_cycle_rapid_to
SIM_macro_append_sv_cmd "SIM_move_linear_zcs Z \[ sim_mtd_get_z $mom_cycle_rapid_to \]"
# move rapid delta Z to $mom_cycle_feed_to
SIM_macro_append_sv_cmd "SIM_move_linear_zcs Z \[ sim_mtd_get_z $mom_cycle_feed_to \]"
# change value of mom_cycle_feed_to , set cutting mode and feedrate
set mom_cycle_feed_to [expr abs($mom_cycle_feed_to)]
SIM_macro_append_sv_cmd " SIM_set_cutting_mode CUT"
SIM_macro_append_sv_cmd " SIM_set_feed $mom_cycle_feed_rate INCH_PER_MIN"
# move to bottom of drill
SIM_macro_append_sv_cmd "SIM_move_linear_zcs Z \[ sim_mtd_get_z $mom_cycle_feed_to \]"
# move to retract position
SIM_macro_append_sv_cmd "SIM_move_linear_zcs Z \[ sim_mtd_get_z $mom_cycle_retract_to \]"
# end of macro definition
SIM_MTD_macro_end cycle_200
Here is the definition of the local procedure sim_mtd_get_z. The global variables sim_last_X, sim_last_Y and sim_last_Z are set to the last tool tip position before the macro starts. They way an incremental work i.r.t some starting point can be done.
proc sim_mtd_get_z { z_val } {
global sim_last_X sim_last_Y sim_last_Z
set z [expr $sim_last_Z + $z_val]
return $z
}
Now, somewhere in the NC program the macro is called after positioning the tool at a starting point.
SIM_set_cutting_mode RAPID
SIM_move_linear_zcs X $mom_pos(0) Y $mom_pos(1) C $mom_out_angle_pos(0) B $mom_out_angle_pos(1)
SIM_macro_call cycle_200
SIM_macro_def
Syntax:
SIM_macro_def macro_name
Description:
Start a definition of a new macro. If macro exists, it will be deleted first.
Parameters:
macro_name: the name of the macro
Output:
none
Example:
See SIM_macro_call
SIM_macro_delete
Syntax:
SIM_macro_delete macro_name
Description:
Delete an exiting macro
Parameters:
macro_name: the name of the macro
Output:
none
Example:
See SIM_macro_call
SIM_macro_delete_all
Syntax:
SIM_macro_delete_all
Description:
Delete all macros
Parameters:
none
Output:
none
Example:
See SIM_macro_call
SIM_macro_end macro_name
Syntax:
SIM_macro_end macro_name
Description:
End definition of a new macro
Parameters:
macro_name: the name of the macro
Output:
none
Example:
See SIM_macro_call
SIM_move_circular_mtcs
Syntax:
SIM_move_circular_mtcs <plane vector> <args>
Description:
Do a circular motion. Coordinates are in machine tool coordinates system (MTCS). The function approximates the specified arc by linear segments. The deviation of the segments from the arc is by cording tolerance (set by SIM_set_cording_tol). Each motion of the arc segment is executed by the SIM_move_linear_mtcs command.
The command syntax is very similar to the G02 or G03 G code command. This command syntax covers two types of circular motion formats. One where the center of the arc is explicitly defined and the other one is by the arc radius. Here are four examples of this circular motion format:
The first two examples describe a circular arc in the xy-plane. The other examples describe an arc in space. Examples one and two also represents arcs defined in other orthogonal planes (i.e, X-Z and Y-Z planes). In that case K replaces J or I respectively.
Example one and three uses the co-ordinates of the centre point (M) of the arc given by I 20 J 30 and I 20 J 30 K 34 respectively. The arc direction is determined by the plane vector. The rotation direction is always positive (CCW) i.r.t the specified vector. Figure 1 illustrates the arc direction depending on the plane vector. The end co-ordinates (E) are given by X, Y respective X, Y and Z. The start co-ordinates (S) is the starting point (where the tool is before this motion starts).
Figure : rotation direction for the circular-interpolation in the xy-plane and space by an given centre point (M) and rotation vector
Example two and four uses the radius of the circle arc. There are couple solutions using the radius instead of the centre point as illustrated in next figure.
Figure: center point mode for the circular-interpolation in the xy-plane and space by a given radius
We use the rotation vector and the sign of the radius to determine the right arc. Furthermore we need a simple rule to find the correct centre point:
R>0
® 180° >= rotation angle > 0°R<0
® 360° > rotation angle > 180°It is not permissible to program with the Radius method if the traversing angle is 0 or 360. Therefore full circle must be programmed using the other method.
SIM_move_circular_zcs
Syntax:
SIM_move_circular_zcs <plane vector> <args>
Description:
Do a circular move. Coordinates are specified in ZCS. See detailed description in SIM_move_circular_mtcs
Output:
none
Parameters:
See SIM_move_circular_mtcs
SIM_move_linear_mtcs
Syntax:
SIM_move_linear_mtcs <args>
Description:
This command moves the current reference junction (set by SIM_set_current_ref_junction like tool tip junction) to the target position specified in machine tool coordinate system (MTCS). The linear and rotary axes that participate in achieving the target position are defined by the SIM_set_linear_axes_config and SIM_set_rotary_axes_config respectively.
The arguments that can be passed to the command are very similar to the G01 arguments (just the motion arguments). The target position can be explicitly defined for X, Y, Z and rotary axes. But it can also omit one or more of the coordinates which means that those coordinates don’t change during that motion.
Note that the axes of the MTCS coordinate system are not necessarily aligned with the actual machine tool axes. Although, this could be the common case.
This function also compute the duration of this motion based on the length of the linear and angular displacement and the current feedrate. The actual computation of the duration is computed by a user TCL procedure call back that is set by the S&V command SIM_set_duration_callback_fct.
Parameters:
See details in description
Output:
none
Example:
SIM_move_linear_mtcs X 100 Y 200 Z 300 A 20 B 15
SIM_move_linear_mtcs X 20
SIM_move_linear_mtcs B 100
SIM_move_linear_zcs
Syntax:
SIM_move_linear_zcs <args>
Description:
This command is identical to the SIM_move_linear_mtcs except two differences. First, the coordinates in this command are specified i.r.t ZCS and not MTCS. Second, the ZCS coordinate system is not fixed and can be set by call to SIM_update_current_zcs.
Parameters:
See SIM_move_linear_mtcs
Output:
none
Example:
SIM_move_linear_zcs X 120.3 Y 300.5 A 67.5
SIM_set_current_ref_junction
Syntax:
SIM_set_current_ref_junction <jct_name>
Description:
Set the current reference junction. The reference junction is taken into account in the high level S&V motion commands.
Parameters:
jct_name: name of existing junction
Output:
none
Example:
SIM_set_current_ref_junction TOOL_TIP_JCT
SIM_set_duration_callback_fct
Syntax:
SIM_set_duration_callback_fct <fct>
Description:
Set the callback function that is used to compute the duration of a motion. To get an accurate duration of a motion, one can take into account the acceleration and deceleration feedrate rather than a constant feedrate. The fct prototype should be as follows:
proc CalculateDurationTime { linear_or_angular delta } {
….
set time ….
….
return $time
}
linear_or_angular can get the values LINEAR or ANGULAR. This specifies whether delta, the axis displacment is for linear or rotary axes. The function has to return the time in seconds that will take the machine tool to do this delta motion.
Parameters:
fct: a TCL callback function
Output:
none
Example:
SIM_set_duration_callback_fct CalculateDurationTime
SIM_set_intermediate_update
Syntax:
SIM_set_intermediate_update <flag>
Description:
Set flag whether the high level S&V motion commands calls SIM_update command at the end or not. By default it does.
Parameters:
flag: 1 to call and 0 no to call SIM_update
Output:
none
Example:
SIM_set_linear_axes_config
Syntax:
SIM_set_linear_axes_config <axes-list>
Description:
Set the current list of logical NC axes that will participate in executing the next linear motion command.
Parameters:
axes-list: the linear axes list
Output:
none
Example:
SIM_set_linear_axes_config [concat X Y Z]
SIM_set_linear_axes_map
Syntax:
SIM_set_linear_axes_map <map-table>
Description:
Set the current table that maps logical linear axes to physical axes.
Parameters:
map_table: a list of pairs of logical and physical axes
Output:
none
Example:
SIM_set_linear_axes_map [concat X X_AXIS Y Y_AXIS Z Z_AXIS]
SIM_set_rotary_axes_config
Syntax:
SIM_set_rotary_axes_config <axes-list>
Description:
Set the current list of logical NC axes that will participate in executing the next rotary motion command.
Parameters:
axes-list: the rotary axes list
Output:
none
Example:
SIM_set_rotary_axes_config [concat B C]
SIM_set_rotary_axes_map
Syntax:
SIM_set_rotary_axes_map <map-table>
Description:
Set the current table that maps logical rotary axes to physical axes.
Parameters:
map_table: a list of pairs of logical and physical axes
Output:
none
Example:
SIM_set_rotary_axes_map [concat A A B SP]
SIM_transform_mtcs_to_zcs
Syntax:
SIM_transform_mtcs_to_zcs <x> <y> <z>
Description:
Transforms the point from MTCS to current ZCS coordinate system.
Parameters:
x, y, z: x,y and z coordinate of point to be transformed.
Output:
Returns the transformed point as a list or the three coordinates.
Example:
set pt_zcs [SIM_transform_mtcs_to_zcs $mtcs_x $mtcs_y $mtcs_z]
SIM_transform_zcs_to_mtcs
Syntax:
SIM_transform_zcs_to_mtcs <x> <y> <z>
Description:
Transforms the point from current ZCS to MTCS coordinate system.
Parameters:
x, y, z: x,y and z coordinate of point to be transformed.
Output:
Returns the transformed point as a list or the three coordinates.
Example:
set pt_mtcs [SIM_transform_zcs_to_mtcs $zcs_x $zcs_y $zcs_z]
SIM_update_current_zcs
Syntax:
SIM_update_current_zcs <zcs_jct>
Description:
Set the current ZCS junction to be considered in the high level S&V motion commands. This also updates the transformation from ZCS to MTCS
Parameters:
zcs_jct: the name of the new ZCS junction. Junction must be already created.
Example:
set origin0 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(0) ]
set origin1 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(1) ]
set origin2 [ SIM_convert_sim_to_mtd_units $mom_msys_origin(2) ]
SIM_create_junction CURRENT_ZCS_JCT $dest_cmp $origin0 $origin1 $origin2 $mom_msys_matrix(0) $mom_msys_matrix(1) $mom_msys_matrix(2) $mom_msys_matrix(3) $mom_msys_matrix(4) $mom_msys_matrix(5) $mom_msys_matrix(6) $mom_msys_matrix(7) $mom_msys_matrix(8)
SIM_update_current_zcs CURRENT_ZCS_JCT