blahblahblah5038 Posted April 28, 2007 Posted April 28, 2007 I have a wood project at school, which as part of my design needs to be cut on a cnc mill. Beacuse of the thickness required by the design, I glued several pieces of wood together, but needed to take material off the top. The pieces were too short for the planer, so I decide to head to the mill early and cut down the pieces on the mill. The mill software is a pain in the butt, so no one can reall figure out how to get it to consistantly work. I was told by the teacher to manualy write the code. Yeah right! Instead, I wrote a script to write the several hundred boring lines of code for me. Please excuse the messiness of my work, I had not origonally intended to post this on the forum. expandcollapse popup;Created by Blahblahblah5038 ;for the purpose of generating CNC code to control a CNC Router and Face a Block #include <math.au3> ;before using this program on the CNC Mill I need to zero the x and y to be approxametly the left front(nearest side to the oporator) corner of the work piece ;as well as the z exactly to the bottom of the piece. ;This portion asks questions pertinent to the program $startthickness = InputBox("Machining", "What is the current thickness of the material?") ;starting thickness of the work piece, does not need to be exact, but it is better to overestimate $endthickness = InputBox("Machining", "What is the final thickness of the material?");if you zero the machine correctly, this will be exact $buffer = InputBox("Machining", "How many inches would you like as a buffer");increases cutting area, don't need accuracy in the X and Y directions $length = InputBox("Machining", "What is the piece's length (Y)?") + $buffer ;however your machine measures Y $width = InputBox("Machining", "What is the piece's Width (X)?") + $buffer ;however your machine measures X $passno = InputBox("Machining", "How many passes other than the Last should the drill make?") ;number of rough cut passes $intCount = 0;counters $intCount2 = 0 $N = 4 ;keep track of line number, in case the computer doesn't do it for you, our equipment doesn't $bitDia = InputBox("Machining", "What is the Bit's Diameter?") $intLR = Int(($length/ (2 * $bitDia))) ;number of passes left to right per height $A = - ($startthickness + .5) ; a distance from the work piece $increment = ($startthickness - $endthickness - .01) / $passno ;how quickly the bit approaches the work piece, .01 is left for finish cut $Z = $startthickness - $increment ;distance in Z from bottom Run("notepad.exe") ;cnc code will be sent here WinWaitActive("Untitled - Notepad") Send("{Enter}");N = line number, G9=absolute coordinates, G0=rapid movement, XYZ are directional Send("N1G9G0X0YZ" & $A & "{ENTER}") ;move bit away from piece Send("N2M3"); M3 = turn on mill Send("{ENTER}") Send("N3G1Z" & $startthickness & "F4" & "{ENTER}") ;move to start thickness as provided by user if _MathCheckDiv ($intLR, 2) then $intLR = $intLR+1 For $intCount = 1 To $passno ;makes rough cuts Send("N" & $N & "G0X0Y0Z" & $startthickness & "{Enter}") $N = $N + 1 Send("N" & $N & ";Rough cut " & $intCount & "{ENTER}") $N = $N + 1 Send("N" & $N & "G1Z" & $Z & "{Enter}") $N = $N + 1 For $intCount2 = 1 To $intLR + 5 step 2 $X =$bitDia * $intCount2 $X2 = $bitDia * ($intCount2 +1) Send("N" & $N & "X" & $X & "{Enter}") $N = ($N + 1) Send("N" & $N & "Y" & $width & "{Enter}") $N = ($N + 1) Send("N" & $N & "X" & $X2 & "{Enter}") $N = ($N + 1) Send("N" & $N & "Y0" & "{Enter}") $N = ($N + 1) Next $Z = $Z - $increment Next ;makes final cut Send("N" & $N & ";Final Cut" & "{ENTER}") $N = $N + 1 $FinalLR = $intLR * 2 Send("N" & $N & "G0X0Y0Z" & $startthickness & "{Enter}") $N = $N + 1 Send("N" & $N & "G1Z" & $endthickness & "{Enter}") $N = $N + 1 if _MathCheckDiv ($FinalLR, 2) then $FinalLR = $FinalLR+1 For $intCount2 = 1 To $FinalLR + 5 step 2 $X = .5 * $bitDia * $intCount2 $X2 = .5 * $bitDia * ($intCount2 +1) Send("N" & $N & "X" & $X & "{Enter}") $N = ($N + 1) Send("N" & $N & "Y" & $width & "{Enter}") $N = ($N + 1) Send("N" & $N & "X" & $X2 & "{Enter}") $N = ($N + 1) Send("N" & $N & "Y0" & "{Enter}") $N = ($N + 1) Next ;return to origional position Send("N" & $N & "G0Z" & $startthickness & "{Enter}") $N = $N + 1 ;M2 ends program Send("N" & $N & "M2") Noteworthy works:Fast Pixel SearchSigned: WG
ConsultingJoe Posted April 28, 2007 Posted April 28, 2007 Cool idea, too bad you can't write a GUI that connects directly to the mill. Nice job though Check out ConsultingJoe.com
blahblahblah5038 Posted April 28, 2007 Author Posted April 28, 2007 there is one. You can use it to manualy move the mill or to manually enter keystrokes. just answer the questions, wait for the code, copy, paste, zero it in, and click run. Noteworthy works:Fast Pixel SearchSigned: WG
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now