Hello Guest it is April 19, 2024, 03:39:44 PM

Author Topic: Parameter setting usage with subroutines  (Read 6675 times)

0 Members and 1 Guest are viewing this topic.

Parameter setting usage with subroutines
« on: May 11, 2012, 05:15:13 PM »
Having got on top of subroutine syntax ( for the moment anyway ! ) I am still trying to produce a chequer plate pattern using nested subroutines to repeat a small block many times to produce the size of chequer plate that I need.

# parameters look like an answer to a maiden ( programmer's prayer ) but Mach3 just skips through the main program without doing anything.

Can anyone spot what I am doing wrong?  My first efforts are attached, I have taken line numberhe parameter setting lines in case that was causing problems.  The subroutines cutting the chequer plate square O4321 and O1234 work OK if I get rid of all the offset shifting sub routines O444 and O555 and hard code a few moves.

Regards,

Andrew
Re: Parameter setting usage with subroutines
« Reply #1 on: May 11, 2012, 06:30:19 PM »
Hi Andy,
  I didn't get to look at you code closely, but check out this thread.
 http://www.machsupport.com/forum/index.php/topic,11360.msg71968.html#msg71968
These guys helped me out superbly, might be just what you want. ?
Russ

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Parameter setting usage with subroutines
« Reply #2 on: May 11, 2012, 06:37:19 PM »
How many rows and columns ?

(;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Parameter setting usage with subroutines
« Reply #3 on: May 11, 2012, 07:07:50 PM »
Just glancing throught the code you are using 0 in the your sub names instead of o. Just a suggestion always USE a lower case o for the Oword.

That at least will let you see what you have to work on Looks like your spacing is off.  Is each space suppose to have 2 passes one LH one RH ? or is it suppose to shift 1space up and 1 space over ?

Just throwing out some points of interest(;-)

IF you use the VAR Monitor you will be able to SEE the #var values "realtime". RUn the program in single block mode and step through the Gcode. 

You are close(;-)

(;-) TP

« Last Edit: May 11, 2012, 07:09:25 PM by BR549 »
Re: Parameter setting usage with subroutines
« Reply #4 on: May 13, 2012, 01:42:02 PM »
Thanks very much!  As usual it is the obvious thing that is staring you in the face all the time, the subroutine labels were all numerics in a couple of cases.  Corrected them and it ran straight away!  The lowercase tip for sub routine names is a useful one. 

The program now works well.  Each square has two passes at 90° to each other to form the chequer plate and then that square is repeated across the width with one subroutine and done the length with the higher level one.

I also had a look but Russ's link and intend to go back and study that further.  I must also look at the VAR monitor as that will be useful in future.

Once again the forum has come up trumps,

Thanks Guys,

Andrew

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Parameter setting usage with subroutines
« Reply #5 on: May 13, 2012, 08:00:59 PM »
GEE you could have posted the working CODE as a reference for others. (;-)

Just a thought,

(;-) TP
Re: Parameter setting usage with subroutines
« Reply #6 on: May 14, 2012, 08:03:46 AM »
Sorry!  Didn't think of others struggling like me!  Thanks for the nudge.  I have added more comments to clarify what the program is doing.  It runs on Mach3 on my desktop but I have no reason to suspect it won't run on the mill cutting metal.

Hope someone finds it useful, the same principle could be applied to any sort of repetitive machining.  Use G52 to shift the origin around and then do the repeats with parameter variables.  I could eliminate more code by using calculated parameters but this way the method is more visible.

Thanks for the help which got me to this point.

Regards,

Andrew

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Parameter setting usage with subroutines
« Reply #7 on: May 14, 2012, 06:59:04 PM »
Thanks Andrew ANYTIME there is an example of how things work MANY will benifit from it.

Good Job,

(;-) TP