Your company's Logo

   


Using a Filter Script


Sometimes the CNC machine does not download the program in exactly the right format that one would like and its neccessary to make changes before or afterwards. DNC Server has the abilty to perform changes to the text during upload and download. It can change the line that comes through the serial port before it is put in the edit window, and it can change the line before it is sent out through the serial port from the edit window. This allows for any custom format changes to the text that are required by the CNC machine.

This is accomplished through a script that is run for every line of text that is uploaded or downloaded.

In DNC Settings there are tabs for both an Input filter and Output filter script. 

For instance:
You are drip feeding a long program and want block numbers in the display of the program in the main window as it is sending, so you know where you are.
But the program is so long that the block numbers go beyond 4 digits, but the machine won't take block numbers beyond 4 digits.

Instead of having to take out all the block numbers from the file beforehand, you could strip them out before the line was sent to the control, and they would still remain in the program.

 

 

This filter would remove the N number from every line before it is sent out the serial port. The CNC file is not changed, just the output through the serial port is changed.

Filter File

You can have a seperate filter file for input and output. These file names are saved for each machine configuration, so you can have different ones for each machine. Use the button to browse for files. The file extension for filter files is ".filt".

Activating the script

The checkbox "Use Output Filter" and "Use Input Filter" allows the filtering to be turned on and off. The filters will not be used if these are not checked. .

Testing the Script

A "Test" button is provided to test for syntax errors and to see if it works as expected. If there are errors, a message box will display the line number that the error is on.

If the script is successfull, a message will say, "No Errors Found".

If you go to the CNC file edit window on the main window and put the cursor on a line of text in the edit window, the script will use that line to process with the script, so you can see how the script would work with an actual line of text.

 

Variables

String variables are distinguished by a "$" on the end.

To get the current line in its current state use the ioline$() function.
 

Functions

Most of these functions skip anything in the comments. You need to set the comment characters in Settings - General to skip the comments in the CNC program.

 

Built-in CNC Functions
   
front(string) Will add a string to the front of the line.
 
remove(string)
Will remove the address and its value from the line.
rear(string) Will add a string to the back of the line.
 
addspaces() Seperates all the addresses on the line with spaces.
 
stripcomment() Removes the comment from the line. Looks for the comment characters that are in listed in the Settings pages.
 
stripspaces() Removes any spaces in the line.
 
getvalue(address) Returns the value of this address in the current line. It only returns 0 if the address was found and contains 0. If the address was not found it returns -9999.9999
insertline(string) When downloading, this inserts this string into the edit window before the current line is added. When uploading, the string will be sent before the current line.
endfile() Checks if the end of the sending or receiving has been reached - before the last line has been proccesed. It returns -1 if true.
beginfile() Checks if the first line has been proccessed yet. It reurns -1 if true.
ioline$() Retrieves the current line.
setline(string) Sets the current line. This is what will be received or sent.
changev(address,oldvalue,
newvalue,format)
Changes the value of an address. If the value of the address equals oldvalue then it will be changed to newvalue. It goes by the numeric value not the string value. So it will recognize X1.00, X1., X01.000 as the same value.

 
   
format=0  // normal
format=1=*  'X* //change all oldvalues of that address to newvalueformat
format=2=<  //change any number thats less than oldvalue
format=3=>  //change any number thats more than oldvalue
format=4= same as 0 but also goes in comments}
format=+100  // outputs no decimal - one place
format=+200  // outputs no decimal - two places
format=+300  // outputs no decimal - three places
format=+400  // outputs no decimal - four places
format=+900  // outputs no decimal - zero places
 
hasaddress(address)
hasaddress will return position of address in current line in editor. 0 if the address was not found.
stop(string)

Stops outputting the file to the serial port at the current line.
Pressing "Abort" will end sending and receiving. Pressing Ignore will continue.
  String is optional for mesage box display.
offset(address,value)
If address exists, it will be increased by value. You can subtract by using minus number.
scale(address,value) If address exists, it will be multiplied by value.
saveprint(filename) Since the print function does not have any window to print to, it saves the output in a buffer that can be saved to a file.
sendxon() Send the XON character out the serial port.
sendxoff() Send the XOFF character out the serial port.
Global variables Normally all the variables you make in the script will only last for proccessing one line. If you need to save values over the whole file input or output, you can use the ten global number and string variables. You can set and retreive the values with these functions.
getglobalnum(index) Retreives a global number variable. index=1 to 10
setglobalnum(index,value) Sets a global number variable.
getglobal$(index) Retreives a global string.
setglobal$(index,string) Sets a global string.
getlineindex$(index) Returns the text line of the editor at this index
setlineindex$(index,string) Sets the text line of the editor at this index
linecount() Returns the number of lines in the editor
gotoline(index) Current line in editor jumps to this linenumber
currentlinenumber() Returns the line number of the current line
cancel() Like pressing the Cancel button.
output(string) Sends a string of characters out tthe serial port.
sendfile(filename)
Opens a text file and outputs it through the serial port. With this you can insert another prorgam file anywhere within the main file. The script is not performed on lines in the secondary file, only on the file in the edit window.
rotate(angle) Rotates the current line by the angle before output. Only X,Y plane. Rotates around X0,Y0. Will change X,Y values. Will change I and J values also if present.
isstart() True (-1) only before the first line is sent.
isend() True (-1) just before the last line is sent.
wait(millisecods)
wait(1000) would stop all processing and wait for 1 second.
   
Basic Script Language

The scripting language is compatible with standard Basic languages. Its compatible with most books and infomation on the internet about the Basic Programming Language.

Filter Script Basic is 90% compatible with MS GWBasic and QBasic, with some Pascal extension like While, Repeat, Break, Continue, which let you write programs without labes and Goto instructions. Numeric labels are supported for backward compatibilty with old Basic programs

See more on the Language Reference here .

 

Note: With a large Input script It's possiblethat the extra proccessing may require a slower baud rate to be used to make sure that it is able to keep up with the incoming data - depending on the speed of the computer.

Back

 

 

 

 

 

      
      
 

Copyright ©2008 i-Logic Software. email: support@i-logic.com