From 49a8262c6c142edf62e4e1ce37ac7310be572f4d Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Thu, 1 Aug 2019 14:45:07 +0100 Subject: [PATCH] WH-17 - Added a script for analysing wheel alignment errors --- .../2/src/test/error_analysis/hmb_log.txt | 76 +++++++++++ .../pixel_pitch_corr_analysis.py | 128 ++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 generic_ip/pulse_generator/2/src/test/error_analysis/hmb_log.txt create mode 100644 generic_ip/pulse_generator/2/src/test/error_analysis/pixel_pitch_corr_analysis.py diff --git a/generic_ip/pulse_generator/2/src/test/error_analysis/hmb_log.txt b/generic_ip/pulse_generator/2/src/test/error_analysis/hmb_log.txt new file mode 100644 index 0000000..b3896e3 --- /dev/null +++ b/generic_ip/pulse_generator/2/src/test/error_analysis/hmb_log.txt @@ -0,0 +1,76 @@ +# HMB log file +< 2019_07_30_h09:39:37 > Loading Configuration file ./config/default.cfg +< 2019_07_30_h09:39:37 > Encoder Resolution = 20.0000000000 +< 2019_07_30_h09:39:37 > Print-Head Resolution type = dpi +< 2019_07_30_h09:39:37 > Print-Head Resolution = 1200.0000000000 +< 2019_07_30_h09:39:37 > Encoder Source = 0 +< 2019_07_30_h09:39:37 > Internal Encoder Frequency = 5000.0000000000 +< 2019_07_30_h09:39:37 > Encoder Phase = 1 +< 2019_07_30_h09:39:37 > Encoder Edge = 2 +< 2019_07_30_h09:39:37 > Encoder Directionality = 0 +< 2019_07_30_h09:39:37 > PD Source = 3 +< 2019_07_30_h09:39:37 > PD Edge = 0 +< 2019_07_30_h09:39:37 > Print-Mode = Continuous +< 2019_07_30_h09:39:37 > PD-Type = None +< 2019_07_30_h09:39:37 > Image Length = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Gap Length = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Print-Head Width = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Forward-Pass Pre-Print Buffer Length = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Swathe Length = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Reverse-Pass Offset = 0.0000000000 pixel +< 2019_07_30_h09:39:37 > Pre-Print Additional Movement = 0.0000000000 mm +< 2019_07_30_h09:39:37 > Daisy-Chain Enable = 1 +< 2019_07_30_h09:39:37 > Daisy-Chain Position = 1 +< 2019_07_30_h09:39:37 > Daisy-Chain Length = 1 +< 2019_07_30_h09:39:37 > Configuration file loaded. +< 2019_07_30_h09:39:37 > Make sure to be connected to the EMB Server and press the button 'Apply' to configure the EMB +< 2019_07_30_h09:39:37 > Starting Remote-Server on port 6124 +< 2019_07_30_h09:39:46 > ERROR: Unable to connect to the EMB-server on IP address 192.168.79.139 +< 2019_07_30_h09:40:21 > Opened connection to IP 192.168.79.139, Port 6121 +< 2019_07_30_h09:40:21 > show server.version +< 2019_07_30_h09:40:21 > hmb_remote_server version 1.10016.0.5356 + +< 2019_07_30_h09:40:21 > show fpm_ctrl.fw_info +< 2019_07_30_h09:40:21 > GIS-HMB Board - Firmware version is F003 + +< 2019_07_30_h09:40:23 > set diag.pd_watchdog_enable 0 0.1 +< 2019_07_30_h09:40:23 > set diag.polling 7 200 +< 2019_07_30_h09:42:49 > show print.force_all_zeros +< 2019_07_30_h09:42:49 > 0 + +< 2019_07_30_h09:43:05 > set pg.wh_wheel_corr 1 4827 +< 2019_07_30_h09:43:05 > W&H - Wheel Correction Enabled +< 2019_07_30_h09:43:30 > Event-Number #1, Time = 500.092 s, Positition = 101.540000 mm (abs_pos = 20308) +< 2019_07_30_h09:43:37 > - Rotation Count = 1, Position Error = -2.000, Division-Ratio Correction = -0.00331500 +< 2019_07_30_h09:43:37 > Event-Number #2, Time = 506.773 s, Positition = 198.080000 mm (abs_pos = 39616) +< 2019_07_30_h09:43:44 > - Rotation Count = 2, Position Error = 1.000, Division-Ratio Correction = -0.00000000 +< 2019_07_30_h09:43:44 > Event-Number #3, Time = 513.464 s, Positition = 294.620000 mm (abs_pos = 58924) +< 2019_07_30_h09:43:46 > Event-Number #4, Time = 515.962 s, Positition = 391.160000 mm (abs_pos = 78232) +< 2019_07_30_h09:43:47 > - Rotation Count = 3, Position Error = 2.000, Division-Ratio Correction = 0.00248600 +< 2019_07_30_h09:43:49 > - Rotation Count = 4, Position Error = -1.000, Division-Ratio Correction = -0.00082900 +< 2019_07_30_h09:43:49 > Event-Number #5, Time = 518.668 s, Positition = 487.700000 mm (abs_pos = 97540) +< 2019_07_30_h09:43:51 > Event-Number #6, Time = 520.496 s, Positition = 584.240000 mm (abs_pos = 116848) +< 2019_07_30_h09:43:51 > - Rotation Count = 5, Position Error = 0.000, Division-Ratio Correction = -0.00000000 +< 2019_07_30_h09:43:52 > Event-Number #7, Time = 522.121 s, Positition = 680.780000 mm (abs_pos = 136156) +< 2019_07_30_h09:43:53 > - Rotation Count = 6, Position Error = 0.000, Division-Ratio Correction = -0.00000000 +< 2019_07_30_h09:43:54 > Event-Number #8, Time = 523.475 s, Positition = 777.320000 mm (abs_pos = 155464) +< 2019_07_30_h09:43:54 > - Rotation Count = 7, Position Error = 0.000, Division-Ratio Correction = -0.00000000 +< 2019_07_30_h09:44:12 > Event-Number #9, Time = 542.085 s, Positition = 872.320000 mm (abs_pos = 174464) +< 2019_07_30_h09:44:14 > - Rotation Count = 8, Position Error = -1.000, Division-Ratio Correction = -0.51046200 +< 2019_07_30_h09:44:15 > Event-Number #10, Time = 544.155 s, Positition = 967.320000 mm (abs_pos = 193464) +< 2019_07_30_h09:44:15 > - Rotation Count = 9, Position Error = -1.000, Division-Ratio Correction = -0.25688900 +< 2019_07_30_h09:44:17 > - Rotation Count = 10, Position Error = 2.000, Division-Ratio Correction = -0.25274600 +< 2019_07_30_h09:44:17 > Event-Number #11, Time = 546.342 s, Positition = 1062.320000 mm (abs_pos = 212464) +< 2019_07_30_h09:44:19 > Event-Number #12, Time = 548.990 s, Positition = 1157.320000 mm (abs_pos = 231464) +< 2019_07_30_h09:44:20 > - Rotation Count = 11, Position Error = -1.000, Division-Ratio Correction = -0.25606000 +< 2019_07_30_h09:44:22 > Event-Number #13, Time = 551.806 s, Positition = 1252.320000 mm (abs_pos = 250464) +< 2019_07_30_h09:44:22 > - Rotation Count = 12, Position Error = 0.000, Division-Ratio Correction = -0.25523200 +< 2019_07_30_h09:44:24 > Event-Number #14, Time = 553.494 s, Positition = 1347.320000 mm (abs_pos = 269464) +< 2019_07_30_h09:44:24 > - Rotation Count = 13, Position Error = 0.000, Division-Ratio Correction = -0.25523200 +< 2019_07_30_h09:44:25 > - Rotation Count = 14, Position Error = 0.000, Division-Ratio Correction = -0.25523200 +< 2019_07_30_h09:44:25 > Event-Number #15, Time = 554.990 s, Positition = 1442.320000 mm (abs_pos = 288464) +< 2019_07_30_h09:59:11 > set diag.polling 0 200 +< 2019_07_30_h09:59:11 > set server.disconnect +< 2019_07_30_h09:59:11 > Closed connection to 192.168.79.139 +< 2019_07_30_h09:59:11 > - Rotation Count = -1, Position Error = 0.000, Division-Ratio Correction = -1.00000000 +< 2019_07_30_h09:59:43 > Closing EMB Console ... diff --git a/generic_ip/pulse_generator/2/src/test/error_analysis/pixel_pitch_corr_analysis.py b/generic_ip/pulse_generator/2/src/test/error_analysis/pixel_pitch_corr_analysis.py new file mode 100644 index 0000000..8a5f903 --- /dev/null +++ b/generic_ip/pulse_generator/2/src/test/error_analysis/pixel_pitch_corr_analysis.py @@ -0,0 +1,128 @@ +##///////////////////////////////////////////////////////////////////////////// +## Title : wheel_correction_analysis +##///////////////////////////////////////////////////////////////////////////// +## File : wheel_correction_analysis.py +## Author : Gianmarco Girau +## Company : GIS +## Target : HMB Console +## Dependency : none +##///////////////////////////////////////////////////////////////////////////// +## Description: Analyze misalignment error from wheel corrections +##///////////////////////////////////////////////////////////////////////////// +## Last update: 2019-05-30 +##///////////////////////////////////////////////////////////////////////////// +## Revisions : +## Date Version Author Description +## 2019-05-30 01.00.0a gmg Created +##///////////////////////////////////////////////////////////////////////////// + + +from bokeh.plotting import figure, output_file, show +from bokeh.layouts import gridplot + + +rotation_idx = [] +pos_err = [] +pitch_corr = [] + +log_file_name = './hmb_log.txt' +data_file_name = './pitch_corr.csv' + +plot_file_name_1 = './pitch_corr_1.html' +plot_file_name_2 = './pitch_corr_2.html' + +##///////////////////////////////////////////////////////////////////////////// +## Get data from the log file +##///////////////////////////////////////////////////////////////////////////// + +f_log = open(log_file_name, 'r') + +for line in f_log: + target = ' - ' + idx =line.find(target) + if idx != -1: + target = 'Rotation Count = ' + idx = line.find(target) + clist = line[idx+len(target):].split(None) + rotation_idx.append(int(clist[0][0:-1])) + target = 'Position Error = ' + idx = line.find(target) + clist = line[idx + len(target):].split(None) + pos_err.append(float(clist[0][0:-1])) + target = 'Division-Ratio Correction = ' + idx = line.find(target) + clist = line[idx + len(target):].split(None) + pitch_corr.append(float(clist[0][0:-1])) + + #print("Rotation Idx = {0:d}, Position-Error = {1:f}, Pixel-Pitch-Correction = {2:f}".format(rotation_idx[-1], pos_err[-1], pitch_corr[-1])) + + + # Create empty lists for rotation numbers, errors, add an the corresponding item on each line + +f_log.closed + +# Save data on a separate CSV file + +f_data = open(data_file_name, 'w') +f_data.write("Rotation index, Position Error, Pixel-Pitch Correction" + '\n') +for idx in range(0,len(rotation_idx)): + f_data.write("{0:d}, {1:f}, {2:f}".format(rotation_idx[idx], pos_err[idx], pitch_corr[idx]) + '\n') + +f_data.close + +##///////////////////////////////////////////////////////////////////////////// +## Plot-data +##///////////////////////////////////////////////////////////////////////////// + +# output to static HTML file +output_file(plot_file_name_1) + +plot_w = 500 +plot_h = 500 + +toolset="pan,box_zoom,reset,save" + +# create a new plot +s1 = figure(width=plot_w, plot_height=plot_h, title='Position Error', x_axis_label='Flexo Wheel Rotation', y_axis_label='Position Error [Encoder Steps]', tools=toolset) +s1.circle(rotation_idx, pos_err, size=5, color="navy", alpha=0.5) + +s2 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=s1.y_range, title='Pixel-Pitch Correction', x_axis_label='Flexo Wheel Rotation', y_axis_label='Pixel-Pitch Correction [Encoder Steps]', tools=toolset) +s2.triangle(rotation_idx, pitch_corr, size=10, color="olive", alpha=0.5) + +#p = gridplot([[s1], [s2]], toolbar_location=None) +p = gridplot([[s1], [s2]]) + +# show the results +show(p) + +# Create a second plot in um + +# output to static HTML file +output_file(plot_file_name_2) + +enc_res = 5 +head_reas = 21.167 + +pos_err_um = [x*enc_res for x in pos_err] +pitch_corr_um = [x*enc_res for x in pitch_corr] + +plot_w = 500 +plot_h = 500 + +toolset="pan,box_zoom,reset,save" + +# create a new plot +s1 = figure(width=plot_w, plot_height=plot_h, title='Position Error', x_axis_label='Flexo Wheel Rotation', y_axis_label='Position Error [um]', tools=toolset) +s1.circle(rotation_idx, pos_err_um, size=5, color="navy", alpha=0.5) + +s2 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=s1.y_range, title='Pixel-Pitch Correction', x_axis_label='Flexo Wheel Rotation', y_axis_label='Pixel-Pitch Correction [um]', tools=toolset) +s2.triangle(rotation_idx, pitch_corr_um, size=10, color="olive", alpha=0.5) + +#p = gridplot([[s1], [s2]], toolbar_location=None) +p = gridplot([[s1], [s2]]) + +# show the results +show(p) + + +