befor y test

This commit is contained in:
2025-08-07 16:47:10 +02:00
parent 5fcdac4277
commit 604ee87257
136 changed files with 13834 additions and 1114 deletions

View File

@@ -1,10 +1,10 @@
{
"Number_of_cycles": 10000,
"Number_of_cycles": 1,
"Amplitude_mm": 1,
"Time_in_beam_s": 5,
"Time_out_of_beam_s": 10,
"Exposure_time": 0.0002,
"Img_Processing": 1,
"pixel_size_mu": 0.275,
"Exposure_time": 0.0001,
"Img_Processing": 0,
"pixel_size_mu": 1.1,
"long_time_interval": 50
}

View File

@@ -1,4 +1,4 @@
{"std_test_mov": [-10, 10],
"std_test_wait": [1, 5],
{"std_test_mov": [-1, 1],
"std_test_wait": [4, 4],
"backlsh_meas_mov": [10, -10, -10, 10],
"backlash_meas_wait": [1]}

BIN
Images_doku/Corrected.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
Images_doku/TimeNewCtr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
Images_doku/complete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
Images_doku/roomTemp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
Images_doku/stable_x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

66
Scripts/Test_y.py Normal file
View File

@@ -0,0 +1,66 @@
from time import sleep
from pathlib import Path
import sys
import pyads
def check_path(path_str):
try:
path = Path(path_str)
if not path.exists():
raise FileNotFoundError(f"Path does not exist: {path_str}")
print(f"Path exists: {path_str}")
except FileNotFoundError as e:
print(f"Error: {e}")
config_path = r"C:\Users\berti_r\Python_Projects\StagePerformaceDocu\Config\config.json"
check_path(config_path)
library_path = r"C:\Users\berti_r\Python_Projects\templates\motion_libs"
check_path(library_path)
sys.path.append(library_path)
measurement_mov_path = r"C:\Users\berti_r\Python_Projects\StagePerformaceDocu\Config\measurement.json"
check_path(measurement_mov_path)
import motionFunctionsLib as mfl
import time
plc = mfl.plc('5.67.222.118.1.1', 852)
plc.connect()
axis1 = mfl.axis(plc, 1)
axis4 = mfl.axis(plc, 4)
print(axis4.getCoupledGear1())
axis1.setAcceleration(10000.0)
axis1.setDeceleration(10000.0)
axis1.setVelocity(3)
axis4.setAcceleration(10000.0)
axis4.setDeceleration(10000.0)
axis4.setVelocity(3)
axis1.enableAxis()
axis4.enableAxis()
sleep(1)
print("coupling: ",axis4.getCoupledGear1())
for i in range(3):
axis4.moveRelative(0.5)
axis1.moveRelative(0.5)
sleep(5)
axis4.moveRelative(-0.5)
axis1.moveRelative(-0.5)
sleep(5)
axis1.disableAxis()
axis4.disableAxis()

View File

@@ -52,7 +52,9 @@ if not os.path.exists(workdir):
plc = mfl.plc('5.67.222.118.1.1', 852)
#TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!
plc.connect()
axis1 = mfl.axis(plc, 2)
axis2 = mfl.axis(plc, 2)
axis1 = mfl.axis(plc, 1)
axis4 = mfl.axis(plc, 4)
#insert try catch later
def get_pixel_size():
config = myu.load_object(config_path)
@@ -203,7 +205,7 @@ def aquire_avg(camera_a, nr=10):
com_y = np.average(y_array)
return com_x, com_y
def run_repeatability_series(
def run_repeatability_series_n(
motor_pv_prefix=0, ntries=100,save_images=True, run_analysis=False):
#improv
@@ -227,12 +229,12 @@ def run_repeatability_series(
#enable axis clean up later
axis1.setAcceleration(10000.0)
axis1.setDeceleration(20000.0)
axis1.setVelocity(-3)
axis1.disableAxis()
axis2.setAcceleration(10000.0)
axis2.setDeceleration(20000.0)
axis2.setVelocity(-3)
axis2.disableAxis()
sleep(1)
axis1.enableAxis()
axis2.enableAxis()
sleep(1)
#--------------------------------------load coordinates from file-----------------------
x_coordinates_json = myu.load_object(measurement_mov_path)
@@ -246,7 +248,7 @@ def run_repeatability_series(
#---------------------------------------------move------------------------------------------
#add multithreading for simultanious movement of y and x axis
for mov,wait in zip(x_coordinates, wait_x):
axis1.moveRelativeAndWait(mov)
axis2.moveRelativeAndWait(mov)
sleep(wait)
start_pos_rbv = 4 #????
meas_pos_rbv = 5 #????
@@ -287,12 +289,12 @@ def run_repeatability_series(
analyze_repeatability(savefile, pixel_size=pixel_size, units='um')
#-----------------------------------------cleanup-----------------------------------------
axis1.disableAxis()
axis2.disableAxis()
camera.stop()
del camera
def run_repeatability_series_motor_off(
def run_repeatability_series(
motor_pv_prefix=0, ntries=100, save_images=True, run_analysis=False):
# improv
ntries = init_nr_of_cycles()
@@ -315,13 +317,21 @@ def run_repeatability_series_motor_off(
# enable axis clean up later
axis1.setAcceleration(10000.0)
axis1.setDeceleration(20000.0)
axis1.setAcceleration(50.0)
axis1.setDeceleration(50.0)
axis1.setVelocity(3)
axis1.disableAxis()
sleep(1)
axis1.enableAxis()
sleep(1)
axis4.setAcceleration(50.0)
axis4.setDeceleration(50.0)
axis4.setVelocity(3)
axis4.disableAxis()
sleep(1)
axis4.enableAxis()
sleep(1)
# --------------------------------------load coordinates from file-----------------------
x_coordinates_json = myu.load_object(measurement_mov_path)
x_coordinates = x_coordinates_json.get('std_test_mov')
@@ -332,14 +342,12 @@ def run_repeatability_series_motor_off(
for i in range(ntries):
# ---------------------------------------------move------------------------------------------
# add multithreading for simultanious movement of y and x axis
axis1.enableAxis()
sleep(0.1)
for mov, wait in zip(x_coordinates, wait_x):
axis1.moveRelativeAndWait(mov)
axis1.moveRelative(mov)
axis4.moveRelative(wait)
sleep(wait)
start_pos_rbv = 4 # ????
meas_pos_rbv = 5 # ????
axis1.disableAxis()
# ---------------------------------------------capture------------------------------------------
x_array = []
y_array = []
@@ -377,7 +385,97 @@ def run_repeatability_series_motor_off(
analyze_repeatability(savefile, pixel_size=pixel_size, units='um')
# -----------------------------------------cleanup-----------------------------------------
axis1.disableAxis()
axis2.disableAxis()
camera.stop()
del camera
def run_repeatability_series_motor_off(
motor_pv_prefix=0, ntries=100, save_images=True, run_analysis=False):
# improv
ntries = init_nr_of_cycles()
print(f"started with {ntries} cycles")
if os.getenv("EPICS_CA_ADDR_LIST") is not None:
pass
else:
os.environ["EPICS_CA_ADDR_LIST"] = "129.129.181.64"
camera = ad.AD()
pixel_size = 1.1
savedir = os.path.join(workdir,
f'{get_timestr()}_repeatibility_{motor_pv_prefix}')
safe_meas_settings(savedir)
savefile = os.path.join(savedir,
f'repeatibility_{motor_pv_prefix}.dat')
os.makedirs(savedir)
camera.start()
# enable axis clean up later
axis2.setAcceleration(10000.0)
axis2.setDeceleration(20000.0)
axis2.setVelocity(3)
axis2.disableAxis()
sleep(1)
axis2.enableAxis()
sleep(1)
# --------------------------------------load coordinates from file-----------------------
x_coordinates_json = myu.load_object(measurement_mov_path)
x_coordinates = x_coordinates_json.get('std_test_mov')
wait_x_json = myu.load_object(measurement_mov_path)
wait_x = wait_x_json.get('std_test_wait')
print(wait_x)
for i in range(ntries):
# ---------------------------------------------move------------------------------------------
# add multithreading for simultanious movement of y and x axis
axis2.enableAxis()
sleep(0.1)
for mov, wait in zip(x_coordinates, wait_x):
axis2.moveRelativeAndWait(mov)
sleep(wait)
start_pos_rbv = 4 # ????
meas_pos_rbv = 5 # ????
axis2.disableAxis()
# ---------------------------------------------capture------------------------------------------
x_array = []
y_array = []
for nr_img in range(10):
sleep(0.1)
im = camera.get_image()
sleep(0.1)
if (1 == init_image_processing_yes_no()):
com_x_tmp, com_y_tmp = __process_img(im)
else:
com_x_tmp, com_y_tmp = image_center_of_mass(im, plot=False, verbose=False)
x_array.append(com_x_tmp)
y_array.append(com_y_tmp)
com_x = np.average(x_array)
com_y = np.average(y_array)
data_str = " {:6d} {:18f} {:18f} {:8.3f} {:8.3f} {:14.3f}\n".format(
i, start_pos_rbv, meas_pos_rbv, com_x, com_y, time.time())
print(data_str, end='')
# -------------------------------------------Save----------------------------------------------------
with open(savefile, 'a') as fh:
fh.write(data_str)
if save_images:
imobj = Image.fromarray(im)
imfile = os.path.join(savedir,
f'im_{i:05d}.tif')
imobj.save(imfile)
# --------------------------------------------analyse----------------------------------------------
if run_analysis:
print("")
analyze_repeatability(savefile, pixel_size=pixel_size, units='um')
# -----------------------------------------cleanup-----------------------------------------
axis2.disableAxis()
camera.stop()
del camera
def analyze_repeatability(input_file, pixel_size, units='um'):

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
0 4.000000 5.000000 33.714 5.275 1753372063.025

View File

@@ -0,0 +1 @@
{"Number_of_cycles": 10000, "Amplitude_mm": 1, "Time_in_beam_s": 5, "Time_out_of_beam_s": 10, "Exposure_time": 0.0002, "Img_Processing": 1, "pixel_size_mu": 0.275, "long_time_interval": 50}

View File

@@ -0,0 +1,11 @@
0 4.000000 5.000000 16.276 23.386 1753378737.477
1 4.000000 5.000000 16.257 23.344 1753378754.747
2 4.000000 5.000000 16.364 23.366 1753378772.020
3 4.000000 5.000000 16.314 23.425 1753378789.276
4 4.000000 5.000000 16.231 23.401 1753378806.521
5 4.000000 5.000000 16.173 23.338 1753378823.753
6 4.000000 5.000000 16.341 23.240 1753378841.013
7 4.000000 5.000000 16.310 23.298 1753378858.278
8 4.000000 5.000000 16.339 23.267 1753378875.588
9 4.000000 5.000000 16.279 23.209 1753378892.908
10 4.000000 5.000000 16.277 23.179 1753378910.184

View File

@@ -0,0 +1 @@
{"Number_of_cycles": 10000, "Amplitude_mm": 1, "Time_in_beam_s": 5, "Time_out_of_beam_s": 10, "Exposure_time": 0.0002, "Img_Processing": 1, "pixel_size_mu": 0.275, "long_time_interval": 50}

View File

@@ -0,0 +1,31 @@
0 4.000000 5.000000 53.744 91.187 1753379057.990
1 4.000000 5.000000 53.216 90.931 1753379075.976
2 4.000000 5.000000 52.466 91.616 1753379093.925
3 4.000000 5.000000 52.540 91.504 1753379111.882
4 4.000000 5.000000 52.270 91.720 1753379129.853
5 4.000000 5.000000 52.668 91.514 1753379147.850
6 4.000000 5.000000 52.292 91.371 1753379165.798
7 4.000000 5.000000 52.442 91.443 1753379183.751
8 4.000000 5.000000 52.305 91.052 1753379201.699
9 4.000000 5.000000 52.421 91.131 1753379219.633
10 4.000000 5.000000 52.438 91.194 1753379237.624
11 4.000000 5.000000 52.958 91.528 1753379255.615
12 4.000000 5.000000 52.334 91.406 1753379273.619
13 4.000000 5.000000 51.922 91.582 1753379291.567
14 4.000000 5.000000 51.047 91.542 1753379309.553
15 4.000000 5.000000 51.498 91.297 1753379327.477
16 4.000000 5.000000 51.378 91.596 1753379345.474
17 4.000000 5.000000 51.564 91.465 1753379363.434
18 4.000000 5.000000 51.582 91.547 1753379381.452
19 4.000000 5.000000 51.473 91.716 1753379399.435
20 4.000000 5.000000 51.634 91.819 1753379417.469
21 4.000000 5.000000 51.580 92.015 1753379435.452
22 4.000000 5.000000 51.199 92.092 1753379454.391
23 4.000000 5.000000 51.562 92.187 1753379472.350
24 4.000000 5.000000 50.696 92.146 1753379490.339
25 4.000000 5.000000 50.913 92.160 1753379508.307
26 4.000000 5.000000 50.815 91.828 1753379526.347
27 4.000000 5.000000 51.044 91.885 1753379544.368
28 4.000000 5.000000 50.911 91.885 1753379562.394
29 4.000000 5.000000 50.696 91.586 1753379580.395
30 4.000000 5.000000 50.437 91.585 1753379598.447

View File

@@ -0,0 +1,10 @@
0 4.000000 5.000000 nan nan 1754304852.005
1 4.000000 5.000000 nan nan 1754304872.446
2 4.000000 5.000000 nan nan 1754304892.649
3 4.000000 5.000000 nan nan 1754304913.547
4 4.000000 5.000000 nan nan 1754304931.902
5 4.000000 5.000000 nan nan 1754304949.753
6 4.000000 5.000000 nan nan 1754304968.500
7 4.000000 5.000000 nan nan 1754304987.722
8 4.000000 5.000000 nan nan 1754305007.048
9 4.000000 5.000000 nan nan 1754305026.594

View File

@@ -0,0 +1,10 @@
0 4.000000 5.000000 nan nan 1754305099.639
1 4.000000 5.000000 nan nan 1754305117.895
2 4.000000 5.000000 nan nan 1754305135.935
3 4.000000 5.000000 nan nan 1754305154.658
4 4.000000 5.000000 nan nan 1754305174.053
5 4.000000 5.000000 nan nan 1754305192.787
6 4.000000 5.000000 nan nan 1754305211.095
7 4.000000 5.000000 nan nan 1754305229.860
8 4.000000 5.000000 nan nan 1754305249.033
9 4.000000 5.000000 nan nan 1754305268.243

View File

@@ -0,0 +1,10 @@
0 4.000000 5.000000 nan nan 1754315833.736
1 4.000000 5.000000 nan nan 1754315852.777
2 4.000000 5.000000 nan nan 1754315872.930
3 4.000000 5.000000 nan nan 1754315892.349
4 4.000000 5.000000 nan nan 1754315911.177
5 4.000000 5.000000 nan nan 1754315929.431
6 4.000000 5.000000 nan nan 1754315947.957
7 4.000000 5.000000 nan nan 1754315966.471
8 4.000000 5.000000 nan nan 1754315984.299
9 4.000000 5.000000 nan nan 1754316002.358

Some files were not shown because too many files have changed in this diff Show More