README

Setup and usage notes for the PWI4 helper ZIP package.

PWI4 Connect, Enable and Home for NINA

Version: 2026-05-26.1

README.txt

PWI4 Connect, Enable and Home for NINA
======================================

Version: 2026-05-26.1

This ZIP contains:

- pwi4_connect_enable_home.bat
  Use this file in NINA when PWI4 should connect, enable both axes and start homing.

- pwi4_connect_enable_no_home.bat
  Use this file in NINA when PWI4 should connect and enable both axes, but not start homing.

- pwi4_connect_enable_home.ps1
  PowerShell script used by the batch files.

- pwi4_connect_enable_advanced_example.bat
  Example batch for a PWI4 API running on another computer or another port.
  Edit PWI4_BASE_URL inside the file before using it.

Quick start:

1. Extract all files into one local folder on the Windows computer that runs NINA and PWI4.
2. In NINA Advanced Sequencer, add an External Script instruction near the beginning of the sequence.
3. Select pwi4_connect_enable_home.bat or pwi4_connect_enable_no_home.bat.
4. Place the instruction before NINA steps that depend on the mount being ready.

If PWI4 already reports mount.is_connected=true and both axes are enabled, the script exits intentionally and does not start homing again. If the mount is connected but an axis is not enabled, or if the expected axis status fields are missing, the script runs the axis enable recovery sequence and records the PWI4 responses in the diagnostic log.

Requirements:

- Windows
- NINA
- PlaneWave PWI4 running or starting
- PWI4 API reachable at http://localhost:8220 before TimeoutSeconds expires
- PowerShell available

Safety:

A real run can move the mount. Confirm that the telescope, cabling, roof or dome and nearby equipment are clear before running the sequence.

Test without movement:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\pwi4_connect_enable_home.ps1" -DryRun

Diagnostic log:

Each run appends a new run section to pwi4_connect_enable_home.log next to the PowerShell script and also writes a timestamped per-run copy under the logs folder. The batch files additionally append to pwi4_connect_enable_home_launcher.log so it is visible whether NINA started the batch and what PowerShell exit code came back.

After a failed run, keep these files for analysis:

- pwi4_connect_enable_home.log
- newest file in the logs folder
- pwi4_connect_enable_home_launcher.log

Advanced examples:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\pwi4_connect_enable_home.ps1" -SkipHome
powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\pwi4_connect_enable_home.ps1" -BaseUrl "http://192.168.1.20:8220"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\pwi4_connect_enable_home.ps1" -TimeoutSeconds 180
powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\pwi4_connect_enable_home.ps1" -AxisTimeoutSeconds 180 -AxisRetryCount 2

Status flow:

wait for PWI4 API -> not connected -> connect -> enable RA/Azimuth axis -> enable DEC/Altitude axis -> optional home -> done

At startup, the script waits up to TimeoutSeconds for http://localhost:8220/status to become reachable. This covers cases where NINA starts the external script while PWI4 is still launching its HTTP API. Temporary /status errors during later wait phases are logged as warnings and retried until the relevant timeout expires.

If RA/Azimuth or DEC/Altitude does not become enabled, the script waits up to AxisTimeoutSeconds, disconnects, reconnects, waits briefly and repeats the complete RA/DEC enable sequence. The default is three total attempts: the first attempt plus two reconnect retries. If the axis still does not become enabled after the configured retry count, the script stops before homing. The log then shows which axis did not reach the enabled state.

Website:

https://www.jostjahn.de/amrum-software/PWI4/