Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

Author Topic: CNC machine - Parametric programming - Introduction  (Read 3440 times)

0 Members and 1 Guest are viewing this topic.

stamatis

  • Guest
CNC machine - Parametric programming - Introduction
« on: September 05, 2008, 19:06:42 PM »
But how come and we call one program parametric? The answer is simple, it uses parameters.
What kind of parameters? This depends on the type of the program.
A parameter is usually a named or numerical field that will hold a numerical, integer or float value. This parameter is used to accept values from the user or even to be used from the controller as temporary value holders. An example of a real simple parametric program is shown below:
Code: [Select]
N1 L1 = 100
N2 L2 = 100
.
.
.
N50 G1 X=L1 Y=L2

Our example machine has a controller that uses the letter 'L' followed by a number to hold parameters. Thus, there are parameters like L1, L2, L129, L214 and so on.
You should imagine a parameter nothing more as an empty basket. Each basket has a label on it, for example, there is a basket with the label L100, another with the label L432 etc etc. Our machine has 600 baskets labeled from L0 to L599.
In each basket you are allowed to put one and only one number! If you put another number inside, then the old number is lost and the basket will carry the new number. You may do any mathematical function with your baskets but be careful! If you add two baskets, you need another third one to put the result! For example you may add basket L1 and L2 and the result will be placed in basket L3. This function can be written:

Code: [Select]
L3 = L1 + L2
This will add THE CONTENTS OF THE BASKETS. But enough with the baskets. We will call them as they are called and that is ''parameters''.
As I was saying, you add the contents of the parameters rather than the parameters themselves.

Let's make it a little more complicated:

Code: [Select]
L1 = 100
L2 = 50
L3 = 80
L4 = 2
L5 = L1 + L2
L6 = L5 - L3
L7 = L6 / L4

Parameters from L1 to L4 will hold static values.
The parameter L5 will contain the result from the addition of L1 and L2, that will be 100 + 50 = 150
Parameter L6 will hold the result from the subtraction L5 - L3, that will be 150 - 80 = 70
Finally, parameter L7 will hold the result from the division L6 / L4 that is 70 / 2 = 35

And why all these parameter gizmo's? Why not to use static values? The answer is somehow easy when you have faced the problem itself.
Suppose that you have a static (static will be for us the opposite to parametric) drawing for your machine. This is a simple rectangle. The panel is for example 800 x 600 x 8 (always in millimeters) and the rectangle will be drawn inside this panel with offset to each side of 100mm and the depth of the cutter is 5mm (8-5 = 3mm from the table) . The G-coded program would be kinda like:

Code: [Select]
G0 X100 Y100
G1 Z3 F10000
G1 X700 F20000
G1 Y500 F20000
G1 X100 F20000
G1 Y100 F20000

Now suppose that you want to fit this program to a panel with sizes 700 x 400 x 7, or any other size. You may also want to change the offset of the lines from each side. Every little single that you may, require a new program creation. Pretty huh e? A factory that makes house doors will need to have at least 100 different drawings. Now imagine, how many times each of this drawing has to be remade to have all different dimensions that house doors require. The number is extraordinary.
Here comes the 'panacea', the parametric program. I shall re-write the above program in simple parametric form. Please note that when using numbers I write X100 but for parameters I write X=L1. The equation symbol is mandatory when referring to parameters. For static numbers you may not use it. Also, after the '';'' symbol everything is comments. Nothing will be executed on a line after the '';'' sign.


Code: [Select]
; PARAMETERS
L1 = 800 ; PANEL X DIMENSIONS
L2 = 600 ; PANEL X DIMENSIONS
L3 = 8 ; PANEL X DIMENSIONS
L4 = 5 ; DEPTH
L5 = 100 ; LEFT AND RIGHT OFFSET
L6 = 100 ; UP AND DOWN OFFSET
;--------------------------------------------
;CALCULATIONS
L101 = L1 – L5 ; THIS HOLD THE MOST LEFT POINT
L102 = L2 – L6 ; THIS HOLD THE MOST BOTTOM POINT
L103 = L3 - L4 ; THIS HOLD THE DISTANCE FROM TABLE FOR THE CUTTER
L104 = L3 + 40 ; THIS IS A SAFE LEVEL FOR FREE CUTTER MOVES
;--------------------------------------------
G0 X = L5 Y = L6 Z = L104
G1 Z = L103 F10000
G1 X = L101 F20000
G1 Y = L102
G1 X = L5
G1 Y = L6
G0 Z = L104

That's all! More complicated? It may be but hey, complicated problems needs complicated solutions. The above parametric program is able to run each and every different panel dimension with only limitation the machine table. One program for every size. The operator will only need to change the parameter L1 to change the width dimension (X) or the L2 parameter to change to height (Y) or the L3 parameter to change the thickness of the panel (Z). Also, by changing the L4 parameter, he can automatically change the machining depth of the cutter!!! Parameters L5 and L6 holds the offsets for left - right and up - down offsets of the drawing. This means that if he change these parameters he can have different drawing offsets from the panel edges. Incredible? And all these features can be achieved with only one program! The operator needs no more training than to learn to change the parameter values! The factory needs of no some ''CAD design specialist'' because if every program is made parametric, then it needs to be made only once! ONLY ONCE! And further more, this factory will need of no extra expensive automated super wow CAM program, as the drawings are recalculated during run time within the machine controller.

Parametric programs may be so easy as the above example, but also may be very complicated. The complicity has to do with the geometry and maths you need to know. The above example will only use functions such as plus and minus, but other programs will require geometry like trigonometrical functions. And of  course, advanced programs will require you to know by heart the Pythagorean theorem.

I will try with my following tutorials to teach you as straight forward as I can, the magic of parametric programming. Stay tuned to PCB Heaven[dot]com!