RS V8849 Hoja De Instrucciones página 26

Tabla de contenido

Publicidad

Idiomas disponibles
  • ES

Idiomas disponibles

  • ESPAÑOL, página 12
V8849
Stepper Motor Control Language
The on board language provided for control of the stepper motors has been designed
to give the maximum flexibility while making the programming as simple as possible.
The language is similar to the C language which can utilize the usual statements like:-
For
While
If... Else...
Print
etc...
KEYWORDS
———————————————————————————————
//
—————————————————————————————————————
Purpose:
To comment a program
Syntax:
// text
Remarks:
The text after the // to the end of line is ignored by the control board
program.
Example:
// a comment which does nothing
—————————————————————————————————————
@
Redirection in daisychained systems
—————————————————————————————————————
Purpose:
To address the nth card in a multicard control board system.
Syntax:
@n all further input and output is from the nth card
Remarks:
To program the first slave card send @1 and then program the card
as if it were the master. Send @0 when you wish to program the
master card again.
Example:
@1
out(255)
// turn on all the outputs on card #1
@0
—————————————————————————————————————
+,-,*,/
Numeric operators
—————————————————————————————————————
Purpose:
Arithmetic
Syntax:
e1 + e2
e1 - e2
e1 * e2
e1 / e2
-e1
where e1 and e2 are expressions
Remarks:
The operators have the following names:
+
add
-
subtract
*
multiply
/
integer divide (ignores fractional part)
-
negate
Example:
1+2
// prints 3
70/6
// prints 11
—————————————————————————————————————
==,<,>,<=,>=,!=
Boolean operators
EQ,LT,GT,LE,GE,NE
—————————————————————————————————————
Purpose:
Comparison of values of expressions
Syntax:
e1 EQ e2
true if e1 and e2 evaluate the same
e1 == e2
as above
e1 LT e2
true if e1 is less than e2
e1 < e2
as above
e1 GT e2
true if e1 is greater than e2
e1 > e2
as above
e1 LE e2
true if e1 is not greater than e2
e1 <= e2
as above
e1 GE e2
true if e1 is not less than e2
e1 >= e2
as above
e1 NE e2
true if e1 is not equal to e2
e1 != e2
as above
Remarks:
These conditional expressions evaluate to 1 for true and 0 for false.
Note the alternative forms for each relation.
Example:
2 < 3
// prints 1 (true)
3*3 GE 4*4
// prints 0 (false)
—————————————————————————————————————
&&,||,^^,!
Logical operators
AND,OR,XOR,NOT
—————————————————————————————————————
Purpose:
Logical operations
Syntax:
e1 AND e2
true if e1 and e2 are non-zero (true)
e1 && e2
as above
e1 OR e2
true if e1 or e2 are non-zero
e1 || e2
as above
e1 XOR e2
true if only one of e1,e2 is non-zero (true)
e1 ^^ e2
as above
NOT e1
true if e1 is zero (false) and visa versa
!e1
as above
Remarks:
These logical operations evaluate to 1 for true and for false.
Note the alternative forms for each relation.
Example:
2>3 && 4>1
// prints 1 (true)
2 OR 3>5
// prints 1 as 2 is non-zero
!137
// prints 0 (false) as 137 non-zero
!!137
// prints 1 (true)
—————————————————————————————————————
&,|,^
Bitwise binary operators
—————————————————————————————————————
Purpose:
Binary bitwise operations which treat expressions as binary numbers.
Syntax:
e1 & e2
bitwise and of e1 and e2
e1 | e2
bitwise or of e1 and e2
e1 ^ e2
bitwise xor of e1 and e2
Remarks:
These would typically be used in conjunction with the optocoupled
inputs and outputs.
Example:
2&6
// prints 2 (010&110 = 010)
3|5
// prints 7 (011|101 = 111)
26
Comment
out(4|8)
// turn on outputs #2 and #3
in()&3
// true if input #0 or #1 is on
—————————————————————————————————————
=, +=, -=, *=, /=
—————————————————————————————————————
Purpose:
To assign a new value to a variable
Syntax:
var = e1
set value of var to e1
var += e1
set value of var to var+e1
var -= e1
set value of var to var-e1
var *= e1
set value of var to var*e1
var /= e1
set value of var to var/e1
where var is a variable name.
Remarks:
Obviously one cannot assign a value to a constant.
The divide is integer divide as above. The last four forms above
require that var has been assigned previously.
Example:
felicity = 7
// sets value of felicity to 7
a = 4
// sets value of a to 4
a *=5
// sets value of a to 20
—————————————————————————————————————
++,—
Autoincrement and decrement operators
—————————————————————————————————————
Purpose:
Concise incrementing and decrementing of variables
Syntax:
var++
increase value of var by 1
var—
decrement value of var by 1
Remarks:
The variable must have been assigned previously.
Example:
i=4
i++
// prints 5
—————————————————————————————————————
else
—————————————————————————————————————
See entry for if
—————————————————————————————————————
end
—————————————————————————————————————
Purpose:
To halt program execution under software control
Syntax:
end
Remarks:
Normally the program will stop executing when it has finished
executing the program the user has typed in.
If it is necessary to stop earlier this command causes an early stop.
Example:
if (i EQ 0) end
else print 100/i
—————————————————————————————————————
for
—————————————————————————————————————
Purpose:
To perform a repetitive program action
Syntax:
for (statement1; expression; statement2) statement3
Remarks:
This is the most complex command. It is not essential
for any program but does make programs more concise.
This type of for loop is much more general than the "for i=0 to 10 step
2" type.
Statement1 is executed when the loop starts.
Then while the expression is true (non-zero) statement3 is executed
followed by statement2.
Example:
for (i=0; i<10; i++) {
for (j=0; j<10; j++) print i,j,"\n"
}
This prints out:
00
01
..
98
99
NB: "{" and "}" extend a statement list over several lines.
"\n" causes a newline to be printed.
—————————————————————————————————————
func
—————————————————————————————————————
Purpose:
To define a function for use in a program
Syntax:
func name() {
...function statements using %1,%2 etc..
return expression
}
Remarks:
Defining a function does not cause its execution. A function must
return a value. The arguments of a function (if any) are referred to by
the dummy variables %1,%2 etc: Any variables defined outside the
function are known to the function. Any variables changed inside the
function are changed outside the function.
Example:
func square() { // this defines the function
return %1*%1
}
i= square(4)
—————————————————————————————————————
if,else
—————————————————————————————————————
Purpose:
To perform program actions dependent on value of an expression.
Syntax:
if (expression) statement
if (expression) statement
else statement
Remarks:
In the first form the statement is executed if the expression evaluates
as non-zero (true).
In the second form the first statement is executed if the expression
evaluates as true but the second statement if it is false (zero).
Example:
if (a EQ 2) print "ok"
if (a > 3) out(1,0)
else out(1,1)
Assignments
Command
Command
// we don't want to divide by 0
Command
// repeat for i=0 to 9
// repeat for j=0 to 9
Function definition
// sets value of i to 16
Command
// if a>3 turn off output #1
// otherwise turn it on

Publicidad

Tabla de contenido
loading

Tabla de contenido