Hi matteo,
I've had the same problem with my mill which had the X and Y axis out of square by about 4min of arc.
Prior to me stripping down the mill and making the required plate to correct the issue I used software
to make the correction.
As you probably know there is a formula page on the 'Function Cfg's' menu which will do that calculation.
The problem arises though that Mach does not apply the formula equally at all times. What happens is
for instance is that a correction is calculated but requires a significant movement and Mach responds
by trying an instantaneous move of several mm and fails because of limited acceleration. If you're using
steppers they stall and all bets are off. I have not seen any real explanation that can describe the circumstances
when it occurs but a number of users have seen and not be able to explain it either.
What I did was to write a macro that wrote a new file with the arithmetic correction and the ran that and it
worked a treat. In reality it was a wizard of sorts but as I was just starting to use VB I was happy with anything
that worked.
This is what I used
Sub main
Dim origname$,modname$,pathname$,currline$
Dim correction#
pathname="C:\Users\craig\Documents\eagle\lvdt4\lvdt4."
Begin Dialog filenameinput 16,30,180,96,"filename input"
OKButton 132,20,40,14
Text 8,8,32,8,""
TextBox 8,20,100,12,.inputname
End Dialog
Dim Dlg1 As filenameinput
Dialog Dlg1
origname=pathname & Dlg1.inputname
modname=pathname & "CORRECTED" & Dlg1.inputname
correction=-0.004
Open origname For Input As #1
Open modname For Output As #2
While Not EOF(1)
Line Input #1, currline
posx=InStr(1,currline,"X")
If posx=0 Then
Print #2,currline
Else
posy=InStr(1,currline,"Y")
posendy=InStr(posy,currline," ")
xstring=Mid(currline,posx+1,posy-posx-2)
ystring=Mid(currline,posy+1,posendy-posy)
xstring=xstring+ystring*correction
leftstring=Left(currline,posx)
rightstring=Right(currline,Len(currline)-posy+1)
newstring=leftstring & xstring & " " & rightstring
print #2,newstring
End If
wend
End Sub
As you can see the first part (very inelegant though it be) was just getting the file
to be corrected and generating the name of the corrected file.
The substantive part is where it reads a line, extracts the X and Y cords,calculates the
corrected X coord along the same lines you proposed (xstring=xstring+ystring*correction)
then puts the line back together as a string and sends it to the new or corrected file.
The only real challenge is getting the fairly limited string functions in VB to accommodate
your requirements. The file dialog I've used is a dog and hope I could do better now than then!
This approach means that cords in your Gcode match the numbers in your CAD while
you are optimising your Gcode and the just prior to running the code make the correction
not unlike a post processor I suppose.
Some ideas for you.
Craig