Hello Guest it is March 28, 2024, 05:39:11 AM

Author Topic: Buttons and the script/gcode  (Read 3633 times)

0 Members and 1 Guest are viewing this topic.

Re: Buttons and the script/gcode
« Reply #10 on: February 12, 2019, 01:14:37 PM »
THANKS again MN300
On my way.
Kenneth
Re: Buttons and the script/gcode
« Reply #11 on: February 12, 2019, 01:39:23 PM »
one more thing please ?
can i get mach4 to reopen to the last start it was in ?
like x0 y0 z.2.   right now it starts all axis at zero.
THANKS
Kenneth
Re: Buttons and the script/gcode
« Reply #12 on: February 12, 2019, 02:49:57 PM »
Hi,
some of those questions are answered here:

https://www.machsupport.com/forum/index.php?topic=39111.msg263977#msg263977

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Buttons and the script/gcode
« Reply #13 on: February 12, 2019, 03:27:35 PM »
Hi Kenneth,
this thread should be in the Mach4 General Discussion board to get maximum exposure.

If I understand you want the machine to move to 0,0,0.1......is that correct?

Do you want a button on Mach's screen OR do you want a macro like m100 that you can MDI?

Quote
can i get mach4 to reopen to the last start it was in ?
like x0 y0 z.2.   right now it starts all axis at zero.

Yes, that can be done, although I suspect your intention has  flawed logic.

If you want the DRO's to read a certain set of numbers on start up, that can be done. What happens though if the machine
has stopped hard to the left, front and top at the end of the last session. Now you start a new session and the DRO's
display 0,0,0.1 when the machine is in its last position? It doesn't make sense.

I think that what you are trying to do, exactly as I did or at least tried years ago, was to devise some means of being able to
turn Mach on and it magically knew where it is and display its position on the DROs. If that is the case you are going to
be disappointed. There are a few workarounds and tricks that can be used to accomplish what you want with fair accuracy,
but those tricks and workarounds are actually harder to understand and implement than using 'homing' or 'referencing'
in the first place.

Can you explain what it you want to achieve and why?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Buttons and the script/gcode
« Reply #14 on: February 12, 2019, 04:31:04 PM »
i'm sorry, i should have explained better. when i finish a job. i have the axis
going tom Z.2 then X0 Y0. when i finish for the day, i leave it there. i do turn
off the controller and understand it's not a good idea to assume that
the machine is still in that exact position when turned back on. but my job doesn't require the precise
measurement as i make boxes from stock and the the zero of the stock is a little
off from my vice(corner X0 Y0 Z.2) where i start my cut.
      thanks for ALL ya'll help !
Kenneth
Re: Buttons and the script/gcode
« Reply #15 on: February 12, 2019, 04:35:45 PM »
Hi,
yes that is what I thought, many newcomers have tried to do exactly that.

The problem is even if you can cause the DROs to reflect the actual position, that is where you left it,
you cannot programmatically set the machine coordinates.

https://www.machsupport.com/forum/index.php?topic=39309.0

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Buttons and the script/gcode
« Reply #16 on: February 12, 2019, 05:17:08 PM »
it worked great in mach3. always x0 y0 z.2 where i left it.
why mach4 different? script i guess. but thanks.... i'll have to live with it.
Kenneth
Re: Buttons and the script/gcode
« Reply #17 on: February 12, 2019, 06:10:27 PM »
Hi,
no, you can't set the machine coordinates in Mach3 programmatically either. If all you want is the DROs to read
0,0,0.1 when you start up, that's easy. In Mach4 it requires a script of a few lines, easy.

That does not accommodate the machine coordinates however. The fact that you used this method in Mach3 suggests that you
don't care about machine coordinates and so it would work in Mach4 in exactly the same way.

Woe betide you if you issue a G28 or similar!

The correct way to do it, and if you worked on an industrial machine you would, when you turn it on you would 'reference'
or 'home' it and then MDI g0 x0 y0 z0.1. The machine coordinates would remain referenced for the remainder of your
working day.

If you fit home switches to your machine you could do exactly the same thing.

If you don't have or don't want to fit home switches, then your machine coordinates are all 'over the shop' and if you crash
because of it its your fault.

If you want a script to write the DROs on start up let me know, I will help.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Buttons and the script/gcode
« Reply #18 on: February 12, 2019, 06:28:11 PM »
THANKS joeaverage, i really don't use machine coordinates as i never reach my limits
or make anything bigger than say ten inches in the X and three inches in the Y. my limits are
X fifty four and Y a little over ten(a knee mill). i just use the readout from the DRO and
do nicely. i really have NO idea where my coordinates really are.(have to make a coor DRO i guess)
   i made a button to make the mill move to X0 Y0 Z.2, but then i'm .4" from my zero  :)
i think i just have to leave my mill all at zero and live with it.
Thanks again !

p.s. i DO have a coordinate DRO in mach3, but never look at it.
i make boxes for PC boards out of aluminum(small boards:)
Kenneth
Re: Buttons and the script/gcode
« Reply #19 on: February 12, 2019, 07:21:31 PM »
Hi,
OK you don't really care about machine coordinates. To be honest I think that is a mistake. I used to have a few
crashes until I fitted Home switches and 'took control' of my machine coordinates and have had only one crash in the four
years since.

Quote
p.s. i DO have a coordinate DRO in mach3, but never look at it.

You have the same in Mach4. See the pic attached.

What you really require is when you turn on Mach (and enable it) that the machine 'Homes in Place' and then
applies a work offset so that your DROs read 0,0,0.2

Here is some code to do it:

Code: [Select]
function m666()
local inst=mc.mcGetInstance()
mc.mcAxisDerefAll(inst)
mc.mcAxisSetHomeInPlace(inst,mc.X_AXIS,1)
mc.mcAxisSetHomeInPlace(inst,mc.Y_AXIS,1)
mc.mcAxisSetHomeInPlace(inst,mc.Z_AXIS,1)
mc.mcAxisHomeAll(inst)
mc.mcAxisSetPos(inst,mc.X_AXIS,0.0)
mc.mcAxisSetPos(inst,mc.Y_AXIS,0.0)
mc.mcAxisSetPos(inst,mc.Z_AXIS,0.2)
end
if (mc.mcInEditor()==1) then
m666()
end

By way of explanation;
mc.mcAxisDeRefAll()   dereferences any axis that happens to be already homed, unlikely at start up but just to be sure....
mc.mcAxisSetHomeInPlace() just is to make sure that your machine can home in place, I know that you don't have home switches
so the machine should therefore home in place by default.....its just the 'fault' part of 'default' that I don't trust!
mc.mcAxisHomeAll() will now cause your machine to be referenced TO ITS CURRENT LOCATION. Thus if you were to look at the
machine coordinates you would see that the position 0.2 above the corner of your vice will be 0,0,0 (machine coordinates)
mc.mcAxisSetPos() sets the DRO and implies a matching work offset.

This code should be in Mach4Hobby/Profiles/<your profile name>/Macros as:
m666.mcs  The reason for the m666 is because its 'devil' code, to be used at your own risk ::)

You could open the Zero Brane editor, paste the code in and then <save as> and browse to your profiles macro directory.

The last thing you need to do is ensure that the macro will run at start up, or more specifically the initial Enable of
Mach after start up. This has been provided for in Configure/Control/General/Initialisation Codes.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'