From 0eb2d1f1b5b65075a839d29819a6f6a81a52c929 Mon Sep 17 00:00:00 2001 From: Emard Date: Mon, 13 Oct 2025 20:12:53 +0200 Subject: [PATCH 01/11] set long goto period --- synscan/motors.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/synscan/motors.py b/synscan/motors.py index 44134ae..83c0004 100644 --- a/synscan/motors.py +++ b/synscan/motors.py @@ -305,6 +305,11 @@ def axis_set_goto_targetCounts(self,axis,targetCounts): response=self._send_cmd('S',axis,targetCounts+0x800000) # SetGotoTarget return response + def axis_set_long_goto_step_period(self,axis,stepPeriod): + logging.info(f'AXIS{axis}: Setting long goto step period to {stepPeriod}') + response=self._send_cmd('T',axis,stepPeriod) # long goto step period + return response + def axis_set_goto_targetIncrementCounts(self,axis,targetCounts): #NOT IN USE. HAVE TO BE TESTED!! '''GoTo Target increment in StepsCounts. Motors has to be stopped''' From 31d92d614e2a2b3464c0c7dbe033387e242cd264 Mon Sep 17 00:00:00 2001 From: Emard Date: Mon, 13 Oct 2025 20:14:46 +0200 Subject: [PATCH 02/11] fix typos in comments --- synscan/motors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synscan/motors.py b/synscan/motors.py index 83c0004..2593ab9 100644 --- a/synscan/motors.py +++ b/synscan/motors.py @@ -155,7 +155,7 @@ def get_parameters(self): Some of this parameters are needed for all calculations so they have to be available to the rest of the code - Parameters are stored in a dict with te following keys: + Parameters are stored in a dict with the following keys: * countsPerRevolution * TimerInterruptFreq @@ -320,7 +320,7 @@ def axis_set_goto_targetIncrementCounts(self,axis,targetCounts): #Position values are offseting by 0x800000 response=self._send_cmd('H',axis,targetCounts+0x800000) # SetGotoTargetIncrement #Set Brake Point Increment - response=self._send_cmd('M',axis,0x000DAC) # SetBreakPointIncrement + response=self._send_cmd('M',axis,0x000DAC) # SetBrakePointIncrement return response def axis_wait2stop(self,axis): From daa2aaf516193dee65ad041c9b7bc4287d37cb58 Mon Sep 17 00:00:00 2001 From: Emard Date: Mon, 13 Oct 2025 20:18:01 +0200 Subject: [PATCH 03/11] example for slow goto --- examples/slowgoto.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/slowgoto.py diff --git a/examples/slowgoto.py b/examples/slowgoto.py new file mode 100644 index 0000000..fd24a1e --- /dev/null +++ b/examples/slowgoto.py @@ -0,0 +1,14 @@ +import synscan + +'''Goto example''' +smc=synscan.motors() +#Slow down long goto +smc.axis_set_long_goto_step_period(1, 3000); # AZ +smc.axis_set_long_goto_step_period(2, 3000); # ALT +#Synchronize mount actual position to (0,0) +smc.set_pos(0,0) +#Move forward and wait to finish +smc.goto(30,30,synchronous=True) +#Return to original position and exit without wait +smc.goto(0,0,synchronous=False) + From 337cc5aebe11234a60f99e17dc38f0db7ca8cfb1 Mon Sep 17 00:00:00 2001 From: Emard Date: Mon, 13 Oct 2025 20:30:30 +0200 Subject: [PATCH 04/11] comment on implemented command 'T' set long goto period --- synscan/motors.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/synscan/motors.py b/synscan/motors.py index 2593ab9..7268ee4 100644 --- a/synscan/motors.py +++ b/synscan/motors.py @@ -8,6 +8,7 @@ # G Set Motion Mode # I Set Step Period (T1 preset value) # S Set Goto Target +# T Set Long Goto Step Period # H SetGotoTargetIncrement # M SetBreakPointIncrement # E Set Position / SetAxisPosition @@ -37,6 +38,7 @@ # # Tested successfully on: # - SkyWatcher AZ-GTI +# - SkyWatcher Virtuoso GTi firmware 3.40.AF # - open-synscan # - Star Adventurer Mini (AXIS1 only), but goto does not stop. # From 2ac0bd58c38520409dc8e61eb6298195b81047eb Mon Sep 17 00:00:00 2001 From: Emard Date: Sun, 7 Dec 2025 16:52:02 +0100 Subject: [PATCH 05/11] comments --- synscan/comm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synscan/comm.py b/synscan/comm.py index ba28538..8da2fef 100644 --- a/synscan/comm.py +++ b/synscan/comm.py @@ -32,7 +32,7 @@ def __init__(self,udp_ip=UDP_IP,udp_port=UDP_PORT): self.lock= threading.Lock() def cmd(self,cmd,timeout_in_seconds=2): - '''Low level send command function ''' + ''' Low level send command function ''' with self.lock: self._sock.sendto(cmd,(self.udp_ip,self.udp_port)) ready = select.select([self._sock], [], [], timeout_in_seconds) @@ -60,7 +60,7 @@ def __init__(self,serial_dev): self.commOK=False def cmd(self,cmd,timeout_in_seconds=2): - '''Low level send command function ''' + ''' Low level send command function ''' with self.lock: self.serial.write(cmd) response = self.serial.readline() From 72deaa1cc24c69feeab6b1dba813c53fc5dedf8e Mon Sep 17 00:00:00 2001 From: Emard Date: Sun, 7 Dec 2025 16:53:22 +0100 Subject: [PATCH 06/11] logging compatibility --- logging.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 logging.py diff --git a/logging.py b/logging.py new file mode 100644 index 0000000..e435498 --- /dev/null +++ b/logging.py @@ -0,0 +1,14 @@ +# micropython compatibility replacement +# for logging + +def info(x): + return + +def debug(x): + return + +def warning(x): + return + +def basicConfig(format,level): + return From cd19ecc94b01d2dec9d430979538279bb4161352 Mon Sep 17 00:00:00 2001 From: Emard Date: Sun, 7 Dec 2025 17:39:59 +0100 Subject: [PATCH 07/11] use run() --- examples/one_axis_variablespeedtrack.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/one_axis_variablespeedtrack.py b/examples/one_axis_variablespeedtrack.py index 488b1b6..e73edb2 100644 --- a/examples/one_axis_variablespeedtrack.py +++ b/examples/one_axis_variablespeedtrack.py @@ -3,24 +3,26 @@ '''One axis variable speed track example''' smc=synscan.motors() -AXIS=2 -#FORWARD -#RAMP UP -for speed in range(0,50,1): +def run(): + AXIS=2 + #FORWARD + #RAMP UP + for speed in range(0,50,1): time.sleep(.1) smc.axis_track(AXIS,speed/10) -#RAMP DOWN -for speed in range(50,0,-1): + #RAMP DOWN + for speed in range(50,0,-1): time.sleep(.1) smc.axis_track(AXIS,speed/10) -#BACKWARDS -#RAMP UP -for speed in range(0,50,1): + #BACKWARDS + #RAMP UP + for speed in range(0,50,1): time.sleep(.1) smc.axis_track(AXIS,-speed/10) -#RAMP DOWN -for speed in range(50,0,-1): + #RAMP DOWN + for speed in range(50,0,-1): time.sleep(.1) smc.axis_track(AXIS,-speed/10) +run() From a55eb9098ac705da8a2af2feb1b8849be7b28215 Mon Sep 17 00:00:00 2001 From: Emard Date: Sun, 7 Dec 2025 17:40:23 +0100 Subject: [PATCH 08/11] micropython compatible --- synscan/comm.py | 38 +++++++++++++++++++++++++++----------- synscan/motors.py | 15 ++++++++++----- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/synscan/comm.py b/synscan/comm.py index 8da2fef..16b28ff 100644 --- a/synscan/comm.py +++ b/synscan/comm.py @@ -3,19 +3,20 @@ # pysynscan # Copyright (c) July 2020 Nacho Mas - import socket import logging import os import select -import threading - - - -UDP_IP = os.getenv("SYNSCAN_UDP_IP","192.168.4.1") -UDP_PORT = int(os.getenv("SYNSCAN_UDP_PORT",11880)) -LOGGING_LEVEL=os.getenv("SYNSCAN_LOGGING_LEVEL",logging.INFO) +try: + from os import getenv + UDP_IP = getenv("SYNSCAN_UDP_IP","192.168.4.1") + UDP_PORT = int(getenv("SYNSCAN_UDP_PORT",11880)) + LOGGING_LEVEL=getenv("SYNSCAN_LOGGING_LEVEL",logging.INFO) +except: + UDP_IP = None + UDP_PORT = 11880 + LOGGING_LEVEL=0 class commUDP: ''' @@ -29,7 +30,11 @@ def __init__(self,udp_ip=UDP_IP,udp_port=UDP_PORT): self.udp_ip=udp_ip self.udp_port=udp_port self.commOK=False - self.lock= threading.Lock() + try: + import threading + self.lock= threading.Lock() + except: + self.lock=None def cmd(self,cmd,timeout_in_seconds=2): ''' Low level send command function ''' @@ -56,7 +61,11 @@ def __init__(self,serial_dev): import serial ''' Init the serial port ''' self.serial = serial.Serial(serial_dev, 9600, timeout=.02) - self.lock = threading.Lock() + try: + import threading + self.lock= threading.Lock() + except: + self.lock=None self.commOK=False def cmd(self,cmd,timeout_in_seconds=2): @@ -93,7 +102,14 @@ def __init__(self,udp_ip=UDP_IP,udp_port=UDP_PORT,serial_dev=None): if serial_dev: self.comm = commSerial(serial_dev) else: - self.comm = commUDP(udp_ip,udp_port) + if udp_ip: + self.comm = commUDP(udp_ip,udp_port) + else: # "syn" is local python interface with syn.cmd() + # esp32blesynscan/micropython/ + # rename synscan.py -> syn.py + # mpremote cp synscan.py :/syn.py + import syn + self.comm = syn def _send_raw_cmd(self,cmd,timeout_in_seconds=2): return self.comm.cmd(cmd, timeout_in_seconds) diff --git a/synscan/motors.py b/synscan/motors.py index 7268ee4..6eb42c2 100644 --- a/synscan/motors.py +++ b/synscan/motors.py @@ -47,14 +47,19 @@ # https://inter-static.skywatcher.com/downloads/skywatcher_motor_controller_command_set.pdf import os -import logging from synscan.comm import comm import time +import logging -UDP_IP = os.getenv("SYNSCAN_UDP_IP","192.168.4.1") -UDP_PORT = int(os.getenv("SYNSCAN_UDP_PORT",11880)) - -LOGGING_LEVEL=os.getenv("SYNSCAN_LOGGING_LEVEL",logging.INFO) +try: + from os import getenv + UDP_IP = getenv("SYNSCAN_UDP_IP","192.168.4.1") + UDP_PORT = int(getenv("SYNSCAN_UDP_PORT",11880)) + LOGGING_LEVEL=getenv("SYNSCAN_LOGGING_LEVEL",logging.INFO) +except: + UDP_IP = None # use python interface syn.cmd() + UDP_PORT = 11880 + LOGGING_LEVEL=0 class motors(comm): ''' From f8744b12c61cde0f794e6207f0fe9f987287255e Mon Sep 17 00:00:00 2001 From: Emard Date: Sun, 7 Dec 2025 19:37:35 +0100 Subject: [PATCH 09/11] slew example (for manual/joystick movement) --- examples/slew.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 examples/slew.py diff --git a/examples/slew.py b/examples/slew.py new file mode 100755 index 0000000..5458b20 --- /dev/null +++ b/examples/slew.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import synscan +import time + +'''Goto example''' +def run(): + smc=synscan.motors() + smc._set_T1_preset(1, 3000); # AZ + smc.axis_start_motion(1) + time.sleep(1) + smc.axis_stop_motion(1) + +run() From be8cea5d077d9b4353c941a217639a449a78b7fa Mon Sep 17 00:00:00 2001 From: Emard Date: Sat, 13 Dec 2025 19:49:42 +0100 Subject: [PATCH 10/11] some goto examples --- examples/goto0 | 16 ++++++++++++++++ examples/goto1 | 17 +++++++++++++++++ examples/goto180 | 20 ++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 examples/goto0 create mode 100755 examples/goto1 create mode 100755 examples/goto180 diff --git a/examples/goto0 b/examples/goto0 new file mode 100755 index 0000000..ecf2e55 --- /dev/null +++ b/examples/goto0 @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import synscan + +'''Goto example''' +def run(): + smc=synscan.motors() + #Slow down long goto + smc.axis_set_long_goto_step_period(1, 3000); # AZ + smc.axis_set_long_goto_step_period(2, 3000); # ALT + #move to 2° lower left before final point + #for 0,0 AZ should be 2° less, ALT should be 2° less + smc.goto(-2,-2,synchronous=True) + #Return to original position and exit without wait + smc.goto(0,0,synchronous=False) + +run() diff --git a/examples/goto1 b/examples/goto1 new file mode 100755 index 0000000..6732a51 --- /dev/null +++ b/examples/goto1 @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import synscan + +'''Goto example''' +def run(): + smc=synscan.motors() + #Slow down long goto + smc.axis_set_long_goto_step_period(1, 3000); # AZ + smc.axis_set_long_goto_step_period(2, 3000); # ALT + #Move forward and wait to finish + smc.goto(-1,-1,synchronous=True) + print(smc.axis_get_pos(1),smc.axis_get_pos(2)) + #Return to original position and exit without wait + smc.goto(0,0,synchronous=False) + print(smc.axis_get_pos(1),smc.axis_get_pos(2)) + +run() diff --git a/examples/goto180 b/examples/goto180 new file mode 100755 index 0000000..c280ac7 --- /dev/null +++ b/examples/goto180 @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import synscan + +'''Goto example''' +def run(): + smc=synscan.motors() + #Slow down long goto + smc.axis_set_long_goto_step_period(1, 3000); # AZ + smc.axis_set_long_goto_step_period(2, 3000); # ALT + #If counts per revolution are correct, after both axis turn 180 + #the telescope should point to same target as 0,0 + #smc.goto(180,180,synchronous=True) + #move to 2° lower left before final point + #for 180,180 AZ should be 2° less, ALT should be 2° more + smc.goto(177,178,synchronous=True) + #If counts per revolution are not correct + #experiment with this until telescope points to 0,0 + smc.goto(179+17/60,175+46/60,synchronous=False) + +run() From cb5ace87b136304325b78fd01ebaaeae39f88614 Mon Sep 17 00:00:00 2001 From: Emard Date: Sat, 13 Dec 2025 19:50:08 +0100 Subject: [PATCH 11/11] symlink to avoid installation --- examples/synscan | 1 + 1 file changed, 1 insertion(+) create mode 120000 examples/synscan diff --git a/examples/synscan b/examples/synscan new file mode 120000 index 0000000..840bda0 --- /dev/null +++ b/examples/synscan @@ -0,0 +1 @@ +../synscan \ No newline at end of file