Programming Flashcards
’’’ # ‘’’
Label Designator
1. The # denotes the name of a program label, eg. #move
2. Labels are often used to implement subroutines or loops .
3. Labels are either user-defined or are reserved names, called “automatic subroutines”, that automatically execute when a particular event occurs.
* Labels can include the characters A-Z, a-z, 1-9. Numbers cannot be the first character. All other characters are invalid.
* A label can only be defined at the beginning of a new line.
* The number of labels available can be queried with MG_DL
* LL returns the current label table in the controller.
* Galil recommends that at least the first character be lowecase for user labels to differentiate from automatic subroutines.
* Automatic subroutines are listed in the command reference starting with a # character.
* There is a maximum of 510 labels available.
’’’ #AUTO ‘’’
Sub
1. Defines the automatic entry point of embedded DMC code.
2. When power is applied to the controller, or after the controller is reset, the program will automatically begin executing at this label.
3. When no host software is used with the controller, #AUTO is required to run an application program on the controller stand-alone
4. Label must be the first element on a line of code.
5. Use EN to end the routine.
6. Thread 0 is used to execute #AUTO on startup
’’’ #COMINT ‘’’
Communication interrupt automatic sub
1. Automatic subroutine to provide interrupt driven communications from the serial port.
2. #COMINT can be configured by the CI command to run either when any character is received, or when a carriage return is received over the com port. (auxiliary port is used if equipped)
3. #COMINT runs in thread 0, and an applications must be running in thread 0 in order for #COMINT to be enabled.
4. Code running in thread 0 will be interrupted by the #COMINT subroutine
5. It is important to handle the interrupt condition and return without delay. The controller will continue to to receive data and update the operands (P1CH, P2CH, etc) while in #COMINT. This can lead to missed characters, numbers, and strings if #COMINT is unnecessarily delayed.
6. It is the user’s responsibility to ensure the communication buffer is not filled when in this mode, otherwise the controller will report error code 5 “Input Buffer Full”. The buffer on the controller is cleared when either of the two following conditions are met
* A carriage return is received on the communication port.
* CI -1 is called.
’’’ #ININT ‘’’
Input Interrupt Automatic Sub
1. The #ININT subroutine is used to execute specific code when inputs specified by the II command are in the desired state.
2. Use the II command to enable the routine,
3. Use RI to exit the routine.
4. To make an unconditional jump from #ININT, there are two methods for re-enabling the interrupt capability.
* Issue a ZS and then re-issue the command II before the JP
* Use a “null” routine. The “null” routine allows for the execution of the RI command before the unconditional jump.
’’’ #MCTIME ‘’’
MC Command Timeout Automatic Sub
1. Automatic sub used to run user-code is a Motion Complete (MC) trippoint times out.
2. If the motor position does not reach or pass the target within the specified timeout (TW), #MCTIME will run if present.
3. MC uses position from TP for servos, or TD for steppers.
4. Use EN to terminate the subroutine.
AB
Abort
1. The AB command is a command to issue an abort to controller operation.
2. AB (Abort) stops motion instantly without a controlled deceleration.
3. If there is a program operatin, AB can also be specified to abort the program and all running threads.
4. The command, AB, will shut off the motors for any axis in which the off on error function (OE) is enabled.
5. -AB gives state of Abort Input , 1 inactive and 0 active
6. AB aborts motion on all axes in motion and cannot stop individual axes
BK
Breakpoint- Pause program execution
1. The BK command causes the controller to pause execution of the given thread at the given thread at the given program line number. When that line is reached, program execution halts before the line is executed, while all other threads continue running.
2. After a breakpoint is encountered, a new breakpoint can be armed (to continue execution to the new breakpoint) or BK will resume program execution.
3. The SL command can be used to single step from the breakpoint.
4. Only one breakpoint may be armed at any time.
5. BK can be armed before or during thread execution.
6. -BK will tell whether a breakpoint has been armed, whether it has been encountered, and the program line number of the breakpoint:
* = -LineNumber : breakpoint armed
* = LineNumber : breakpoint encountered
* = -2147483648: breakpoint not armed
DA
De-allocate variable and arrays
1. The DA command freed the array and/or variable memory space.
2. In this command, more than one array or variable can be specified for memory deallocation.
3. Differenc arrays and variables are separated by comma when specified in one command.
* str[] - Defined array name
* str - Defined variable name
* str = * -Deallocates all the variables
* str = * [] - Deallocates all the arrays
4. -DA contains the total number of arrays available
5. DA? returns the total number of arrays available
6. Since this command deallocates the spaces and compacts the array spaces in the memory it is possible that execution of this command may take longer time than a standard command.
7. Variables and arrays that are deallocated are not set to zero. A routine that writes a zero to the array and/or variables should be created if this is desired.
DL
Download Program
DM
Dimension Arrays
1. The DM command defines a single-dimensional array with a name and n total elements. The first element of the defined array starts with element number 0 and the last element is at n -1
2. Typing in array name with [-1] eleemtn marked reports the number of elements for that array.
3. The first character of str must be alphabetic. The rest can be any alphanumeric characters.
4. When assigning array elements, the number specified must be less than the current available array space.
5. -DM contains the available array space.
6. DM? returns the available array space.
7. The DM command can allocate any number of array in a single command up to the maximum command line length of the controller being used.
ELSE
Else for IF Conditional Statement
1. The ELSE command is an optional part of an IF conditional statement.
2. The ELSE command must occur after an IF command and it has no arguments.
3. It allows for the execution of a command only when the argument of the IF command evaluates False.
4. If the argument of the IF command evaluates false, the controller will skip commands until the ELSE command.
5. If the argument for the IF command evaluates trum the controller will execute the commands between the IF and ELSE command.
EN
End of Program or Subroutine
1. The EN command is used to designate the end of a program or subroutine.
2. 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.
3. A return parameter can be specified to EN from a subroutine to return a value from the subroutine to the calling stack.
4. The EN command is used to end the automatic subroutines #MCTIME, #COMINT, and #CMDERR.
* USe the RE command to end the #POSERR and #LIMSWI subroutines.
* Use the RI command to end the #ININT subroutine.
ENDIF
End of If Conditional Statement
1. The ENDIF command is used to designate the end of an IF conditional statement.
2. 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.
3. It is recommended that the user not include jump commands inside IF conditional statements since this causes re-direction of command execution.
HX
Halt Execution of Program
1. The HX command halts the execution of any program that is running
2. the parameter n specifies the thread to be halted.
3. When used as an operand, -HXn contains the running status of thread n with:
* 0 Thread not running
* 1 Thread is running
* 2 Thread has stopped at trippoint
IF
IF Conditional Statement
1. The IF command is used in conjunction with an ENDIF command to form an IF conditional statement.
2. The arguments consist of one or more conditional statements and each condition must be enclosed with parenthesis ().
3. If the conditional statement(S) evaluates true, the command interpreter will continue executing commands which follow the IF command.
4. If the conditional statement evaluates false, the controller will ignore commands until the associated ENDIF command or an ELSE command occurs in the program.
5. Conditions are tested with the following logical operators:
* < less than or equal to
* > greater than or equal to
* = equal to
* <= less than or equal to
* >= greater than or equal to
* <> not equal
* | and & can be used to evaluate multiple conditions
* The “&” operand between any two conditions requires that both statements must be true for the combined statement to be true.
The “|” operand between any two conditions requires that only one statement be true for the combined statement to be true.
* A true condition = 1 and a false condition = 0
* Each condition must be placed in paranthesis for proper evaluation by the controller.