stop()
Stop motion abruptly
—————————————————————————————————————
Purpose:
To abruptly stop the motors in an emergency.
Syntax:
stop()
stop both motors
stop(axis)
stop specified axis
Remarks:
This stop is sudden and is likely to cause loss of position.
It is advisable to use datum() after a stop() or else to use halt().
Example:
stop(1)
// abruptly stop axis #1 motor
See also:
halt(), move(), datum()
—————————————————————————————————————
time()
Time since program started
—————————————————————————————————————
Purpose:
To return how long it is from some previous state.
Syntax:
time()
returns time in ticks of 1mS
time(val)
set the value of time()
Remarks:
This command is very useful in allowing for timeout in user programs.
Example:
t_stop=time()+60000
movel(-1,-1)
while ((time()<t_stop)&&moving()) { // wait till 60 secs
}
// have passed or motion has stopped
stop()
// then stop anyway
See also:
wait()
—————————————————————————————————————
where()
Report motor position
—————————————————————————————————————
Purpose:
To report current position of motors
Syntax:
where(axis) where is specified axis (in units of steps)
Remarks:
This reports the distance in steps from the datum position.
Example:
cmovel(1,1)
// start a slow move
where(0)
// show #0 position
where(1)
// show #1 position
where(0)
// show #0 position again
where(1)
// show #1 position again
See also:
datum()
—————————————————————————————————————
wait()
Wait for a period of time
—————————————————————————————————————
Purpose:
To wait for a specified time.
Syntax:
wait(n) wait for n mS
Example:
out(0,1)
// turn on output #0
wait(1000)
// wait 1mS
out(0,0)
// turn off output #0
See also:
time()
EXAMPLE PROGRAMS
All motions are specified as absolute motions ie: motions to the specified position in
units of motor steps from the datum (origin).
move(1000,1000)
move(1000,1000)
1)
BACKWARDS AND FORWARDS
A simple program which moves the x to 2000 and the y axis to 1000,
then back to the origin and then to (2000,1000) repeatedly until input 1 is switched on.
while( NOT in(1) ) {
move(2000,1000)
while(moving()){
}
move(0,0)
while(moving()){
}
}
NB:
The program listing is shown with indentation as this aids
readability. Such spaces are ignored by the CONTROL BOARD.
The param() command can be used to change the parameters of motor motion (ie:
starting speed, top speed, acceleration and deceleration).
2)
PULSE OUTPUTS
Turn all the outputs on and off repeatedly.
while(1) {
out(255)
wait(1000)
out(0)
wait(1000)
}
3)
DRILL A SQUARE
This program moves a drill connected to two lead screws driven by stepper motors.
The drill is moved to the corners of a square and at each corner the drill is switched
on to produce a hole.
The operator must press a switch #0 before each cycle to start the operation.
The output#2 turns the drill on and off.
The LCD display shows messages.
This demonstrates the use of procedures. Note that nothing happens while the
procedure is defined... only when it is run.
proc drill() {
out(2,1)
wait(4000)
out(2,0)
}
proc do_move() {
move(%1,%2)
while (moving){ // wait for completion
}
}
proc cycle() {
do_move(3000,0)
// 60 seconds from now
// start move to limit
// move to 1000,1000
// wait till its there
// nothing happens because we
// are already there
// loop while not input #1
// issue move to (2000,1000)
// wait till move complete
// end of while moving loop
// move back to start
// wait till move complete
// end of while moving loop
// end of outer while loop
// endless loop
// all outputs on
// wait 1 second
// all outputs off
// wait 1 second
// end of while loop
// define procedure to drill a hole
output
// turn on
#2
// wait 4 seconds
// turn off output #2
// end of drill procedure
// define procedure to do
//complete move
// issue the move (%1 and %2
//are args)
// end of while loop
// end of procedure
// define procedure to do a
//drill cycle
// move to first position
drill()
do_move(3000,3000)
drill()
do_move(0,3000)
drill()
do_move(0,0)
drill()
}
n=1
param(0,150,6000,400,400)
param(1,150,6000,400,400)
while(1) {
lcd "\fPress start"
while (!in(0)) {
}
cycle()
lcd "\fCycle=",n
n++
wait(1000)
}
NB:The move() command does not wait until the motion is complete before returning
as this would severely limit the range of possible programs (ie: it would be impossible
to perform any other operation while moving). The user procedure do_move() does a
complete move.
If the LCD is not fitted an attempt to use it will generate an error. Leave out the lcd
commands if there is no LCD.
4)
MOVE ROUND A PROFILE
This program shows motion round a specified profile.
This shows the use of autoexec() to make a program which executes
automatically when the CONTROL BOARD is switched on:
The LCD display shows a message,
The mouse is used to move to the datum position
Input #0 starts the process
Output #1 could turn on a laser
The motors move round the profile
This repeats
proc do_move() {
move(%1,%2)
while (moving){
}
}
proc do_arc() {
arc(%1,%2,%3) // issue the arcmove
while (moving){
}
}
proc profile() {
do_move(1000,-1000)
out(0,1)
do_arc(1000,0,180)
do_move(-1000,1000)
do_arc(-1000,0,180)
do_move(1000,-1000)
out(0,0)
}
proc autoexec() {
while(1) {
manual()
lcd "\fSet datum\nPress DATUM"// message on LCD
while (NOT in(0) ) {
}
stop()
datum()
lcd "\fRUNNING"
profile()
}
}
Now turn the CONTROL BOARD off, wait 20 seconds and turn it on again.
Did you buy the non-volatile memory?
Use of the Control Board Software (Terminal Emulator)
This is a program to be run on a IBM PC or compatible. It is intended to help program
development.To run the disk just put the disk in the current drive and type RSL.
The program is a simple terminal emulator with the capability of saving program listing
to files and also of re-entering programs into the control board from files.
The disk contains many example programs. Look at the README.TXT file for more
detail.
V8849
// drill a hole
// move to second position
// drill a hole
// move to third position
// drill a hole
// move to start position
// drill a hole
// end of procedure
// n counts the number of cycles
// setup x axis parameters
// setup y axis parameters
// loop endlessly
// clear LCD and display
// message
// wait for input #0
// end of while loop
// perform drill cycle
// display cycle number
// increment n
// wait 1 second
// end of while loop
// define procedure to do
//complete move
// issue the move (%1 and %2
//are args)
// wait for completion
// end of while loop
// end of procedure
// define procedure to do
//complete arc
// wait for completion
// end of while loop
// end of procedure
// define procedure to trace
//profile
// move to (1000,-1000)
// turn something on
// do an end semicircle (radius
//1000)
// straight line along top
// do another end semicircle
// straight line along bottom
// turn something off
// end of procedure
// this defines the autoexec
// procedure
// loop endlessly
// allow manual motion
// wait for input #0
loop
// end of while
// turn off manual mode
// set datum
// say we are running
// move round profile
// end of outer while loop
// end of autoexec procedure
29