minute read

Configuration

You are reading our Automation1 API documentation for the Python™ programming language.

The Basics

In the Python API, Configuration lets you change various aspects of the controller behavior. These changes do not have an effect until the next controller reset.

Aerotech recommends that you use Machine Setup in Studio to configure your controller. See the Configure Workspace page.

You can configure the following items for your Automation1 controller through the Python API:

  • 1D Calibration
  • 2D Calibration
  • Galvo 2D Calibration
  • Galvo Power Correction
  • Parameters

How to Use

You can access all the configuration items through the Controller.configuration property. Each configuration item has a corresponding property that has get_configuration and set_configuration methods.

You can get a configuration item, inspect it, modify it, and set it. If a configuration item has never been set, the get_configuration method will raise an exception. Refer to the example that follows.

Copy
calibration_1d_file = controller.configuration.calibration_1d_file.get_configuration()
calibration_2d_file = controller.configuration.calibration_2d_file.get_configuration()
configured_parameters = controller.configuration.parameters.get_configuration()

controller.configuration.calibration_1d_file.set_configuration(file_1d)
controller.configuration.calibration_2d_file.set_configuration(file_2d)
controller.configuration.parameters.set_configuration(parameters)

Configured Parameters

Controller parameters dictate how the controller behaves. They are categorized into axis, task, and system categories. Refer to the example that follows.

Copy
configured_parameters.axes[axis]
configured_parameters.tasks[task]
configured_parameters.system

Axis controller parameters depend on the electrical and mechanical devices that make up an axis. They configure things like units, axis names, and jog speeds.

Task controller parameters configure things like task-based coordinated motion.

System controller parameters configure things like memory allocation and communication.

See The Three Controller Categories: Axis, Task, and System for more information.

Controller Parameters That You Can Adjust at Runtime

Typically, it is not necessary for you to change the controller parameters that are already configured. The parameters that Machine Setup configures for you are almost always the best ones to use.

The changes that you make to Active Parameters have an effect immediately, but they are not permanent. This occurs because the values that you specify for these parameters are erased after you reset the controller. To permanently save your changes to the controller parameters, use the ConfiguredParameters class. See the example program in the Example Code section for configured parameters.

Controller Parameters That You Cannot Adjust at Runtime

There are some controller parameters that you cannot change at runtime. You must change them by using the ConfiguredParameters class. Then reset the controller for these changes to have an effect. See the example program in the Example Code section for configured parameters.

Controller Parameter Data Types

Controller parameters have different data types. They are as follows:

  • 32-bit integers,
  • single-precision floating-point numbers,
  • double-precision floating-point numbers,
  • strings.

In the Python API, these data types are represented as Numeric parameters and String parameters. Numeric parameter values are floats in Python. String parameter values are strings in Python.

Example Code

This example program shows you how to do the operations that follow:

  • Get the currently configured parameters from your controller.
  • Change the values of configured parameters.
  • Set the configured parameters on your controller.
Copy
import automation1 as a1

controller = a1.Controller.connect()

# Get the current configured controller parameters. This will raise an exception if the parameters are not configured.
configured_parameters = controller.configuration.parameters.get_configuration()

# Modify the X axis parameters.
configured_parameters.axes["X"].motion.maxjogspeed.value = 1.0
configured_parameters.axes["X"][AxisParameterId.DefaultAxisSpeed].value = 2.5
configured_parameters.axes["X"]["DefaultAxisRampRate"].value = 1.2

# Set the modified controller parameters that you want to use on the next controller reset.
controller.configuration.parameters.set_configuration(configured_parameters)

Configured Program Automation

In the Python API, Configured Program Automation gives you a way to:

  • Configure compiled AeroScript programs to load or run automatically on a task when the controller starts.

  • Configure AeroScript source files to be included automatically when compiling other AeroScript programs and libraries.

  • Configure AeroScript libraries to be loaded and automatically imported when compiling other AeroScript programs and libraries.

Configured Program Automation in the PythonAPI uses the ConfiguredProgramAutomation class. You can construct a new instance of this class, or you can use the Controller.Configuration.program_automation.get_configuration() method to get an instance of this class that has the current program automation configuration of the controller.

To configure an AeroScript program to load or run on a task automatically when the controller starts, use the ConfiguredProgramAutomation.compiled_programs.add() method. A compiled program must be loaded or run on a task. One task cannot load or run more than one compiled program at a time.

To configure an AeroScript source file to be included automatically during AeroScript compilation, use the ConfiguredProgramAutomation.program_source_files.add() method. If you include an AeroScript source file, you will expose all preprocessor directives defined in the source file to the program being compiled. For more information, see the Preprocessor page.

To configure a compiled AeroScript library to be loaded onto the controller, use the ConfiguredProgramAutomation.compiled_libraries.add() method. When a compiled AeroScript library is loaded onto the controller, it can be imported dynamically. For more information, see Libraries. When you create the ConfiguredProgramAutomation.CompiledLibrary instance and shouldAutoImport is set to true, the compiled library will import automatically during AeroScript compilation.

Example Code

This example program shows you how to do the operations that follow:

  • Get the currently configured program automation from your controller.
  • Add new compiled programs, source files, and compiled libraries.
  • Set the configured program automation on your controller.
Copy
# Get the current configured program automation from the controller. This will raise an exception if Program Automation is not configured.
configured_program_automation = controller.configuration.program_automation.get_configuration()

# NOTE: The following code modifies the currently configured program automation. If you want to start from scratch, create a new ConfiguredProgramAutomation instance.

# Add a compiled program to automatically run on task 2 whenever the controller starts.
configured_program_automation.compiled_programs.add(2, “/compiledprogram.a1exe”, True)

# Add a program source file to automatically include during AeroScript compilation.
configured_program_automation.program_source_files.add("/sourcefile.ascript")

# Add a compiled library that will be automatically imported during AeroScript compilation.
configured_program_automation.compiled_libraries.add("/compiledlibrary.a1lib", True)

# Set the configuration on the controller.
controller.configuration.program_automation.set_configuration(configured_program_automation)

Thread Safety

The threading library is the only multithreading library that is officially supported by the Automation1 Python API.

The Controller.configuration property is not thread safe. Only one thread at a time can access this property. If it is necessary for two or more threads to access or modify this property, you must use locks to limit the access.