• No results found

Motion flow can be configured by using the custom segments "ExactStopCheck" BOOL flag as shown in the examples below.

Setting ExactStopcheck = FALSE (Default)

Any motion commands surrounding the custom code will be not be stopped. For example, an analog or digital output must be synchronized with motion. The custom code will be placed in a monitoring queue to be executed when the motion path (which is likely buffered) actually crosses the preceding coordinate position. In this scenario, Custom_Code_Execute (for the custom code in question) cannot be configured with OKToIncrement logic to control program flow. OkToIncrement will be ignored when ExactStopCheck=FALSE.

Up to 30 custom codes can be deferred for later execution.

Setting ExactStopcheck = TRUE

The custom code will wait for any preceding Motion commands to stop before executing. In this scenario, Custom_Code_

Execute can be customized to allow the program flow (and motion) to continue only after any required conditions have been met. For example, if a heater or pressure reading must be within a required value to proceed. See the OKToIncrement cus-tomization below in Example #1, line 10.

Error Description

See the Function Block ErrorID list.

Example #1 - Setting a BOOL value to the MPiec Controller

Assume a custom M code command "M742" is required to set a BOOL value, and M743 to clear the same BOOL.

Custom_Code_Processor function block

Simply add the custom codes to the CASE statement as shown on line 28. This identifies the codes as recognized by system, and prevents the CASE ELSE condition from setting the "UnsupportedMCode" Error condition.

Custom_Code_Execute function block

Simply add the code as shown on lines 21 and 22. The variable CustomMCode will have the value of 742 or 743 when the CASE statement is executed, and can be used in the logic as shown to set or clear a BOOL variable in a user defined structure ref-erenced in this function as VAR EXTERNAL.

Additionally, choose a program location in the project to link MyAppData.MyBOOL to the relevant device. Consider other logic which may be required to safely operate the device under all machine conditions. Yaskawa recommends adding only the min-imum code to link custom Codes to User structures within the Custom_Code_Execute function and adding additional interlock logic externally.

Example #2 - Write an analog or multiple analog values to a custom user structure on the MPiec Controller.

Assume a custom G code command "G392" is required to set several values, specified in the H, I, J, and Q registers.

G392 H12.5 I550.0 J-0.5 Q11.12

The variable 'ThisSegment' is one of the SegmentDetails in an array of SegmentDetails in the PathData structure. 'ThisSeg-ment' is exclusive to this custom code, so any data element in 'ThisSeg'ThisSeg-ment' can be used without interfering with other pro-cessing in the Group Toolbox. This example shows usage of the Generic LREAL elements provided, and the FeedRate variable, even though the value transferred here may have nothing to do with FeedRate. When implementing custom codes, its only important to link the same data in both function blocks, and consider the datatype.

Custom_Code_Processor function block

Add 392 to the CASE statement as shown on lines 15 through 19.

Custom_Code_Execute function block

Add 392 to the CASE statement as shown on lines 9 through 13.

Once the parameter values are loaded into the MyAppData, use the information in other parts of the project to write the values to the Widget as necessary. Yaskawa recommends keeping the customization code in this block to a minimum, and adding any other necessary logic externally.

Example #3 - Wait for an analog value to be greater than or equal to another value.

Assume that custom G code command M406 indicates the machine must wait until a temperature has reached or exceeded a set point before continuing. In this example, assume MyAppData.TempSetting has been previously set using another custom code or other method.

Custom_Code_Processor function block

Simply add the custom code to the CASE statement as shown on line 34. This identifies the codes as recognized by system, and prevents the CASE ELSE condition from setting the "UnsupportedMCode" Error condition. Three is nothing else to do in the Custom_Code_Processor function. Optionally, the set point could be sent with the custom G Code as a parameter. In that case, copy the TempSetting into ThisSegment.GenericLREAL[0] similar to the example shown on line 16.

Custom_Code_Execute function block

Add the code as shown in lines 27 and 28. Use the OKToIncrement BOOL variable which is returned to MC_MovePath. Setting this variable according to the comparison of the two values allows MC_MovePath to know when it's OK to proceed.

Example #4 Overrides

The ID assigned in the OverrideList function block is added to the base SegmentType of 3000 indicating an override. The ori-ginal ID can be obtained by subtracting 3000 for the ease of programming (See line 45.) Very little code is required in Cus-tom_Code_Procesor, sometimes no code other than to list the ID in the CASE statement to prevent the ELSE condition from returning an Error.

Help version created 2/3/2022 Configuration and Customization

Related documents