DMC Commands Flashcards
TP
Tell Position
The TP command returns the current position of the motor.
TP: ' Return all motor positions 200, -10, 50, 400 //controller response TPA ; ' Return the A motor position 200 //controller response TPB ; ' Return the B motor position -10 //controller response position =_TPA ; ' assign current position of A to a variable
DP
Define Position
The DP command sets the current motor position and current command positions to a user specified value. The units are in quadrature counts. This command will set both the TP and RP values.
DP 0,-1000;' Set position of A to zero and B to -1000 TP?,? ; ' Interogate controller for current positions 0,-1000 //controller response
TE
Tell Error
The TE command returns the position error of the motor(s), which is the difference between commanded (RP) and actual (TP) position.
TE ; ' Return all position errors 5, -2, 0, 6 //controller response TEB ; ' Return position error of B -2 //controller response
RP
Reference Position
The RP command returns the commanded reference position of the motor(s).
The relationship between RP, TP and TE: TE equals the difference between the reference position, RP, and the actual position, TP.
TE = RP - TP
RP command is useful when operating step motors since it provides the commanded position in steps when operating in stepper mode.
_RPm contains the commanded reference position for the specified axis.
RP;' Return A,B,C,D reference positions 200,-10,0,-110 //controller response RPA ; 'Return the A motor reference position 200 //controller response RPB ; 'Return the B motor reference position -10 //controller response
SH
Servo Here (Enable Motor)
The SH commands tells the controller to use the current motor position as the command position (ie: zeros the position error) and to enable servo control at the current position, thus providing torque to the motor. Toggles the amplifier enable signal when using external drives.
SH;' Enable/servo A,B,C,D motors SHA;' Only servo the A motor, the B,C and D motors remain in its previous state. SHB;' Servo the B motor, leave the A,C and D motors unchanged SHC;' Servo the C motor, leave the A,B and D motors unchanged SHD;' Servo the D motor, leave the A,B and C motors unchanged
MO
Motor Off (Disable Motor)
The MO command turns off the motor command line and toggles the amplifier enable signal.
MO; 'Turns off all motors MO A; 'Turns off the A motor. MO B; 'Turns off the B motor. MO CA; 'Turns off the C and A motors. SH; 'Turns all motors on axis1= _MOA; 'Sets variable equal to the A-axis servo status
PR
Position Relative
The PR command sets the incremental distance and direction of the next move. The move is referenced with respect to the current position. Units are counts.
PR 100,200; ' Set relative distance targets BG; ' Begin moves MAB: ' Wait for motion on A and B to complete PR ?,?; ' Request relative distances 100,200 //controller response PRA=500; ' Set new relative distance for A BG; ' Begin. A will go 500 counts while B will go its previously set relative distance of 200. AMAB: ' Wait for motion on A and B to complete
PA
Position Absolute
The PA command sets the end target of the Position Absolute Mode of Motion. Units are counts.
PA 100,200; ' Set absolute position targets BG; ' Begin moves AMAB: ' Wait for motion on A and B to complete PA ?,?; ' Request absolute positions 100,200 //controller response PAA=500; ' Set new absolute distance for the A BG; ' Begin on all axes. A will go to position 500 while B will not move AMAB: ' Wait for motion on A and B to complete
SP
Speed
```The SP command sets the slew speed of any or all axes for independent moves. Units are counts/sec.
PR 10000; ‘ Specify position
AC 2000000; ‘ Specify acceleration rate
DC 1000000; ‘ Specify deceleration rate
SP 5000; ‘ Specify slew speed
BG; ‘ Begin motion
~~~
AC
Acceleration
The AC command sets the linear acceleration of the motors for independent moves such as PR, PA, and JG moves. Unit are counts/sec^2.
PR 10000; ' Specify position AC 2000000; ' Specify acceleration rate DC 1000000; ' Specify deceleration rate SP 5000; ' Specify slew speed BG; ' Begin motion
DC
Deceleration
The DC command sets the linear deceleration of the motors for independent moves such as PR, PA, and JG moves. Unit are counts/sec^2.
PA 10000; ' Specify absolute position AC 2000000; ' Specify acceleration rate DC 1000000; ' Specify deceleration rate SP 5000; ' Specify slew speed BG; ' Begin motion
BG
Begin
The BG command starts a motion on the specified axis or sequence.
PR 10000,4000,,-8000; ' Specify positions for relative move on Axis A, B and D BG AD; ' Begin motion on Axis A and D AM AD; ' Wait for motion to complete on Axis A and D BG D; ' Begin motion on Axis B AM B; ' Wait for motion to complete on Axis B
ST
Stop
The ST command stops motion on the specified axis. Motors will come to a decelerated stop
ST A; ' Stop motion on the A axis SC A; ' Query A axis status 4 //controller response - Indicates stopped by ST command
AM
After Move
The AM command is a trippoint used to control the timing of events. This command will hold up execution of the following commands until the current move on the specified axis or axes is completed. Any combination of axes or a motion sequence may be specified with the AM command.
AM tests for profiler completion only. Use MC to test for physical motion to complete.
PR 4000; BGA ; ' make move AMA; ' wait for move to complete on A PR4000,2000; BG; ' make move on A and B AM; ' wait for move to complete on all axes
MC
Motion Complete
The MC command is a trippoint command that holds up execution until motion is complete on the specified axes. The MC command, unlike the AM (after motion command) requires that both the motion profiler has completed motion AND that the motor encoder has reached the specified position before continuing execution.
PR 4000; BGA; ' make move MCA; ' wait for motion to complete on A PR4000,2000; BG; ' make move on A and B MC; ' wait for motion to complete on all axes
WT
Wait
The WT command is a trippoint used to time events. When this command is executed, the controller will wait for the amout of time (msec) specified before executing the next command.
#A ; ' Program A PR 50000 ; ' Position relative move BGA ; ' Begin the move AMA ; ' After motion on A is complete WT 10000 ; ' Wait 10 seconds SB 1 ; ' Turn on relay (set output 1) WT 2000 ; ' Wait 2 seconds CB1 ; ' Turn off relay (clear output 1) EN ; ' End program
AI
After Input
The AI command is a trippoint used in motion programs to wait until after a specified input has changed state. This command can be configured such that the controller will wait until the input goes high or the input goes low.
AI 8;' wait until input 8 is high SP 10000; AC 20000; PR 4000; BGA;' make move AMA:' wait for move to complete AI -3;' wait until input 3 is low PA0; BGA:' make move AMA;' wait for move to complete
SB
Set Bit
The CB command sets a particular digital output. The SB and CB (Clear Bit) instructions can be used to turn on and off the state of digital outputs.
SB 5;' Set digital output 5 SB 1;' Set digital output 1 CB 5;' Clear digital output 5 CB 1;' Clear digital output 1
CB
Clear Bit
The CB command clears a particular digital output. The SB and CB (Clear Bit) instructions can be used to turn on and off the state of digital outputs.
SB 5;' Set digital output 5 SB 1;' Set digital output 1 CB 5;' Clear digital output 5 CB 1;' Clear digital output 1
#
Label Designator
The # denotes the name of a program label, for example, #move. Labels are often used to implement subroutines or loops. Labels are either user-defined or are reserved names, called “automatic subroutines”, that automatically execute when a particular event occurs.
7 characters max length. Labels can include the characters A-Z, a-z, 1-9. Numbers can not be the first character. All other characters are invalid.
#for sum=sum+i ; ' Add counter to sum i=i+1;' Increment counter JP#for,(i\<=10) ; ' Jump to #for label as long as is less than or equal to 10 EN
EN
End
The EN command is used to designate the end of a program or subroutine. If a subroutine was called by the JS command, the EN command ends the subroutine and returns program flow to the point just after the JS command.
#A; ' Program A PR 500 ; ' Move A axis forward 500 counts BGA ; ' Begin motion on A AMA ; ' Wait for motion to complete on A EN ; ' End of Program
XQ
Execute Program
The XQ command begins execution of a program residing in the program memory of the controller. Execution will start at the label or line number specified.
Up to 8 programs may be executed simultaneously to perform multitasking.
XQ #apple,0 ; ' Start execution at label apple as thread zero XQ #data,2 ; ' Start execution at label data as thread two
#AUTO
Subroutine to Automatically Run on Power-Up
Defines the automatic entry point of embedded DMC code. When power is applied to the controller, or after the controller is reset, the program will automatically begin executing at this label. When no host software is used with the controller, #AUTO is required to run an application program on the controller stand-alone.
'This code will run upon power up #AUTO;' Start on powerup SB 1;' Set bit 1 WT 500;' Wait 500msec CB 1;' Clear bit 1 WT 500;' Wait 500msec JP #AUTO;' Jump back to #AUTO
; (Semicolon)
Command Delimiter
The semicolon operator allows multiple Galil commands to exist on a single line.
SB1;WT500;CB1;' multiple commands separated by semicolons with a comment AC10000;SP4000;BGA;' multiple commands separated by semicolons with a comment
JP
Jump to a Program Location
The JP command causes a jump to a program location on a specified condition. The program location may be any program line number or label. A jump is taken if the specified condition is true. Multiple conditions can be used in a single jump statement.
JP #C ; ' Jump to #C unconditionally JP #POS1,(V1<5) ; ' Jump to label #POS1 if variable V1 is less than 5 JP #A,((V7*V8)=0) ; ' Jump to #A if V7 times V8 equals 0 JP #B,(@IN[1]=1) ; ' Jump to #B if input 1 = 1
JS
Jump to Subroutine
The JS command allows the program to jump to a subroutine and return back after completion. This command is often used to call reusable code.
#main;' Program Main PR2000;SP4000;BGA;' make move AMA;' wait for move to complete JS#PULSE;' gosub to #PULSE PR-2000;SP-4000;BGA;' make move AMA;' wait for move to complete JS#PULSE;' gosub to #PULSE EN;' end of program #PULSE SB1;WT100;CB1;WT100;' turn on/off output1 EN;' end of subroutine - return to calling program
IF
IF Conditional Statement
The IF command is used in conjunction with an ENDIF command to form an IF conditional statement. The arguments consist of one or more conditional statements and each condition must be enclosed with parenthesis (). If the conditional statement(s) evaluates true, the command interpreter will continue executing commands which follow the IF command. If the conditional statement evaluates false, the controller will ignore commands until the associated ENDIF command or an ELSE command occurs in the program.
#A IF (_TPA<1000);' IF conditional statement based on a motor position MG "Motor is within 1000 counts of zero";' Message to be executed for true ENDIF;' End of IF conditional statement EN #input IF (@IN[1]=0);' IF conditional statement based on input 1 MG "Input 1 is Low";' Message to be executed if "IF" statement is true ENDIF;' End of IF conditional statement EN v1=@AN[1]*5;' some calculation for variable v1 IF((v1>25)&(@IN[4]=1));' Conditions based on V1 variable and input 4 status MG "Conditions met";' Message to be executed if "IF" statement is true ENDIF;' End of IF statement EN
ENDIF
End of IF Conditional Statement
The ENDIF command is used to designate the end of an IF conditional statement. An IF conditional statement is formed by the combination of an IF and ENDIF command. An ENDIF command must always be executed for every IF command that has been executed. It is recommended that the user not include jump commands inside IF conditional statements since this causes re-direction of command execution. In this case, the command interpreter may not execute an ENDIF command.
IF (@IN[1]=0);' IF conditional statement based on input 1 IF (@IN[2]=0);' 2nd IF conditional statement executed if 1st IF conditional true MG "IN1 AND IN2 ARE ACTIVE";' Message if 2nd IF conditional is true ELSE;' ELSE command for 2nd IF conditional statement MG "ONLY IN1 IS ACTIVE";' Message if 2nd IF conditional is false ENDIF;' End of 2nd conditional statement ELSE;' ELSE command for 1st IF conditional statement IF (@IN[2]=0);' 3rd IF conditional statement executed if 1st IF conditional false MG "ONLY IN2 IS ACTIVE";' Message if 3rd IF conditional statement is true ELSE;' ELSE command for 3rd conditional statement MG "IN1 AND IN2 INACTIVE";'Message if 3rd IF conditional statement is false ENDIF;' End of 3rd conditional statement ENDIF;' End of 1st conditional statement
ELSE
ELSE Function for Conditional IF Statement
The ELSE command is an optional part of an IF conditional statement. The ELSE command must occur after an IF command and it has no arguments. It allows for the execution of a command only when the argument of the IF command evaluates False. If the argument of the IF command evaluates false, the controller will skip commands until the ELSE command. If the argument for the IF command evaluates true, the controller will execute the commands between the IF and ELSE command.
IF (@IN[1]=0);' IF conditional statement based on input 1 IF (@IN[2]=0);' 2nd IF conditional statement executed if 1st IF conditional true MG "IN1 AND IN2 ARE ACTIVE";' Message if 2nd IF conditional is true ELSE;' ELSE command for 2nd IF conditional statement MG "ONLY IN1 IS ACTIVE";' Message if 2nd IF conditional is false ENDIF;' End of 2nd conditional statement ELSE;' ELSE command for 1st IF conditional statement IF (@IN[2]=0);' 3rd IF conditional statement executed if 1st IF conditional false MG "ONLY IN2 IS ACTIVE";' Message if 3rd IF conditional statement is true ELSE;' ELSE command for 3rd conditional statement MG "IN1 AND IN2 INACTIVE";'Message if 3rd IF conditional statement is false ENDIF;' End of 3rd conditional statement ENDIF;' End of 1st conditional statement
@IN
Read Digital Input
The @IN operand returns the value of the given digital input (either 0 or 1).
MG @IN[1] 1.0000 x = @IN[1] ; ' assign value of digital input 1 to variable x = ? ; ' print value 1.000 JP #LOOPER,(@IN[2]=1) ; ' Jump to #LOOPER if input 2 = 1
@OUT
Read Digital Output
Returns the value of the given digital output (either 0 or 1)
MG @OUT[1] ; ' print value of digital output 1 1.0000 x = @OUT[1] ; ' assign state of digital output 1 to a variable
@AN
Analog Input Query
The @AN[] operator returns the value of the given analog input in volts.
MG @AN[1] ; 'print analog input 1.7883 a1 = @AN[1] ; 'assign value of analog input 1 to variable
AB
Abort
The AB command issues an abort to controller operation.
AB stops motion on all axes instantly without a controlled deceleration. If there is a program operating, AB can also be specified to abort the program and all running threads. The command, AB, will shut off the motors for any axis in which the off on error function is enabled (see command “OE”).
AB1; ' stop motion without aborting program AB0; ' stop motion and program execution
JG
Jog
The JG command sets the jog mode and the jog slew speed of the axes.
To stop motion use ST command.
JG 4000,-2000; ' Set jog mode and slew speeds BG; ' Begin motion WT1000; ' Wait 1000 msec JGB= -4000; 'Change slew speed on B
AD
After Distance
The AD command is a trippoint to block command execution until a given distance is traversed. This is a profiled trippoint which means it depends on the motion profiler and not the actual motor encoder. AD can only be used when there is commanded motion on the axis.
#A DP 0,0;' Zero position PR 10000,20000;' Specify position relative moves BG ;' Begin motion AD 5000;' After A reaches 5000 MG "Halfway to A";TP A;' Send message AD ,10000;' After B reaches 10000 MG "Halfway to B";TP B;' Send message EN
AP
After Absolute Position
The AP command will hold up the execution of the following command until the actual motor position crosses the specified position. This trippoint does not rely on the profiler, but on actual encoder position.
#test DP0;' Define zero JG 1000;' Jog mode (speed of 1000 counts/sec) BG A;' Begin move AP 2000;' After passing the position 2000 V1=_TPA;' Assign V1 A position MG "Position is", V1;' Print Message ST;' Stop motion EN;' End of Program
KP
Proportional Gain Constant
KP designates the proportional constant in the controller filter. The proportional gain outputs a control signal proportional to the amount of error.
Affects the stiffness of the motor.
\:KP 12,14,16,20;' set a,b,c,d axis proportional term \:KPC= 8;' set C proportional term only \:KPC=? ; ' interrogate for C proportional term 8.0 //controller response \:KP?,?,?,? ; ' interrogate for A,B,C,D values 12.0,14.0,8.0,20.0 //controller response
KD
Derivative Gain Constant
KD designates the derivative constant in the control filter. The derivative gain outputs a voltage based on the rate of change of the error.
Affects the damping (overshoot, undershoot) of the motor.
\:KD 60,72,55,81;' set a,b,c,d axis derivative term \:KDC= 65;' set C derivative term only \:KDC=? ; ' interrogate for C derivative term 65.0 //controller response \:KD?,?,?,? ; ' interrogate for A,B,C,D values 60.0,72.0,65.0,81.0 //controller response
KI
Integrator Gain Constant
The KI command sets the integral gain of the control loop. The integrator term will reduce the position error at rest to zero.
\:K1 7,14,8,1;' set a,b,c,d axis derivative term \:KIC= 2.1;' set C derivative term only \:KDC=? ; ' interrogate for C derivative term 2.1 //controller response \:KD?,?,?,? ; ' interrogate for A,B,C,D values 7.0,14.0,2.1,1.0 //controller response
AR
After Relative Distance
The AR command is a trippoint used to control the timing of events. This command will hold up the execution of the following command until one of the following conditions have been met:
- The commanded motor position crosses the specified relative distance from either the start of the move or the last AR or AD command.
- The motion profiling on the axis is complete.
- If in jog (JG) mode, the commanded motion is in the direction which moves away from the specified position.
#A;' Program A DP 0;' Set position to zero JG 50000;' Specify jog speed BG A;' Begin motion #B;' Label AR 25000;' After passing 25000 counts of relative distance on A-axis MG "Passed";TPA;' Send message on A-axis JP #B;' Jump to Label #B EN;' End Program