advertisement
REM the sum of the amperr bits should be 0 with no amplifier error er=_TA0+mask+_TA2+_TA3
JP#AMPERR,er0
REM Notify user amperr has cleared
MG″AMPERR RESOLVED″
WT3000
RE
JS Subroutine Stack Variables (^a, ^b, ^c, ^d, ^e, ^f, ^g, ^h)
There are 8 variables that may be passed on the subroutine stack when using the JS command. Passing values on the stack is advanced DMC programming, and is recommended for experienced DMC programmers familiar with the concept of passing arguments by value and by reference.
Notes:
1. Passing parameters has no type checking, so it is important to exercise good programming style when passing parameters. See examples below for recommended syntax.
2. Do not use spaces in expressions containing ^.
3. Global variables MUST be assigned prior to any use in subroutines where variables are passed by reference.
4. Please refer to the JS command in the controller's command reference for further important information.
Example: A Simple Adding Function
#Add
JS #SUM (1,2,3,4,5,6,7,8)
MG _JS
EN
'
;' call subroutine, pass values
;' print return value
#SUM
EN ,,(^a+^b+^c+^d+^e+^f+^g+^h)
;NO(^a,^b,^c,^d,^e,^f,^g,^h) syntax note for use
;' return sum
:Executed program from program1.dmc
36.0000
Example: Variable, and an Important Note about Creating Global Variables
#Var value=5 global=8
JS #SUM (&value,1,2,3,4,5,6,7)
MG value
MG _JS
EN
'
#SUM
^a=^b+^c+^d+^e+^f+^g+^h+global
EN ,,^a
;'a value to be passed by reference
;'a global variable
;'note first arg passed by reference
;'message out value after subroutine.
;'message out returned value
;NO(* ^a,^b,^c,^d,^e,^f,^g)
'notes:
'do not use spaces when working with ^
'If using global variables, they MUST be created before the subroutine is run
Executed program from program2.dmc
36.0000
36.0000
Chapter 7 Application Programming
•
141 DMC-41x3 User Manual
advertisement
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Related manuals
advertisement
Table of contents
- 22 Standard Servo Motor Operation:
- 22 Stepper Motor Operation
- 22 Master Reset and Upgrade Jumpers
- 23 Motor Off Jumper
- 23 Communications Jumpers for DMC-41x3
- 23 Amplifier Enable Jumper Configuration
- 23 Using Windows XP, Vista and 7 (32 & 64 bit):
- 23 Using Linux (32 & 64 bit):
- 24 Communicating through an Ethernet connection
- 24 Using GalilTools Software for Windows
- 25 Communicating through the USB Programming Port
- 25 Using GalilTools Software for Windows
- 25 Sending Test Commands to the Terminal:
- 25 Connecting to External Amplifiers
- 27 Inverting the Loop Polarity
- 42 Using Voltages > 28 VDC
- 42 Bypassing the Opto-Isolation
- 43 Description
- 43 Electrical Specifications
- 43 Wiring the Standard 4mA outputs
- 44 Description
- 44 Electrical Specifications
- 44 Wiring the 25mA Sinking Outputs
- 45 Description
- 45 Electrical Specifications
- 45 Wiring the 25mA Sourcing Outputs
- 46 Description
- 46 Electrical Specifications
- 46 Wiring the 500mA Sourcing Opto-Isolated Outputs
- 47 Electrical Specifications
- 47 Example:
- 48 Electrical Specifications
- 48 Electrical Specifications
- 48 Electrical Specifications
- 49 Electrical Specifications
- 56 Baud Rate Selection
- 56 USB Driver
- 57 RS232 ‑ Auxiliary Port
- 57 Handshaking
- 57 Example:
- 61 Example #1
- 61 Results:
- 61 Example #2
- 62 Results:
- 62 Example #3
- 62 Results:
- 67 Header Information - Byte 0, 1 of Header:
- 67 Bytes 2, 3 of Header:
- 67 Thread Status (1 Byte)
- 67 Coordinated Motion Status for S or T Plane (2 Byte)
- 68 Axis Status (1 Word)
- 68 Axis Switches (1 Byte)
- 72 C++ Library (Windows and Linux)
- 72 COM (Windows)
- 77 Header Format:
- 77 Data fields Format
- 78 Example
- 83 Example - Absolute Position Movement
- 83 Example - Multiple Move Sequence
- 85 Example - Jog in X only
- 85 Example - Joystick Jogging
- 91 Additional Commands
- 91 An Example of Linear Interpolation Motion:
- 92 Specifying Vector Speed for Each Segment
- 92 Changing Feed Rate:
- 96 Specifying Vector Speed for Each Segment:
- 97 Changing Feed Rate:
- 97 Compensating for Differences in Encoder Resolution:
- 97 Trippoints:
- 97 Tangent Motion:
- 97 Example:
- 98 Example:
- 101 Example – Electronic Gearing Over a Specified Interval
- 103 Example - Synchronize two conveyor belts with trapezoidal velocity correction
- 110 Parabolic Velocity Profile
- 115 General Velocity Profiles
- 116 Generating an Array - An Example
- 116 Contour Mode Example
- 117 Teach (Record and Play-Back)
- 117 Record and Playback Example:
- 119 Stepper Motor Smoothing
- 119 Monitoring Generated Pulses vs. Commanded Pulses
- 120 Motion Complete Trippoint
- 122 Example: SPM Mode Setup
- 122 Full-Stepping Drive, X axis:
- 122 Half-Stepping Drive, X axis:
- 122 1/64th Step Microstepping Drive, X axis:
- 123 Example: Error Correction
- 123 Example: Friction Correction
- 125 Continuous Dual Loop - Example
- 126 Sampled Dual Loop - Example
- 127 Example - Smoothing
- 129 Example: Homing
- 131 Example: Find Edge
- 133 Valid labels
- 134 Invalid labels
- 134 Using the command, NO or Apostrophe (‘)
- 135 Difference between NO and ' using the GalilTools software
- 138 DMC-41x3 Event Triggers
- 139 Event Trigger - Multiple Move Sequence
- 139 Event Trigger - Set Output after Distance
- 139 Event Trigger - Repetitive Position Trigger
- 140 Event Trigger - Start Motion on Input
- 140 Event Trigger - Set output when At speed
- 140 Event Trigger - Change Speed along Vector Path
- 140 Event Trigger - Multiple Move with Wait
- 141 Define Output Waveform Using AT
- 141 Using AT/WT with non-default TM rates
- 141 Command Format - JP and JS
- 142 Logical operators:
- 142 Conditional Statements
- 142 Examples:
- 142 Multiple Conditional Statements
- 143 Using the JP Command:
- 143 Example Using JP command:
- 143 Using the IF and ENDIF Commands
- 143 Using the ELSE Command
- 144 Nesting IF Conditional Statements
- 144 Command Format - IF, ELSE and ENDIF
- 144 Example using IF, ELSE and ENDIF:
- 144 Example:
- 146 Example - Limit Switch:
- 146 Example - Position Error
- 147 Example - Input Interrupt
- 147 Example - Motion Complete Timeout
- 147 Example - Command Error
- 148 Example - Command Error w/Multitasking
- 148 Example - Communication Interrupt
- 149 Example – Ethernet Communication Error
- 149 Example – Amplifier Error
- 150 Example: A Simple Adding Function
- 150 Example: Variable, and an Important Note about Creating Global Variables
- 151 Example: Working with Arrays
- 151 Example: Abstracting Axes
- 151 Example: Local Scope
- 152 Example: Recursion
- 152 REM vs. NO or ' comments
- 153 WT vs AT and coding deterministic loops
- 155 Examples:
- 156 Examples:
- 157 Valid Variable Names
- 157 Invalid Variable Names
- 157 Assigning Values to Variables:
- 157 Examples:
- 157 Assigning Variable Values to Controller Parameters
- 157 Displaying the value of variables at the terminal
- 157 Example - Using Variables for Joystick
- 159 Examples of Keywords:
- 159 Example:
- 159 Examples:
- 160 Using a Variable to Address Array Elements
- 160 Example:
- 160 Uploading and Downloading Arrays to On Board Memory
- 160 Command Summary - Automatic Data Capture
- 161 Data Types for Recording:
- 161 Operand Summary - Automatic Data Capture
- 161 Example - Recording into An Array
- 163 Example
- 163 Example
- 165 Specifying the Port for Messages:
- 165 Formatting Messages
- 165 Using the MG Command to Configure Terminals
- 165 Summary of Message Functions
- 166 Example - Printing a Variable and an Array element
- 166 Using the PF Command to Format Response from Interrogation Commands
- 167 Example
- 167 Adding Leading Zeros from Response to Interrogation Commands
- 167 Local Formatting of Response of Interrogation Commands
- 168 Local Formatting of Variables
- 169 Example- Set Bit and Clear Bit
- 169 Example- Output Bit
- 169 Example- Output Port
- 169 Example - Turn on output after move
- 170 Example - Using Inputs to control program flow
- 170 Example - Start Motion on Switch
- 171 Example - Input Interrupt
- 171 Jumping back to main program with #ININT
- 171 Example - Position Follower (Point-to-Point)
- 172 Example - Position Follower (Continuous Move)
- 172 Example – Low Pass Digital Filter for the Analog inputs
- 178 Example:
- 180 Amp Enable
- 180 Error Output
- 181 General Abort
- 181 Selective Abort
- 181 ELO (Electronic Lock Out)
- 181 Forward Limit Switch
- 181 Reverse Limit Switch
- 181 Example:
- 182 Conditions for proper operation of Encoder Failure detection
- 182 Example:
- 182 Using Encoder Failure to detect a hard stop or stalled motor
- 183 Example:
- 183 Examples:
- 183 Example:
- 184 Limit Switch Example:
- 186 Under Voltage
- 186 Under Current
- 187 Position Error
- 187 Invalid Firmware
- 187 Self Test
- 192 Voltage Drive
- 193 Current Drive
- 193 Velocity Loop
- 198 Motor
- 198 Amp
- 198 DAC
- 198 Encoder
- 198 ZOH
- 198 Compensation Filter
- 200 Equivalent Filter Form - DMC-41x3
- 205 BOX4, BOX8
- 205 DIN – DIN Rail Mounting
- 205 12V – Power Controller with 12VDC
- 205 -16 bit – 16 bit Analog Inputs
- 205 4-20mA – 4-20mA analog inputs
- 206 LSNK – 25mA Sinking Outputs
- 206 LSRC – 25mA Sourcing Outputs
- 206 HSRC – 500mA Sourcing Outputs
- 206 TRES – Encoder Termination Resistors
- 206 ISCNTL – Isolate Controller Power
- 207 RS-422 – Auxiliary Serial Port Serial Communication
- 207 RS-422-Auxiliary Port
- 207 BiSS and SSI – BiSS and SSI Absolute Encoder Interface
- 208 ISAMP – Isolation of power between each AMP amplifier
- 208 SR90 – SR-49000 Shunt Regulator Option
- 208 100mA – 100mA Maximum Current output for AMP-43140
- 208 SSR – Solid State Relay Option for AMP-43140
- 213 Baud Rate Jumper Settings
- 229 AG command:
- 229 AU and AW commands:
- 238 AG command:
- 238 AU and AW commands:
- 244 AG command:
- 244 AU command: