erik_f
04-08-2008, 08:22 AM
Dana,
You said this in the bt32/48 post...
"Where I need this level of accuracy I use C# to generate custom cut files. Then I can correct for as many factors as I want to."
I'm not familiar with C#...I'm very interested in how you are adjusting parameters to get better accuracy. I have in the past only been able to do this by generating a brand new part file after changing the cad file. This is very tedious...please give me some insight!
Thanks,
Erik
henrik_o
04-08-2008, 01:06 PM
C# (http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29) -- though that doesn't tell you much.
dana_swift
04-08-2008, 03:31 PM
C# is a programming language by Microsoft. They offer a free download which is fully functional, so it costs nothing but "lots" of time. I create a model to cut parametrically in C# then use a C# library I wrote to generate the SBP files.
C# is closely related to Java, if that helps any.
There is also an open source version of the language named "mono", available from sourceforge free of charge including the source code for the language itself.
There are a lot of websites dedicated to C#, any programming language could do the same job. For simple one-off projects I use partworks, but the accuracy is not as good, as it assumes all materials cut perfectly. I dont make that assumption and can correct as many factors as I wish.
Another big advantage C# gives me is full 3D cutting capability. If I want to cut out a square and arch the top surface, it is just a matter of describing how much arch and in what direction.
Hope that helps explain things, I dont expect anybody else to take this path.
D
erik_f
04-09-2008, 10:40 AM
yeah thanks for explaining...I think it may be a little out of my league though.
Erik
sailfl
04-10-2008, 07:12 AM
Dana,
Are you using the C# to create preprocessor g code? I would like to hear more about how you are using it. I have C, C++, Java, VB and a whole bunch of other experience.
Thanks
dana_swift
04-10-2008, 08:49 AM
Hello Nils-
The SBP file doesn't use usually use G codes. But the SBP file is easy to generate using OO methods. As well as G files are, and many others.
The first thing I did was create a "ShobBot" namespace, everything ShopBot goes into it.
For generating SBP files I wrote a set of classes, the lowest level of which is "ThousandthsOfAnInch" which converts doubles to integers that default to 0.001 inch precision, however they can be set to round to any other value such as 0.0001 inch. The rounding rules are implimented in my code so I don't get a crossover flat spot at zero counts when the sign changes.
That new data type is used to create a class called "ShopBotPartFile". This class is used to interface the standard ShopBot commands to the file, it amounts to little more than a wrapper. In addition the constructor and destructor write the headers and footers to the file and check to see if the router has been stopped under program control, if not, the shutdown code is created.
The base class uses very readable member functions like:
public void Move(double X, double Y, double Z)
{
...
}
What this function does is act as a front end for the M3 command, but it uses intelligence. If the router is at Z=2.0 and the command is for the current X and Y with a HIGHER Z, it issues a JZ command for an automatic speedup of the cutting time. If the X and Z positions don't change a MY command is generated. It keeps the SBP file short and sweet, I dont know if it executes any faster but its a lot easier to read. For instance this is an extract from an SBP file:
MY,-1.930
MX,0.080
M2,0.088,-1.938
M2,0.087,0.438
MX,-0.088
M2,-0.087,-1.938
MX,0.088
JZ,0.100
' Cut hole #1
J3,-0.855,-2.290,0.100
M3,-0.855,-2.210,-0.080
CP,0.080,-0.855,-2.250,T,1,0,0,0,1,1,1
MY,-2.130
CP,0.240,-0.855,-2.250,T,1,0,0,0,1,1,1
Notice the comments, some are added automatically, others can be added with a function in this base class.
The base class also impliments "safe" and "unsafe" motion. So JogSafe will always avoid anything in space the program knows about between point A and B. JogDirect will cut through anything in its path perhaps breaking a bit and who knows what else?
Then classes are derived from this base class to handle Paneling, material/bit combined properties, and (not yet finished) temperature compensation for the expansion of the ShopBot at different shop temperatures. (The thing isnt made from nvar ya know!)
Then as clients for these classes I have some tool path generators. The simplest of which is just like any 2D cad, it has functions such as:
public void CutCircularPocket(
double CenterX,
double CenterY,
double Diameter,
double BitDiameter,
double PassOffset,
bool CutInsideToOut,
bool ClimbMilling,
double TopSurfaceZ,
double PocketFinalZ)
{
...
}
And lots of others, these make cutting simple panel oriented things really easy.
Then I have written a list of applications to create cut files for the different things I do. Each one shares these classes. So if i improve the classes in some future project all of my old projects automatically get the improvement.
I probably spent about 4 or 5 evenings writing this originally, so it wasn't a big investment of time. But the results are so much more to my liking. Since the original creation I add functionality as I need it.
And lastly for the cream on the cake I have a set of Autocad drawing classes that generate DXF and SCR files. Guess what? They share the same interfaces as the Shopbot classes! So.. outputting documentation is just as easy a outputting a cut file. It makes it easy to be sure I am getting what I want before I cut anything.
Also the preview function in the shopbot software is wonderful for checking part or all of a cut file to see that the tool really goes where I thought it was going to.
CNC and OO really work well together, its just nice to be very comfortable with both of them. Its a different approach to shopbotting, but I am enjoying.
As you have C C++ and Java experience this will be very easy for you too. Hopefully this gives you some ideas to chew on. Programming is like the shopbot, everybody does it their way, and everybody optimizes the results for their personal preferences.
Nils- I hope that is enough said-
D
bcammack
04-10-2008, 09:11 AM
Well, as a 30+ year programmer/computer professional, I'd have to say that you've probably killed this thread as effectively as I ever could've, Dana.
Interesting concept. I may borrow it for my job as a fundamental architecture. Thanks for sharing!
sailfl
04-10-2008, 05:50 PM
Dana
Thanks. It was more than I thought I would see but it also helped me understand what you are doing. I am not ready to do anything like writing my own code but I will keep what you provided and you might hear from me in the future.
Thanks
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.