Structure of a Program
The example that follows is a simple program written in the AeroScript programming language. Source files for AeroScript programs and libraries must use the UTF-8 encoding.
#define NUM_POS 2
program
var $positions[NUM_POS] as real
// Enable and home axes
Enable([X, Y, Z])
Home([X, Y, Z])
// Start free-running axis Z
MoveFreerun(Z, 100)
// Move X and Y to positions 10 and 20, respectively
MoveRapid([X, Y], [10, 20])
// Perform G-code motion on axes X and Y
G1 X20 Y10 F100
G1 X30 Y5
G1 X45 Y25 F35
// Dwell for 0.5 seconds using G-code
G4 P0.5
// Call a function to get axis positions, perform a trigonometric
// function, and then multiply the result by 1000
$positions[0] = Sin(MyFunc(X)) * 1000.0
$positions[1] = Cos(MyFunc(Y)) * 1000.0
end
function MyFunc($myAxis as axis) as real
return StatusGetAxisItem($myAxis, AxisStatusItem.PositionCommand)
end
This program example has the elements that follow:
-
Preprocessor (e.g., #include "MyDefines.ascript" and #define NUM_POS 2)
-
User-Defined Variables (e.g., $positions[])
-
Comments and Whitespace (e.g., // Set up axes)
-
Aerotech Standard Library API Functions (e.g., Enable(), Home(), Sin(), Cos(), StatusGetAxisItem())
-
G-Code (RS-274) Support (e.g., G4, G1)
-
Operators and Intrinsic Functions (e.g., =, *)
-
User-Defined Functions User-defined functions (e.g., MyFunc())
Next Topic: Comments and Whitespace