Hello Guest it is March 28, 2024, 05:58:19 PM

Author Topic: machine running irregular on button script  (Read 18793 times)

0 Members and 1 Guest are viewing this topic.

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: machine running irregular on button script
« Reply #10 on: December 14, 2010, 07:20:00 AM »
Here is how I would do it, all you have to do is create the M1234 macro to store the points in an array and a M1235 macro to store it after you finish.

Graham

%
G21 G40 (standard setup lines)

#1=[20.] (spacing in X)
#2=[20.] (spacing in Y)
#3=10 (no of points in X)
#4=15 (no of points in Y)

G00 G43 H3 Z25.00
G00 X0 Y0 (set position of first hole/point as X0 Y0)
M98 P1000 L#4 (repeat #4 times)
M1235 (store the vb data array)
M30

O1000 (this bit moves Y axis)
M98 P1001 L#3 (repeat #3 times)
G91 (set to move incremental)
G00 Y#2 (do move to next line)
G90 X0 (set to absolute and go back to start of line)
M99

O1001(this bit moves X axis)
M98 P1002 (call probe sub)
G91 (set to incremental)
G00 X#1 (do move to next point)
G90 (back to absolute)
M99

O1002 (this sub probes)
G00 Z1.
G31 Z-5. F200.
M1234 (call vb macro to store values in array)
G4 P500
G00 Z1.
M99
%
« Last Edit: December 14, 2010, 08:50:39 AM by Graham Waterworth »
Without engineers the world stops
Re: machine running irregular on button script
« Reply #11 on: December 14, 2010, 08:16:02 AM »
Graham, you are the MAN!!

Reading around a little I already found some info.
I was beginning to see the light.....far away...
But this brings it all together! THANKS!


It seems that you can do a lot more with g-code than it looks like on first hand.
My CAM software spits out g-code to easy to study it in depth.
I know what G0 G1 G2 etc is..that's it... 
But now it shows that it might be VERY usefull to make it your second language...  ;D

I will try to do the "writing"-macro's myself. ::)

Thanks Again!!

Rich

 
 

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: machine running irregular on button script
« Reply #12 on: December 14, 2010, 08:52:45 AM »
No problem, if you want to test run the code just change the G31 line to something like G01 Z-1. F200. and Mach3 will simulate the moves for you.

Graham
Without engineers the world stops
Re: machine running irregular on button script
« Reply #13 on: December 14, 2010, 09:37:24 AM »
I have already loaded the code into Mach in offline mode to see what is happening.
M1234 and M1235 are still missing...

Regarding to the M1234 (probe values to array) macro I have some questions.

Will a variable like #3 be "carried over" to the macro?  (this to set the size of the array)
How to avoid the array is re-declared every time the macro is called?? Do I need to use the ReDim Preserve command?

And just to be sure..I guess I need GetVar(2000) etc to write the values to the array...??

Pfff...I am just a dutch truckdriver in daily life... so please be (stay!) kind to me...  ;D

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: machine running irregular on button script
« Reply #14 on: December 14, 2010, 11:31:12 AM »
The GetVar(n) command will allow you to pick up the # variables in VB, n being the # number you require. xstep=GetVar(1)

You may have to set up another M code to initialise the array as global at the start of the g-code.

I have not used the redim command in Mach3 so I would not like to say, maybe somebody else has and will chip in on the subject.

Make sure you save the macros in the macro folder for the profile you are using.

Graham
Without engineers the world stops
Re: machine running irregular on button script
« Reply #15 on: December 14, 2010, 12:00:05 PM »
Thanks again, Graham.

You've more than put me in the right direction.

Now it is time for me to stop asking and start working. :D

Rich

Re: machine running irregular on button script
« Reply #16 on: December 14, 2010, 01:33:21 PM »
I'm thinking the scope of the array will not extend beyond the instance of the script it resides in.  In other words, every time you call M1234, you'll be dealing with a new empty array rather than one array with global scope.  In VB.NET I would just create a global array but I'm not sure if that's possible in VB script.  If, as Graham suggests, you are able to create a global array via a macro, I'd be curious to see how you did it.  Not saying it can't be done, just never tried it and curious if it's possible.

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: machine running irregular on button script
« Reply #17 on: December 14, 2010, 02:33:52 PM »
I am not sure it can be done ether but if not there are other ways to do it.

Graham
Without engineers the world stops
Re: machine running irregular on button script
« Reply #18 on: December 14, 2010, 05:29:33 PM »
Hi,

Working on the macro's... but no results... :-[

As rrc1962 already suggests I am having trouble letting the array survive when the M1234 macro is left for the next probing step.

I have tried making another macro to start with, M1233

It only contains the following line:
    Public arrXYZ(999, 2) As Double

First, I found that

   Dim arrXYZ(GetVar(3) * GetVar(4), 2 ) As Double

is not allowed.  GetVar is giving an error here.

Also, in M1234

   arrXYZ(0,0)= GetVar(2000)

Will not work. The array is not recognized as such.

I am happy things are not easy, life would be boring  :-\

But how are others writing their probing-values???

I hope I find the answer before someone gives it to me.
Nothing would be left of my selfrespect ;D

   

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: machine running irregular on button script
« Reply #19 on: December 14, 2010, 05:33:28 PM »
The mach saved points file works fine open it with g40 assign a name then close with g41 when you are all done probing. Each time the probe trips it auto writes the values of xyza to the file. That way there is little to no VB interaction to cause problems.

But that is just my approach, (;-) TP