Hello Guest it is May 17, 2024, 05:48:09 PM

Author Topic: Button to offset move  (Read 394 times)

0 Members and 1 Guest are viewing this topic.

Offline ROTM

*
  •  24 24
    • View Profile
Button to offset move
« on: April 27, 2024, 03:39:57 AM »
Good day.
I've installed a camera and would like to offset to the router.
How it should work ...when I see in the camera a point where id like to drill something.
Press button and the router will move to this point.(let say the offset is x2,y2)

I looked at several post and came to these 2
local inst = mc.mcGetInstance();
mc.mcCntlGcodeExecute (inst, "G52 X2 Y2");

or
local inst = mc.mcGetInstance() mc.mcMdiExecute(inst, “G52 X2 Y2”)

Will these work or am I missing something?

Thank you!
Re: Button to offset move
« Reply #1 on: April 29, 2024, 12:56:49 PM »
I don't use G52, but from my understanding it is a shift from the current work offset.
So unless you are going to set the work offset at your camera point, I'm not sure this will do what you want.
If you want to just move the router when you are at your camera point... you can use the mdi execute command with this code:
mc.mcMdiExecute(inst, "G91 G00 X2.00 Y2.00)
mc.mcMdiExecute(inst, "G90")

G91 is incremental... it is also modal.  Be sure to have the G90 line after your move to put it back into absolute instead of keeping it in incremental or you'll really get messed up.
Chad Byrd

Offline Bill_O

*
  •  565 565
    • View Profile
Re: Button to offset move
« Reply #2 on: April 29, 2024, 05:20:44 PM »
i use a head shift for different tools on the head.

mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_X, 0.000) --head shift to 0.000 in x
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, 0.000) --head shift to 0.000 in y
instead of 0.000 put the distance you need from the spindle to the camera
then do a g0 to the position the head was in


Offline ROTM

*
  •  24 24
    • View Profile
Re: Button to offset move
« Reply #3 on: May 01, 2024, 12:10:41 AM »
Thanks for the reply I am going to give it try...

How would you do to for instance
you can zero when you are at the desired point in the camera then push the button to run the code to move the bit where the center of the camera was.

but lets say you stop at a certain spot push a button without zero and it will move the bit to the center of the camera....push the same button again and now it moves the center of the bit where the camera was....like reversing the position...man I am tired of reading...lol

Thank you!

Offline Graham Waterworth

*
  • *
  •  2,683 2,683
  • Yorkshire Dales, England
    • View Profile
Re: Button to offset move
« Reply #4 on: May 02, 2024, 11:31:56 AM »
You could set a button to set X & Y axis to the offset values and move to the position with a something like :-

Put this in the button scrip:-

Code "G92 X2. Y2." (set axis to new values)
Code "G00 G90 X0 Y0" (move to zero)
Without engineers the world stops

Offline ROTM

*
  •  24 24
    • View Profile
Re: Button to offset move
« Reply #5 on: May 02, 2024, 11:55:47 PM »
I got somewhere with this simple one
---------------------------------------------------------------
-- Move bit to camera function.
---------------------------------------------------------------
function Bitcammove()
RememberPosition()
mc.mcCntlSetLastError(inst, "Moving bit to camera position")
mc.mcCntlGcodeExecute(inst, "G1 X-1.2859 Y-2.6913 F20" )
end

---------------------------------------------------------------
-- Move Camera to bit function.
---------------------------------------------------------------
function Cambitmove()
mc.mcCntlSetLastError(inst, "Moving camera to bit position")
mc.mcCntlGcodeExecute(inst, "G1 X0 Y0 F20")
end

I added the remember position but do not know how to call back.
It works for now...

When I tried this one
Code "G92 X2. Y2." (set axis to new values)
Code "G00 G90 X0 Y0" (move to zero)

I do not know what happened and the value for x zero was changed...I had reinstalled Mach4 for probabaly the 15th time :/

but my Mach 4 is laggy even with a new computer.

attached is a pic of the final idea...but I will need to try to figure out how to add different button to record a position and then another button to move to the recorded position. This camera setup is when I have small things to machine.

Also attached a pic of what it looks like in my Mach4.

Offline Graham Waterworth

*
  • *
  •  2,683 2,683
  • Yorkshire Dales, England
    • View Profile
Re: Button to offset move
« Reply #6 on: May 03, 2024, 06:52:53 PM »
How many hole positions are you wanting to return to?

If its just a few you could set some #vars to the position use #1500 to #1599 or you could set the G59.x fixture values using a G10 L command or one of many other ways.

An explanation of what you are trying to achieve would help.
Without engineers the world stops

Offline ROTM

*
  •  24 24
    • View Profile
Re: Button to offset move
« Reply #7 on: May 03, 2024, 10:39:56 PM »
Good day.
How it should work...
You move the center of the camera to one edge of the workpiece > click button record position A button
You move the center of the camera to other edge of the workpiece > click button record position B button
Click button move to the center of A and B and the camera should go into the middle of point A and B
and if you want to machine there > click the button move bit to cam position so the bit will go where the cam center was and then you could drill there

The buttons move to A and the B positions if for any reason you need to go back to those points.
This would be for the x axis.....

but in the end pic attached
you go to the piece record position 1,2 click center button...then 3 and 4 click center button then you have the center of the item to be machined.> click move bit to cam position and then machine the piece.

if there is a more efficient way to do this please let me know.
 
Thank you!