# Camera and laser offset, and finding center between 2 points

**URL:** <https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169>\
**Category:** General Chat\
**Created:** [April 26, 2024, 7:48pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169 "2024-04-26T19:48:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [April 26, 2024, 7:48pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/1 "2024-04-26T19:48:30Z")

</div>

Good day.  
I finally installed a small microscopic camera on the machine.(i will probably set a laser crosshair as well in the future)  
Where can I find info on setting the offset between the center of the microscope to the router, plasma and laser?

Also If I have 2 points …let say I move the machine to a point then to another…what would be the fastest way to get the center…

In example set 2 points \> click a programmed button and it will move the machine to the center of those points. (this would be a great time saver)

Thank you!

---

<div class="post-metadata">

**Author:** ![Eric](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/eric/32/3220_2.png) [@Eric](https://forum.avidcnc.com/u/Eric)\
**Post date:** [April 26, 2024, 10:41pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/2 "2024-04-26T22:41:50Z")

</div>

I think what you’re looking for is a G52 shift:

> **[Mach4%20Mill%20GCode%20Manual.pdf](https://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Mill%20GCode%20Manual.pdf)**
>
> 967.70 KB

Check that document for it. This will shift the coordinate system away from the spindle coordinates whatever amount you want.

A technique you could use is to zero XY on a point and then put your camera on that same spot and G52 offset whatever amount you have travelled to get there.

What camera are you using?

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [April 27, 2024, 3:31am UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/3 "2024-04-27T03:31:45Z")

</div>

I bought a supereyes camera…

I am trying to do this as well… [Quicktip Mach4: Kamera und Mikroskop anschließen (youtube.com)](https://www.youtube.com/watch?v=ZgWkOa7EgDA)

I managed to get the camera working in Mach4 after hours of trying …rebooted windows and now it shows 😕  
Now I need to figure out how to program these buttons…

---

<div class="post-metadata">

**Author:** ![jjneeb](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/jjneeb/32/244_2.png) [@jjneeb](https://forum.avidcnc.com/u/jjneeb)\
**Post date:** [April 27, 2024, 7:44pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/4 "2024-04-27T19:44:49Z")

</div>

> [@ROTM](#):
>
> Where can I find info on setting the offset between the center of the microscope to the router, plasma and laser?

You can do an offset as Eric said, or you can write a function that adds an offset to your X, Y, and Z offsets if you want. That is how I do it for my laser’s touchplate rod. I run the touchplate routine on the rod thats mounted to my laser head, and then run the offset code that just adds the offset between where the rod is and the laser beam (which i have gotten through characterization).

The function code is:

* * *

## – This function is used to set X, Y, and Z offsets from a probe that is offset – from the actual tooling. First you use a touchplate and a probe to set the offsets to that reference, – and then you run this function to adjust the work coordinates with respect to the probe to tooling offset. – In the case of a laser, there is an additional Z parameter called focus offsets that lets you enter – an additional offset to adjust focus height. This value is just added to the other Z offset, but it allows – the user to set a fixed offset for the probe offset, and then just adjust the focus parameter based on the job’s – beam requirements. – NOTE: This Function should be executed AFTER the touchplate is used to set the Z of the Laser nozzle.

function SetOffsetsforLaser()  
local inst = mc.mcGetInstance(“SetOffsetsforLaser()”)

```
if not (pf.IsHomed()) then
wx.wxMessageBox("Machine is not homed, it is not safe to perform this move")
do return end
end	

```

–Get DRO settings  
local XOffset = scr.GetProperty(‘droOffsetX’, ‘Value’) --gets dro  
XOffset = tonumber(XOffset) --convert string to number

```
local YOffset = scr.GetProperty('droOffsetY', 'Value') --gets dro
YOffset = tonumber(YOffset) --convert string to number

local ZOffset = scr.GetProperty('droOffsetZ', 'Value') --gets dro
ZOffset = tonumber(ZOffset) --convert string to number

local LaserFocusHeight = scr.GetProperty('droLaserZ', 'Value') --gets dro
LaserFocusHeight = tonumber(LaserFocusHeight) --convert string to number

```

–Check that DRO settings are valid  
if ((XOffset \< -5) or (XOffset \> 5)) then --check for valid XOffset. Adjust as needed for your machine  
wx.wxMessageBox(“X Offset must be between -5 and +5”)  
do return end  
end

```
if ((YOffset < -5) or (YOffset > 5)) then --check for valid YOffset. Adjust as needed for your machine
wx.wxMessageBox("Y Offset must be between -5 and +5")
do return end
end	

if ((ZOffset < -5) or (ZOffset > 5)) then --check for valid ZOffset. Adjust as needed for your machine
wx.wxMessageBox("Z Offset must be between -5 and +5")
do return end
end	

```

if ((LaserFocusHeight \> 0) or (LaserFocusHeight \< -0.500)) then --check for valid Laser Focus height  
wx.wxMessageBox(“Laser Focus Height must be \<= Zero and \> -0.500”)  
do return end  
end

–Print out values in log history   
mc.mcCntlSetLastError(inst, "\*\*\*\* X Offset is: " ..XOffset)  
mc.mcCntlSetLastError(inst, "\*\*\*\* Y Offset is: " ..YOffset)   
mc.mcCntlSetLastError(inst, "\*\*\*\* Z Offset is: " ..ZOffset)   
mc.mcCntlSetLastError(inst, "\*\*\*\* LaserFocusHeight is: " ..LaserFocusHeight)

–set new X Work Coordinates   
local CurrentWorkCoordXAxis = mc.mcAxisGetPos(inst, mc.X\_AXIS) --Get current X axis work coord  
CurrentWorkCoordXAxis = tonumber(CurrentWorkCoordXAxis) --Convert string to number  
mc.mcCntlSetLastError(inst, "\*\*\*\* Current X Axis Work Coordinate is: " ..CurrentWorkCoordXAxis)

```
local NewWorkCoordXAxis = CurrentWorkCoordXAxis + XOffset
mc.mcCntlSetLastError(inst, " **** Setting New X Axis Work Coordinate to: " ..NewWorkCoordXAxis)

mc.mcAxisSetPos(inst, mc.X_AXIS, NewWorkCoordXAxis)

```

–set new Y Work Coordinates   
local CurrentWorkCoordYAxis = mc.mcAxisGetPos(inst, mc.Y\_AXIS) --Get current Y axis work coord  
CurrentWorkCoordYAxis = tonumber(CurrentWorkCoordYAxis) --Convert string to number  
mc.mcCntlSetLastError(inst, "\*\*\*\* Current Y Axis Work Coordinate is: " ..CurrentWorkCoordYAxis)

```
local NewWorkCoordYAxis = CurrentWorkCoordYAxis + YOffset
mc.mcCntlSetLastError(inst, " **** Setting New Y Axis Work Coordinate to: " ..NewWorkCoordYAxis)

mc.mcAxisSetPos(inst, mc.Y_AXIS, NewWorkCoordYAxis)

```

–Set new Z work coordinates   
local CurrentWorkCoordZAxis = mc.mcAxisGetPos(inst, mc.Z\_AXIS) --Get current Z axis work coord  
CurrentWorkCoordZAxis = tonumber(CurrentWorkCoordZAxis) --Convert string to number  
mc.mcCntlSetLastError(inst, "\*\*\*\* Current Z Axis Work Coordinate is: " ..CurrentWorkCoordZAxis)

```
local NewWorkCoordZAxis = CurrentWorkCoordZAxis + ZOffset + LaserFocusHeight
mc.mcCntlSetLastError(inst, " **** Setting New Z Axis Work Coordinate to: " ..NewWorkCoordZAxis)

mc.mcAxisSetPos(inst, mc.Z_AXIS, NewWorkCoordZAxis)

```

end

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [April 29, 2024, 9:42pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/5 "2024-04-29T21:42:50Z")

</div>

Thank you…I am going to give it a try…I am almost where I want to be with this machine…so I can try the rotary

---

<div class="post-metadata">

**Author:** ![ROTM](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ROTM](https://forum.avidcnc.com/u/ROTM)\
**Post date:** [May 3, 2024, 8:20pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/6 "2024-05-03T20:20:10Z")

</div>

I got it working in the most basic way…I will try to use someparts of the code as I not need to use z values…trying to learn here…trying to figure out how to save and run stored points which I think is in the above code…  
on top of that my Mach4 in edit mode is lagging badly so everything takes about 4 times longer lol.

Below a pic of the working cam and the setup where I would like to have in the end.

 ![MACH4CAMERA](https://canada1.discourse-cdn.com/flex027/uploads/avidcnc/original/2X/7/739cadf52b1f7ce786ac5aad1cb1a9029a337f1d.jpeg)  
 ![camworx](https://canada1.discourse-cdn.com/flex027/uploads/avidcnc/original/2X/c/ce7b3ecfd1d4e2c90ed8f1feda82ddb5c96585fa.jpeg)

---

<div class="post-metadata">

**Author:** ![Hulign](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@Hulign](https://forum.avidcnc.com/u/Hulign)\
**Post date:** [May 6, 2024, 11:09pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/7 "2024-05-06T23:09:06Z")

</div>

Well this is a cool project.Thanks for posting it. I need to be able to do something similar I wonder if it’s possible to use a camera setup locate 2 points and do a g68 to rotate the cut data to match the angle of the part being cut? Hopefully that makes sense.

---

<div class="post-metadata">

**Author:** ![jjneeb](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/jjneeb/32/244_2.png) [@jjneeb](https://forum.avidcnc.com/u/jjneeb)\
**Post date:** [May 7, 2024, 4:58pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/8 "2024-05-07T16:58:13Z")

</div>

> [@Hulign](#):
>
> I wonder if it’s possible to use a camera setup locate 2 points and do a g68 to rotate the cut data to match the angle of the part being cut?

Yes it is. As a friend I used to work with would say, its just SMS (Simple Matter of Software). However, for some of us (me) software isn’t always simple, but at least its fun working on features like this. I have used the g68 to do a simple 90 degree rotation for long skinny projects (like a sign) where I want to design horizontally in Vectric, but want to cut it down my Y axis. I put a button in my screen for that and then it redraws the toolpath as well.  
If you are manually jogging the camera crosshairs to the targets, its easy to capture the current position (and apply the offsets between the camera and spindle center). If you want it fully automated where the thing searches for the marks and locates them automatically, thats a lot more challenging.  
I am following this project too because I’m thinking this might be a nice way to set zeros when you don’t need much precision, especially in the middle of a project.

---

<div class="post-metadata">

**Author:** ![marco874](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.avidcnc.com/marco874/32/3570_2.png) [@marco874](https://forum.avidcnc.com/u/marco874)\
**Post date:** [May 30, 2024, 10:25am UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/9 "2024-05-30T10:25:50Z")

</div>

Hello there,

I am loving these insights mate as I found it very much useful and informative to be honest also as a new member I am loving this community so far. Looking forward for more such discussions.

---

<div class="post-metadata">

**Author:** ![Hulign](https://avatars.discourse-cdn.com/v4/letter/h/3be4f8/32.png) [@Hulign](https://forum.avidcnc.com/u/Hulign)\
**Post date:** [June 3, 2024, 11:02pm UTC](https://forum.avidcnc.com/t/camera-and-laser-offset-and-finding-center-between-2-points/3169/10 "2024-06-03T23:02:26Z")

</div>

Well I decided my fix was to buy a smaller machine for 3x the cost. Kind of joking? We bought a Summa F1612 as a in between machine. High Freq router ($27000!?!).  
2 Tangential modules, several different cutters including an electric oscillating tool. It opens up some of the same doors we were using but without it needing to be me running it all the time. I don’t know that I will run MDF on it or not, it’s close to a flatbed printer that doesn’t like dust. Its main job will be cutting cardboard and stickers.
