anafranil online
IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Postprocessor Tutorial
Sprut_UK
post Feb 2 2006, 05:18 PM
Post #1


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Please keep this thread just for this tutorial, if you have a question, please either start a new thread or use an existing one, thanks.
The postprocessor generator software in SprutCAM is very powerful, which means that is not that easy to learn. However, with a bit of time and patience most people should be able to make their own minor 'tweaks' to existing postprocessors.
I will endeavour to put together several 'bite size' tutorials to give an introduction to how it all works.
I am not going to look at the 'Mask' type postprocessors, there is a tutorial included with SprutCAM for this.

First I think we need to start with a look at the interface:


1: This is where the CLData (Cutter Location Data) generated by SprutCAM is displayed.
2: This is the where the list of 'Command' programs are displayed
3: The actual 'code' for the currently selected 'Command' program is displayed and edited here.
4: This is the list of 'Registers' which control the format of the generated output (G-code).
5: Here the SprutCAM operations are listed and can be selected/deselected.
6: The generated (postprocessed) output is displayed here.

These are the main area's, there are of course several other parts of the system, but we will be looking at those above in a bit more detail.

The next part of this tutorial will look at CLData in a bit more detail.........
Go to the top of the page
 
+Quote Post
Sprut_UK
post Feb 3 2006, 09:01 AM
Post #2


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Ok, so what is CLData? CLData is the actual data that SprutCAM generates whenever it creates a cutter path. In fact, each step of a cutter path whether it is an arc or line has it's own bit of CLData.
This CLData is stored in a special format called an array. Now if your not sure what an array is, think of it as an Excel spreadsheet, you have columns and rows.
Each of the columns are numbered sequentially 1, 2, 3, 4... and so on.
Each row contains a one line of CLData.
One line of CLData contains all of the information relating to the bit of cutter path that created it in SprutCAM. For example, if it is a Rapid move, the row will contain the X - Y & Z position for that move.
Each column in that row will contain the separate pieces of information e.g. X in the first column, Y in the next column and so on.
Here is an example:



Now, in order to use the information that is contained in each row, instead of reffering to them as X, Y & Z we instead reffer to them based on which column they exist in, so for a rapid move this would be CLD[1] would be X, CLD[2} would be Y and CLD[3] would be Z:

Go to the top of the page
 
+Quote Post
Sprut_UK
post Feb 3 2006, 04:22 PM
Post #3


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Before I go any further into the process, I think it will be a good idea to show you a couple of useful tools that I tend to use a lot when testing and debugging a postprocessor.
The first is the 'Run' button, the other is the 'Step in' button. You can find these on the main toolbar:



To use the Run button, just click it and the postprocessor system will run the currently selected postprocessor and SprutCAM project, and the resulting G-code will appear in the right hand side of the window.
To use the Step in button just click it, and what happens is that it runs one line of the program (CLData), you can then keep clicking it to run through the 'Command program' steps one at a time.

A very effective way of using these together, especially when you are tracking down a specific problem is to select the line of CLData that you want to investigate by clicking just to the left of it, it goes red when correctly selected:



Now when you press the Run button, it will run the program up to the selected line of CLData, and then you can use the Step in button to run a step at a time to see exactly what is going on.

Give this a go, and feel free to experiment with different postprocessors. If you are going to modify an existing postprocessor, please make a back up first!
Go to the top of the page
 
+Quote Post
Sprut_UK
post Feb 4 2006, 09:54 AM
Post #4


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Ok, now we are getting into the area of the postprocessor generator that does all of the work, the command programs.
The command programs are listed in section 2 of the image in my first post. Each of these programs corresponds to a type of CLData.
You may have already noticed that each line of CLData has a label at the beginning, this label identifies what type of data each block of CLData contains.
When a postprocessor is run, each block of CLData is read, and this starts off with the label at the beginning, each label has a command program associated with it which generally has the same name as the label.
You can see this here:



I have highlighted the CLData labels and command program names with matching colours to make it clearer.
To my knowledge there is only one exception to this rule, and that is the CLData label GOTO is associated with the command program called AbsMov, and before anyone asks..... I have no idea why.........

So, if you have had a play around with the 'Run' and 'Step in' functions in my previous post, you will have seen that if you use the 'Step in' option, each step starts by selecting a line of CLData, the next step (click) opens the corresponding command program (section 3 in first image), and now each step reads one line of the command program. Once all of the steps of the command line program have been completed, you are then returned to the next line of the CLData which then tells it the next command line program to run and so on.
In keeping with most other programming languages, the postprocessor generator language can also use Sub programs which can be called from anywhere in a command program or indeed another Sub program.
I am not planning to delve into this side of the system in this tutorial, but for those who are curious, you can see these Sub programs listed on the 'Sub' tab.

Next we will have a quick look at 'variables' and 'Registers'
Go to the top of the page
 
+Quote Post
Sprut_UK
post Feb 12 2006, 02:31 PM
Post #5


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Ok, what are registers? Well, registers are how the postprocessor generator communicates with the outside world.
When a register is passed a value it does two things:

1/ It checks to see if the value it has just been passed is the same as the previous value that it was passed
2/ If it is, then it outputs this new value into the program - giving it the correct format.

The first step is used to allow 'modal' or 'non modal' commands to be output. Most CNC controls have different requirements of whether commands such as G00 - G01 - G02 - G03 are required on every line (non modal) or whether they can be ignored if they haven't changed from the previous command.
The way a register does this check is to compare the value it has now e.g. 01, with the previous value it contained which is stored in another register with the same name with an @ symbol appended to it.
For example, if we have a register called INTERP_ which is used to output G00 - G01 - G02 - G03 move in a program, then the old value of this register is stored in a regsiter called INTERP_@
For example, if we have a two rapid moves (G00) followed by a Feed move (G01) then the following would happen:

INTERP_ = 00 (new) INTERP_@ = 99999.99 (old), the new and old values are different so 00 is output
INTERP_ = 00 (new) INTERP_@ = 00 (old), the new and old values are equal so no output
INTERP_ = 01 (new) INTERP_@ = 00 (old), the new and old values are different so 01 is output

A simple way of making all outputs of this command non modal is to always make the old register value different to the current one. One way of doing this is:

INTERP_ = 0 ; INTERP_@ = INTERP_ - 1

This forces the old regsiter value to always be 1 less than the new regsiter value, so it will always be output irrespective of whether the value has changed or not.

The second thing that the regsiter does is give the output some format.
When a value is output by a register, the Register indentifier is added to the start of the value (red box), the format of the output value is applied based on the user selected options (green box). The regsiter name can be seen in the blue box.



To view the settings for a particular register, double click the one you want in area 4 (image in first post of thread).

Try adjusting the Register indentifier and formatting options to see what effect these have. As always, save your modified postprocessor under a new name to preserve the original.
Go to the top of the page
 
+Quote Post
Sprut_UK
post Feb 26 2006, 07:52 AM
Post #6


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



Before we move on from looking at Registers I just want to look at one other thing that you can do with them.
The position that a Regsiter appears in the Regsiter list affects the position that the G-code it generates appears in the program it produces.
Basically, the output for a Regsiter that is higher up the list will appear before one that is lower in the list.



Looking at the image above, you can see that X is higher than Y, and Y is higher than Z, so in the G-code that it produces you would get:

X123.00 Y456.00 Z789.00

We can change the position that a regsiter appears in the list by using the up/down arrow keys (image above). If you change the order they appear in the list to:



Then the output for X Y and Z would appear like this:

Z789.00 Y456.00 X123.00

notice that the values are still correct, the only thing that has changed is the order that they appear in the block of program.

Try moving the regsiters around in a postprocessor that you are using to see the effect it has for yourself.

Next we will take a quick look at variables



Edited by - sprut_uk on 26/02/2006 10:53:59

Edited by - sprut_uk on 26/02/2006 10:57:53
Go to the top of the page
 
+Quote Post
Val
post Oct 29 2012, 08:14 PM
Post #7


Advanced Member
***

Group: Members
Posts: 50
Joined: 8-October 11
From: USA
Member No.: 3,307



This tutorial is great, what I'm trying to do is modify the header/safety code and also the tool post, and end of tool safety lines.

I do not know how to get some of the code to show up on the same line vs a new line.


for example using this post because it has an option in the post to out put R vs IJK, this saves charecters for some machines that are limited on memory, I also remove 0's that are not needed in XYZ and G code (when the machine doesn't mind)
http://download.sprutcam.com/index.php?dir...30i%29_Mill.spp

puts out
code for the tool:

CODE

G00G21G40G49G69G80G90G17
( SPOT )
G53Z0.
G53X0.Y0.
T5M6 (tool description)
G54
G17
S2500M3
G00G43H5X7.721Y-0.492Z0.1
M8
G81Z-0.1R0.1F5
...

G80
M9
G49
M5
M1


I edit each post to look the way I want it which is:

CODE

M1( SPOT )
G0G40G90G80G49G53Z0M5
T5M6 (tool description)
S2500M3
G00G54X7.721Y-0.492
G43H5Z.5M8
G81Z-0.1R0.1F5
...

G80
G0G40G80G90M5
G49G53Z0M9


at Start of program
%
O1000(program description)

and for end of program

G0G90G80G40G49G53Z0M5
G53Y0M9
M30

I would edit all those area's myself but I dont know how to convert some of the code to be next to the desired code
Go to the top of the page
 
+Quote Post
Sprut_UK
post Oct 29 2012, 09:03 PM
Post #8


Advanced Member
***

Group: Administrators
Posts: 1,091
Joined: 12-December 07
From: United Kingdom
Member No.: 4



The easiest way to achieve what you want is probably to try the output command.

For example, if you want M1 to appear on a line by itself, you can simply type:

output "M1"

or you could get more fancy and type

output "M1 (Optional Stop)"

To change the safe start line, find the line of code near the bottom of the Partno program that looks like this:

Output "G00G21G40G49G69G80G90G17" and change it to this:

Output "G0G40G90G80G49G53Z0M5"

This is a 'rough and ready' way of editing a postprocessor which is usually suitable for non toolpath related data; safe start lines etc.

Dave


--------------------
"Never interrupt your opponent when he is making a mistake..." - Napoleon Bonaparte
www.sprut.co.uk
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 20th July 2019 - 08:11 PM