2012-08-05 20:52:19 (CET)

supported operations on expressions

unary operations

 

abs        : absolute value

acos      : arc cosine

asin       : arc sine

atan      : arc tangent

cos        : cosine

exp       : e raised to

fix         : round down

fup        : round

int         : integer part

ln          : natural log of

round    : round

sin         : sine

sqrt       : square root

tan        : tangent

not        : logical not

 

 

binary operations:

 

/          : divided by

mod    : modulo

**       : power

*         : times

and     : logic and

xor      : logic exclusive or

-          : minus

or        : logic non exclusive or

+         : plus

>         : greater then

>=       : greater than or equal

<         : less then

 

==       : is equal

<>       : not equal

band   : bitwise and

bxor    : bitwise exclusive or

bor      : bitwise non exclusive or

<<       : shift left

>>       : shift right

 

See also B.2 for examples on expressions.

 

An example:

 

sub do_circle_holes

 

#1=0

g0 z1 x0 y0

while [#1 <> 360]

#2 = [10 * sin[#1]]

#3 = [10 * cos[#1]]

g0 x[#3] y[#2]

g1 z-1

g1 z1

#1 = [#1 + 30]

 

 

if [#1 == 360]

msg "Done"

else

msg "processing at angle "#1

endif

 

endwhile

 

endsub

 

gosub do_circle_holes

m30

 

This example drills holes at a circle with a radius of 10, each 30 degrees. The code that performs this is put in a subroutine, which can be called as many times as needed in the main program.

 

 

Special interpreter commands, non G-Code

Messages:

Msg "Hello there, the value of #1 = "#1" and the value of #2 = "#2

 

ErrMsg

Same as Msg, but this one generates an error

 

Store position

SP <filename> [0 or 1]

This command stores the actual position in given file name.

The extra parameter 0 means create the file.

1 means add to existing file.

If only file name is given, the position is added to existing file.

 

DlgMsg

Gives a dialog message for an interactive g-code program.

DlgMsg <dialog message> <par1Name> <par1ParNumber> ... <par12Name> <par12ParNumber>

Example:

DlgMsg "Give parameters" par1 100 par2 101

The dialog woll have an OK and a Cancel button.

When the user selects OK, variable #5398 is set to 1 and the program automatically continues.

When the user selects CANCEL, variable #5398 is set to -1, program continues.

Just try and you will see what this is about.

if <dialog message>.png picture exist it will be show.

 

 

EXAMPLE of dlg msg:

For this example we created a subroutine associated with user_3 button in the UI.

 

Sub user_3 ;Example of dlgmsg

#1 = 0

#2 = 0

#3 = 0

#4 = 0

#5 = 0

#6 = 0

#7 = 0

#8 = 0

#9 = 0

#10 = 0

#11 = 0

#12 = 0

 

;dlgmsg will pop up a dialog with picture usbcnc.png from c:\program files\usbcnc4\dialogPictures directory

dlgmsg "usbcnc" "A" 1 "B" 2 "C" 3 "D" 4 "E" 5 "F" 6 "G" 7 "H" 8 "I" 9 "J" 10 "K" 11 "L" 12

 

if [#5398 == 1]

msg "OK #1="#1 "#2="#2 "#3="#3 "#4="#4 "#5="#5 "#6="#6 "#7="#7 "#8="#8 "#9="#9 "#10="#10 "#11="#11 "#12="#12

else

msg "CANCEL #1="#1 "#2="#2 "#3="#3 "#4="#4 "#5="#5 "#6="#6 "#7="#7 "#8="#8 "#9="#9 "#10="#10 "#11="#11 "#12="#12

endif

 

Endsub

 

LogFile, LogMsg

Log anything to a file..

LogFile <fileName> <1=append, 0=open new>

LogMsg your message

 

 

Example:

LogFile “text.txt” 1

LogMsg “Hi, the current position of X is “#5001

 

Now check the contents of file text.txt.

 

TCAGuard [on | off]

Switches on or off the tool change area guard.

This is used during the rendering process, where the job file is checked for collisions with the machine area and tool change area.

 

HomeIsEstop [on | off]

This allows to control the homeIsEstop feature.
When on, a EStop is generated when one of the home sensors activate.

 

 

Special interpreter MDI commands.

M6 TX which is a tool change will call the subroutine change_tool. This subroutine can be customized to match your machine.

 

Gosub subname moves the interpreter to the first line off the subroutine, allowing you to execute the subroutine without calling it from the main program. This is good for testing subroutines. In combination with DlgMsg you can give your own input parameters.