Bit-Wise Operators - Galil Motion Control DMC-14 5 Series Manual

Table of Contents

Advertisement

&
|
()
The numeric range for addition, subtraction and multiplication operations is +/-2,147,483,647.9999.
The precision for division is 1/65,000.
Mathematical operations are executed from left to right. Calculations within parentheses have
precedence.
Examples:
SPEED=7.5*V1/2
COUNT=COUNT+2
RESULT=_TPX-(@COS[45]*40)
TEMP=@IN[1]&@IN[2]

Bit-Wise Operators

The mathematical operators & and | are bit-wise operators. The operator, &, is a Logical And. The
operator, |, is a Logical Or. These operators allow for bit-wise operations on any valid DMC-14XX
numeric operand, including variables, array elements, numeric values, functions, keywords, and
arithmetic expressions. The bit-wise operators may also be used with strings. This is useful for
separating characters from an input string. When using the input command for string input, the input
variable will hold up to 6 characters. These characters are combined into a single value which is
represented as 32 bits of integer and 16 bits of fraction. Each ASCII character is represented as one
byte (8 bits), therefore the input variable can hold up to six characters. The first character of the string
will be placed in the top byte of the variable and the last character will be placed in the lowest
significant byte of the fraction. The characters can be individually separated by using bit-wise
operations as illustrated in the following example:
Instruction
#TEST
IN "ENTER",LEN{S6}
FLEN=@FRAC[LEN]
FLEN=$10000*FLEN
LEN1=(FLEN&$00FF)
LEN2=(FLEN&$FF00)/$100
LEN3=LEN&$000000FF
LEN4=(LEN&$0000FF00)/$100
LEN5=(LEN&$00FF0000)/$10000
LEN6=(LEN&$FF000000)/$1000000
MG LEN6 {S4}
MG LEN5 {S4}
MG LEN4 {S4}
MG LEN3 {S4}
MG LEN2 {S4}
MG LEN1 {S4}
EN
DMC-14x5/6
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Logical And (Bit-wise)
Logical Or (On some computers, a solid vertical line appears as a broken line)
Parenthesis
The variable, SPEED, is equal to 7.5 multiplied by V1 and divided by 2
The variable, COUNT, is equal to the current value plus 2.
Puts the position of X - 28.28 in RESULT. 40 * cosine of 45° is 28.28
TEMP is equal to 1 only if Input 1 and Input 2 are high
Interpretation
Begin main program
Input character string of up to 6 characters into variable 'LEN'
Define variable 'FLEN' as fractional part of variable 'LEN'
Shift FLEN by 32 bits (IE - convert fraction, FLEN, to integer)
Mask top byte of FLEN and set this value to variable 'LEN1'
Let variable, 'LEN2' = top byte of FLEN
Let variable, 'LEN3' = bottom byte of LEN
Let variable, 'LEN4' = second byte of LEN
Let variable, 'LEN5' = third byte of LEN
Let variable, 'LEN6' = fourth byte of LEN
Display 'LEN6' as string message of up to 4 chars
Display 'LEN5' as string message of up to 4 chars
Display 'LEN4' as string message of up to 4 chars
Display 'LEN3' as string message of up to 4 chars
Display 'LEN2' as string message of up to 4 chars
Display 'LEN1' as string message of up to 4 chars
Chapter 7 Application Programming
111
i

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dmc-14 6 seriesDmc-1415Dmc-1416Dmc-1425

Table of Contents