Skip to content

Connecting to AG-UC2 by Newport in Python

Instrument Card

The AG-UC2 Agilis™ Controller provides USB computer control for two Agilis axes. The AG-UC2 controller features two sets of push buttons for each Agilis axis; one set for step size settings, and the other set for precise low speed adjustments and fast coarse motion. Power is supplied through the USB port and if not available, the USB-CH power supply can independently power the Agilis controller. USB hubs may also be used for power and communication, but must provide the required 5 V supply, e.g. must feature an external power supply.

AG-UC2

Device Specification: here

Manufacturer card: NEWPORT

NEWPORT

Newport provides a wide range of photonics technology and products designed to enhance the capabilities and productivity of our customers’ applications.

  • Headquarters: Irvine, California, United States
  • Yearly Revenue (millions, USD): 3500
  • Vendor Website: here

Demo: Send commands to a Polulu stepper motor driver

Connect to the AG-UC2 in Python

PROTOCOLS > SCPI

from instrumentkit import SerialInstrument
# Define the AG-UC2 Motor Controller class
class AGUC2MotorController(SerialInstrument):
# Define the instrument-specific properties
baudrate = 9600
timeout = 1
# Define the instrument-specific commands
def move_forward(self, speed):
self.send_command(f"FORWARD {speed}")
def move_backward(self, speed):
self.send_command(f"BACKWARD {speed}")
def stop(self):
self.send_command("STOP")
# Create an instance of the AGUC2MotorController class
motor_controller = AGUC2MotorController("COM1")
# Connect to the motor controller
motor_controller.connect()
# Move the motor forward at speed 50
motor_controller.move_forward(50)
# Wait for 2 seconds
time.sleep(2)
# Stop the motor
motor_controller.stop()
# Disconnect from the motor controller
motor_controller.disconnect()

In this example, we define a custom AGUC2MotorController class that inherits from SerialInstrument provided by Instrumentkit. We set the baudrate and timeout properties specific to the AG-UC2 Motor Controller.

We also define three instrument-specific commands: move_forward, move_backward, and stop. These commands send the appropriate commands to the motor controller via the send_command method.

We then create an instance of the AGUC2MotorController class, specifying the serial port to which the motor controller is connected. We connect to the motor controller using the connect method.

We can then use the defined commands to control the motor. In this example, we move the motor forward at speed 50 for 2 seconds, and then stop the motor.

Finally, we disconnect from the motor controller using the disconnect method.