Hi!
A few months ago I build a little CNC machine for small jobs. So far it works quite well and happily cuts, plastics,
wood and aluminium as well as circuit boards for prototyping.
But I encountered one problem. The surface is not completly straight so I get sometimes (because I have to lift the
working area sometime because of maintaince) a height difference of 0.6 mm. And thats a lot. Its even worse when
doing circuit boards for SMD where the cutdepth has to be even on the whole area.
I know there are physical devices to get the drill on the area but thats not possible to mount on my machine and to
be honest I dont really understand how that works. Also milling a straight object isnt an option because the error changes
everytime I open the machine for maintaince.
So I got this idea:
CONCEPT:
I place a sheet of metal on the surface and connect the sheet and the drill to the arduino. They both act like a "button",
so when they touch each other the arduino knows where the drill is on the metalsurface (thickness has to be subtrackted
of course).
In software I send a "calibrate" command to the arduino and the arduino devides the max. working area in a grid as
shown in the attached image. First the machine goes to the middle as the reference point and sets this point as "0" -> on surface. Then it
goes to all the measurePoints and measures the physical difference between the current point and the reference point
and stores that value in an array.
When milling, the machine then gets the actual cutdepth, takes this value, calculates the intersection of the cutvector with
the plane that is determined by the 4 surrounding points and adds that value to the actual cutdepth that is being send.
So my questions are:
- Is the arduino fast enough to do such vector math?
- How do I get the formula of a vector intersection on a plane (3 points) transfered to actual arduino code? Because the points and
the vectors have to get converted from a parameterized to a coordinates term ? Furthermore I actually need to consider 4 points because
one point could be not on the plane but has to be considered!? - How could I determin programmaticly the "quadrant" and the corresponding 4 points where the intersection occurs?
Here is a first jscript test of a finding algorythm (which logs the first X value where the points X is in between, unfortunately Y
does not log correct values):
arrMesspunkte = new Array()
arrMesswerte = new Array()
arrMesspunkte = [0,0,0,2,0,4,2,0,2,2,2,4,4,0,4,2,4,4]
arrMesswerte = [0.1053,0.065,0.0979,0.1472,0,0,0.0736,0.0518,0.0605]
arrPunkt = [0.813,0.3605]
oPnt = 1
oArrPos = 0
oCurrX = arrPunkt[0]
oCurrY = arrPunkt[1]
//Get quadrant
for(i=0;i<=arrMesspunkte.length/2-1;i++){
oMessX1 = arrMesspunkte[oArrPos]
oMessY1 = arrMesspunkte[oArrPos+1]
oMessZ = arrMesswerte[oPnt-1]
oPnt += 1
oArrPos += 2
oMessX2 = arrMesspunkte[oArrPos]
oMessY2 = arrMesspunkte[oArrPos+1]
if(oCurrX > oMessX1 && oCurrX < oMessX2){
Logmessage("QUA X:"+(oPnt-1))
}
if(oCurrY > oMessY1 && oCurrY < oMessY2){
Logmessage("QUA Y:"+(oPnt-1))
}
}
If someone can push me in the right direction programmaticly I would be very happy!
I hope I explained my problem right...
Thanks in advance!!