EasyManuals Logo

Galil Motion Control DMC-40 0 Series User Manual

Galil Motion Control DMC-40 0 Series
283 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #142 background imageLoading...
Page #142 background image
Mathematical operations are executed from left to right. Calculations within parentheses have precedence.
Examples:
speed = 7.5*V1/2
The variable, speed, is equal to 7.5 multiplied by V1 and divided by 2
count = count+2
The variable, count, is equal to the current value plus 2.
result =_TPX-(@COS[45]*40)
Puts the position of X - 28.28 in result. 40 * cosine of 45 is 28.28
temp = @IN[1]&@IN[2]
temp is equal to 1 only if Input 1 and Input 2 are high
Mathematical Operation Precision and Range
The controller stores non-integers in a fixed point representation (not floating point). Numbers are stored as 4
bytes of integer and 2 bytes of fraction within the range of ± 2,147,483,647.9999. The smallest number
representable (and thus the precision) is 1/65536 or approximately 0.000015.
Example:
Using basic mathematics it is known that 1.4*(80,000) = 112,000. However, using a basic terminal, a DMC
controller would calculate the following:
:var= 1.4*80000;' Storing the result of 1.4*80000 in var
:MG var;' Prints variable "var" to screen
111999.5117
:
The reason for this error relies in the precision of the controller. 1.4 must be stored to the nearest multiple of
1/65536, which is 91750/65536 = 1.3999. Thus, (91750/65536)*80000 = 111999.5117 and reveals the source
of the error.
By ignoring decimals and multiplying by integers first (since they carry no error), and then adding the decimal
back in by dividing by a factor of 10 will allow the user to avoid any errors caused by the limitations of precision
of the controller. Continuing from the example above:
:var= 14*80000;' Ignore decimals
:MG var;' Print result
1120000.0000
:var= var/10;' Divide by 10 to add in decimal
:MG var;' Print correct result
112000.0000
:
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-40x0 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:
Chapter 7 Application Programming ▫ 137 DMC-40x0 User Manual

Table of Contents

Other manuals for Galil Motion Control DMC-40 0 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Galil Motion Control DMC-40 0 Series and is the answer not in the manual?

Galil Motion Control DMC-40 0 Series Specifications

General IconGeneral
BrandGalil Motion Control
ModelDMC-40 0 Series
CategoryController
LanguageEnglish

Related product manuals