Coder API

May 2, 2026 ยท View on GitHub

The Coder tab lets you run simple Python scripts that control the dip coater. Scripts are trusted Python code. Only run scripts you wrote yourself or scripts you have reviewed.

Use this for repeatable routines such as:

  • lower a sample or substrate into a dip coating solution
  • wait for a fixed time
  • withdraw a sample or substrate at a controlled speed
  • wait for drying
  • repeat the sequence

!!! warning Test new scripts with the dummy driver first. Then test with small distances and low speeds before using real coating hardware.

Stopping a Script

Press STOP code to request cancellation and disable the motor. The app stops the script between Coder API calls such as move_down, move_up, sleep, and move_to_position.

STOP code cannot interrupt arbitrary Python while it is busy inside a loop that does not call the Coder API. Keep scripts simple and use short Coder API steps.

Basic Script

This script lowers the moving assembly by 10 mm, waits 5 seconds, then raises it by 10 mm. The examples use keyword arguments so the distance, speed, and acceleration units stay clear.

self.enable_motor()

self.move_down(distance_mm=10, speed_mm_s=5)
self.sleep(seconds=5)
self.move_up(distance_mm=10, speed_mm_s=2)

self.disable_motor()

Available Commands

Enable the Motor

self.enable_motor()

This arms the motor so it can move.

Disable the Motor

self.disable_motor()

This disables the motor. Use this at the end of a script.

Move Down

self.move_down(distance_mm, speed_mm_s, acceleration_mm_s2=None)

Examples:

self.move_down(distance_mm=10, speed_mm_s=5)
self.move_down(distance_mm=10, speed_mm_s=5, acceleration_mm_s2=10)

The first example lowers the moving assembly by 10 mm at 5 mm/s. The second also sets acceleration to 10 mm/s^2.

Move Up

self.move_up(distance_mm, speed_mm_s, acceleration_mm_s2=None)

Examples:

self.move_up(distance_mm=10, speed_mm_s=5)
self.move_up(distance_mm=10, speed_mm_s=5, acceleration_mm_s2=10)

Home the Motor

self.home_motor()

If you need to choose a direction explicitly:

self.home_motor(home_up=True)
self.home_motor(home_up=False)

Homing is required before moving to an absolute position.

Move to an Absolute Position

self.move_to_position(position_mm, speed_mm_s=None, acceleration_mm_s2=None)

Examples:

self.move_to_position(position_mm=10)
self.move_to_position(position_mm=10, speed_mm_s=5)
self.move_to_position(position_mm=10, speed_mm_s=5, acceleration_mm_s2=10)

Wait

self.sleep(seconds)

Example:

self.sleep(seconds=5)

Example: Simple Dip Cycle

self.enable_motor()

# Move into the liquid.
self.move_down(distance_mm=20, speed_mm_s=4)

# Wait while submerged.
self.sleep(seconds=10)

# Withdraw slowly.
self.move_up(distance_mm=20, speed_mm_s=1)

self.disable_motor()

Example: Repeated Cycles

self.enable_motor()

for cycle in range(3):
    self.move_down(distance_mm=15, speed_mm_s=4)
    self.sleep(seconds=5)
    self.move_up(distance_mm=15, speed_mm_s=2)
    self.sleep(seconds=10)

self.disable_motor()

Loading Code From a File

In the Coder tab:

  1. Type the path to a .py file.
  2. Press LOAD code from file.
  3. Check that the code appears in the editor.
  4. Press RUN code.

The path must point to an existing Python file.