Skip to content

Commit

Permalink
Merge pull request #5 from SiLab-Bonn/workflow
Browse files Browse the repository at this point in the history
Workflow
  • Loading branch information
rpartzsch authored Oct 25, 2024
2 parents 39437a2 + 3b2287c commit f42b016
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 22 deletions.
25 changes: 25 additions & 0 deletions .github/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.1
with:
extra_args: flake8 --all-files

installation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install dependencies
run: |
pip install -e .
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Motor stage UI
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

Offers both a terminal and graphical user interface for the Mercury motor controller.
Offers both a terminal and graphical user interface for the Mercury motor controller.
Motor stages can be arranged in daisy chains.

## Installation
Expand All @@ -14,8 +14,8 @@ pip install -e .

## Usage

Configure your specific stage setup in ```motor_stage_ui/configuration.yaml```.
Check the baud rate, address, USB connection, and any potential logic active low settings for the individual motor stage controller.
Configure your specific stage setup in ```motor_stage_ui/configuration.yaml```.
Check the baud rate, address, USB connection, and any potential logic active low settings for the individual motor stage controller.
Set a motor stage name (e.g., ```x_axis```), type, and step size according to the hardware specifications of the motor stage.

Start the motor stage GUI:
Expand All @@ -26,8 +26,8 @@ or control the stage through the terminal:
```bash
motor COMMAND arguments
```
The ```COMMAND``` can be ```move``` or ```stop```, and the arguments consist of a move value and the motor stage name.
The motor stage UI accepts move values in various units (mm, cm, deg, rad, etc.) and converts them automatically.
The ```COMMAND``` can be ```move``` or ```stop```, and the arguments consist of a move value and the motor stage name.
The motor stage UI accepts move values in various units (mm, cm, deg, rad, etc.) and converts them automatically.

The motor stage velocity is set during the initialization step. To avoid unwanted behavior (especially if the default motor speed is too slow), ensure to initialize the motor stage even when using the terminal.

Expand All @@ -36,6 +36,7 @@ motor init MOTORNAME
```

### Configuration
The step size of a specific stage is given in um for translation stages and deg for rotation stages and can be obtained from the 'Design resolution' in e.g. [PI precision position and motion control](https://www.pi-usa.us/fileadmin/user_upload/physik_instrumente/files/CAT/PI-CAT132E-Precision-Positioning-and-Motion-Control-Web.pdf).

| Configuration | Description | Type |
|-----------|-------------|------|
Expand All @@ -51,9 +52,9 @@ motor init MOTORNAME
| Terminal Command | GUI Command | Description | First Argument | Second Argument |
|---------|-------------|-----------|-----------|-----------|
| `init` | `Init.` | Initialize motor stage. Powering and resetting the motor. Set motor move speed in the PIStageInterface.py function.| motor_name (str): name of the motorstage | - |
| `move` | `Input rel.` | Moves the motor stage a relative amount, positive values for ahead, negatives for back. Accepts string inputs with units (4cm, -2mm...). If no unit is given, the motor moves the default unit amount. | motor_name (str): name of the motorstage | a (str): Move amount |
| `move` | `Input rel.` | Moves the motor stage a relative amount, positive values for ahead, negatives for back. Accepts string inputs with units (4cm, -2mm...). If no unit is given, the motor moves the default unit amount. | motor_name (str): name of the motorstage | a (str): Move amount |
| `moveto` | `input abs.` | Moves the motor stage to a absolut position. Accepts string inputs with units (4cm, -2mm...). If no unit is given, the motor moves to the default position unit. | motor_name (str): name of the motorstage |a (str): Move to position |
| `pos` | - | Logs the current position of the motor stage.| motor_name (str): name of the motorstage | -|
| `stop` | `Stop` | Immediately stops all movement of the stage | motor_name (str): name of the motorstage | - |
| `sethome` | `Set Zero` | Sets the current position of the stage as new origin | motor_name (str): name of the motorstage | - |
| `gohome` | `MV. Zero` | Goes to origin of the stage | motor_name (str): name of the motorstage | - |
| `gohome` | `MV. Zero` | Goes to origin of the stage | motor_name (str): name of the motorstage | - |
6 changes: 3 additions & 3 deletions motor_stage_ui/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# name:
# stage: define stage typus 'rotation', 'translation'
# address: set with dip switches
# step_size: depends on the design specifics of the hardware (stage and powering), check 'Design resolution' in e.g.:
# step_size: depends on the design specifics of the hardware (stage and powering), check 'Design resolution' in e.g.:
# https://www.pi-usa.us/fileadmin/user_upload/physik_instrumente/files/CAT/PI-CAT132E-Precision-Positioning-and-Motion-Control-Web.pdf
# set in um for translation stage and in deg for rotational stage
# M-038.DG rotational stage: step_size=0.59 urad / 34*10**(-6) deg
# M-403.6DG translation stage: step_size=0.018 um
# unit: set output unit and default input unit
# unit: set output unit and default input unit

x_axis:
stage_type: translation
Expand All @@ -33,4 +33,4 @@ rot:
step_size: 34e-06
unit: deg
port: '/dev/ttyUSB0'
baud_rate: '9600'
baud_rate: '9600'
9 changes: 6 additions & 3 deletions motor_stage_ui/motor_stage_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os

"""
GUI for the motor stage
"""
Expand All @@ -33,7 +33,8 @@ def __init__(self, config_path):
for index, motor in enumerate(self.conf):
self.motor.append(
PIStagesInterface(
port=self.conf[motor]["port"], baud_rate=self.conf[motor]["baud_rate"]
port=self.conf[motor]["port"],
baud_rate=self.conf[motor]["baud_rate"],
)
)
stage = self.conf[motor]["stage_type"]
Expand Down Expand Up @@ -65,7 +66,9 @@ def __init__(self, config_path):
self.get_position_clicked(
self.conf[list(self.conf.keys())[i]]["address"],
unit=self.conf[list(self.conf.keys())[i]]["unit"],
stage=self.conf[list(self.conf.keys())[i]]["stage_type"],
stage=self.conf[list(self.conf.keys())[i]][
"stage_type"
],
step_size=eval(
str(
self.conf[list(self.conf.keys())[i]][
Expand Down
3 changes: 2 additions & 1 deletion motor_stage_ui/motor_stage_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

"""
Terminal control UI.
Terminal control UI.
"""


@click.group()
@click.pass_context
def motor(conf):
Expand Down
9 changes: 1 addition & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@
"": ["motor_stage_ui/configuration.yaml"],
},
include_package_data=True,
install_requires=[
"Click",
"pint",
"coloredlogs",
"PyQt5",
"pyserial",
"pyyaml"
],
install_requires=["Click", "pint", "coloredlogs", "PyQt5", "pyserial", "pyyaml"],
entry_points={
"console_scripts": [
"motor = motor_stage_ui.motor_stage_terminal:motor",
Expand Down

0 comments on commit f42b016

Please sign in to comment.