I have no experience with your control, but, on Fanuc, one does not need to use G10 at all if the machine is macro-enabled, and system variables are available.
Hello.
I need to write a macro for using current machine coordinates and G10 to write G54. This is on a Yasnac MX3 control. I have enabled M54 and used O9030, and I can set the work coordinates to zero (G10 Q2 P1 X0 Y0). Problem is, I would like to not type work coordinates each time I pick up the part.
I would like someone to explain how the variables work in this application. Is it as simple as:
O9030
G10 Q2 P1 X[#5021] Y[#5022];
M99
#5021=X axis current absolute machine position
#5022=Y axis current absolute machine position
This is my first time trying to program using a macro, so please be patient.
Thank you
Rick
Similar Threads:
I have no experience with your control, but, on Fanuc, one does not need to use G10 at all if the machine is macro-enabled, and system variables are available.
Hi Sinha;
The same will apply for the Yasnac control as for the Fanuc. I also would rather use System Variables in a Macro Program than G10, but the structure of the Macro would be similar for each system.
To frizi,
I would expand on your application by calling the Macro with a Custom G or M Code and pass a number to specify which Workshift Offset to deal with rather than restricting the Macro to only being able to set G54. Example follows:
G101 S1 (VALID NUMBER TO PASS - 1 TO 6) (MACRO CALL OF O9010)
O9010
IF [[#19 LT 1] OR [#19 GT 6]] GOTO100 (ERROR TRAP FOR INVALID WORK SHIFT NUMBER)
#1 = #4003 (SAVE GROUP 03 G CODE)
G90 G10 Q2 P#19 X[#5021] Y[#5022]
G#1 (RESTORE GROUP 03 G CODE)
GOTO900
N100 #3000 = 1 (INVALID WORK SHIFT - FIX)
N900
M99
Regards,
Bill
Hello,
I have been using yasnac manuals and internet resources to try and learn macro programing for I80 and J300 Matsurras. Today I made a macro to automate the process of using a edgefinder. I used G10 to set the work offsets with variables for the P and J value.I saw this thread before work and I borrowed this line for the error traps.
IF [[#19 LT 1] OR [#19 GT 6]] GOTO100 (ERROR TRAP FOR INVALID WORK SHIFT NUMBER)
It got me thinking of how would I check to make sure the value of #19 is a integer without six IF commands. It would be 28 for the J values.
Now that I am thinking about it the answer probably involes making a DO WHILE loop. I can not post the code because I do not have internet access with work computers. I did manage to get my macro to work.
I did not see reference to the OR command in the yasnac manual. Is the manual leaving out other commands I should know about?
Regards,
Jeff
Hello,
I have been using yasnac manuals and internet resources to try and learn macro programing for I80 and J300 Matsurras. Today I made a macro to automate the process of using a edgefinder. I used G10 to set the work offsets with variables for the P and J value.I saw this thread before work and I borrowed this line for the error traps.
IF [[#19 LT 1] OR [#19 GT 6]] GOTO100 (ERROR TRAP FOR INVALID WORK SHIFT NUMBER)
It got me thinking of how would I check to make sure the value of #19 is a integer without six IF commands. It would be 28 for the J values.
Now that I am thinking about it the answer probably involes making a DO WHILE loop. I can not post the code because I do not have internet access with work computers. I did manage to get my macro to work.
I did not see reference to the OR command in the yasnac manual. Is the manual leaving out other commands I should know about?
Regards,
Jeff
Last edited by Needshave; 02-11-2016 at 04:22 AM. Reason: Reposted by accident
Hello Jeff,
You could use FIX, or FUP to round the base variable down, or up respectively and then compare the value with the original number. For example, you could do something like the following:
IF [FUP[#19] NE #19] GOTO200 (ERROR TRAP FOR NON INTEGER NUMBER)
If the above Conditional Statement tests true, then #19 is NOT an integer.
Regards,
Bill
Thank you Bill. I did come up with a way after posting last night. It used a WHILE DO loop and is six lines of code. If the numbers matched it was going to GOTO out of the loop. I'm not sure if that is legal. Your way is much cleaner.
But jumping inside a WHILE loop is illegal.
There is one exception, however. If you jump outside, you are allowed jump inside after executing a few outside blocks.
There would be no syntax error. It should only be logically correct.
The control only does not like a standalone END block.
I can recall a discussion with Stevo1 on this issue several years back. I still remember the analogy I gave: "It is like filing a divorce petition, and withdrawing it before the date of hearing!"
Last edited by sinha_nsit; 02-12-2016 at 10:53 AM.