All Articles / Application Notes

Incorporating Sensor Feedback

Last updated on Aug. 17, 2021

While Zaber's devices work best in high precision positioning applications, many systems will require stages to move in relation to output from a sensor. You can incorporate sensor feedback into your system with a Zaber device in a few ways.

One way to have your stage respond to feedback is to continuously send commands to move at a set speed.

This command moves the stage at a speed based on the data value you send; the data value can have positive or negative values which will move the stage either forward or in reverse. The stage will continue to move at that speed and direction until it receives another command. You can use the output of your sensor to vary the data value. You can update this speed with a frequency of around 50 Hz - 100 Hz.

An example set-up could be a force sensor on the tip of one of our X-NA08A25 actuators. You can set a target force for it to apply then create a script with a negative feedback loop.

While the measured force is lower than the target, the data value you send to the move vel command will be positive. As the measured force approaches the target, the data value will decrease, until it's met when you would send a data value of 0. If the measured force is higher than the target, the data sent would be negative and the actuator would retract.

X-MCC2 two-axis controller
Figure: X-MCC2 two-axis controller.

With the X-MCC2 two-axis controller you have access to digital and analog inputs so that you can directly connect the sensors to the controller. You could then either read those values in over your serial connection and use them to send your commands, or you could set up triggers to use the feedback without even having a computer connection.

If you have any questions or would like to learn more about triggering, please contact us to speak with a technical support engineer.

See below for an example script in Python written using the Zaber Motion Library to use the analog input for proportional speed feedback:

    # Example Python script for using feedback with analog input.
    # This example will move an axis to try to match the analog input value to a specified one.
    # It assumes that positive movement will increase the analog input value,
    # and negative movement will decrease it. After a set period of time it will stop.
    import time
    from zaber_motion import Library, Units   
    from zaber_motion.ascii import Connection
    Library.enable_device_db_store()
    with Connection.open_serial_port("COM3") as connection:
      device_list = connection.detect_devices()
      device = device_list[0]
      axis = device.get_axis(1)
      target_force = 5  # target analog input voltage
      start_speed = 0.5  # starting speed, in mm/s
      speed_scale = 0.1  # speed scaling, in mm/s per volt
      period = 60  # time to move, in seconds
      # start extending the actuator
      axis.move_velocity(start_speed, Units.VELOCITY_MILLIMETRES_PER_SECOND)
      # start a while loop to monitor the analog input
      start_time = time.time()
      while time.time() < start_time + period:
          current_force = device.io.get_analog_input(1)  # read analog input 1
          # set a new speed based on the difference in voltages
          new_speed = (target_force - current_force) * speed_scale
          # move at the new speed
          axis.move_velocity(new_speed, Units.VELOCITY_MILLIMETRES_PER_SECOND)
      axis.stop()