Go Down

Topic: Vectormath on an arduino (plane -> vectorintersection) (Read 685 times) previous topic - next topic

asuryan

Nov 21, 2012, 10:04 pm Last Edit: Nov 21, 2012, 10:43 pm by asuryan Reason: 1
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):
Code: [Select]
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!!

PaulS

Quote
First the machine goes to the middle as the reference point and sets this point as "0" -> on surface.

How does it do this? How does it know where the middle is? How does it know when it has touched the surface?

Quote
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.

How does it know where the measurePoints are? How does it get to them? How does it measure the distance? What "current point"? In what coordinate system?

Quote
- Is the arduino fast enough to do such vector math?

The math isn't that complicated.

Quote
- How do I get the formula of a vector intersection on a plane (3 points) transfered to actual arduino code?

I'm sure that you could google "line/plane intersection" to determine how to calculate a point. The question, though, is what are the values of the plane? What line (vector) do you want to intersect with that plane?

Quote
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.

Structuring the machine so the work surface is removable and replaceable in a flat/level/square configuration seems a lot more practical solution, to me.

On the other hand, manually moving the machine to three points on the not-quite level surface to define a plane, and then manually moving the machine to a 4th point, home, and having it define a 4 * 3 transform, and apply that to all GOTO points isn't that difficult.

stimmer

Firstly, do consider the other methods of bed levelling first. I have 2 CNC machines which both use different methods. The reprap has its bed mounted on 4 springs with a screw adjustment - the head is moved to each corner and I adjust the screw to make it level. The mill has a sacrificial piece of wood for a bed, and whenever I replace the bed I make it mill its own bed level.

If you still want to take the mathematical approach the formula you need is called bilinear interpolation:
http://en.wikipedia.org/wiki/Bilinear_interpolation
The formula might be too slow if you had to work it out at every step. But you might be able to take some short cuts, like only doing the calculation every 10 or 100 steps for example.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

asuryan

Thank you guys for your answers!

Quote
How does it do this? How does it know where the middle is? How does it know when it has touched the surface?

The table dimensions are in the EEPROM of the ATMega so just X/2 and Y/2 ;). I allready have a callibration feature implemented
but only with one point not an array of points and the abillity to interpolate between them. As I described I connect the drill and
the metallsurface to the arduino. When the drill meets the metall -> baaam: closed circuit, machine stops and sets the current position to "0".

Quote
How does it know where the measurePoints are? How does it get to them? How does it measure the distance? What "current point"? In what coordinate system?

I would take the table dimensions and devide these values with the desired grid size and store these values in an array.

Dont get me wrong but I actually build allready a working CNC machine with my own G-Code Interpreter firmware, a Processing
controller host software with 3D representation of the work piece and exporters for Adobe Illustrator and Softimage. So
I allready took care about most of this stuff ;)

But you are both right: bed leveling wouldn´t produce so much headache and would be a much quicker approach.
But I will also have a look on "Bilinear Interpolation". Maybe I can manage to make a programmatical callibration feature in the future.

Anyway: thank you for your time!!  :)

peppik49

Hello ,
I want talk with people that have interesting for RipRap project .
I have no experience of code and I need to know every step.
What is the firmware that run with Arduino2 for this project and , particularly, The Mandel model ?
Tank's

Go Up