@@ -56,7 +56,7 @@ def __init__(
5656 self ,
5757 data_raw : pd .DataFrame ,
5858 file_name : str ,
59- input_voltage : float ,
59+ excitation_voltage : float ,
6060 resistance : float ,
6161 execution_root : str | None = None ,
6262 ) -> None :
@@ -65,7 +65,7 @@ def __init__(
6565 Args:
6666 data_raw (pd.DataFrame): Raw data containing time and thrust measurements.
6767 file_name (str): File name identifier.
68- input_voltage (float): Input voltage used during measurement.
68+ excitation_voltage (float): Excitation voltage used during measurement.
6969 resistance (float): Resistance value used during measurement.
7070 execution_root (str | None): Base directory for logs/ and results/*.
7171 If None, defaults to current working directory.
@@ -79,9 +79,11 @@ def __init__(
7979
8080 # Load configuration parameters explicitly
8181 self ._CFG = load_global_config (self ._EXEC_ROOT )
82- self ._rated_output = self ._CFG .rated_output
83- self ._rated_load = self ._CFG .rated_load
82+ self ._sensitivity_mv_per_v = self ._CFG .sensitivity_mv_per_v
83+ self ._rated_capacity_kgf = self ._CFG .rated_capacity_kgf
8484 self ._g = 9.80665 # gravitational acceleration, m/s^2
85+ self ._gain_internal_resistance_kohm = self ._CFG .gain_internal_resistance_kohm
86+ self ._gain_offset = self ._CFG .gain_offset
8587 self ._frequency = self ._CFG .frequency
8688 self ._cutoff_frequency = self ._CFG .cutoff_frequency
8789 self ._lowpass_order = self ._CFG .lowpass_order
@@ -155,7 +157,7 @@ def __init__(
155157 ].copy ()
156158 self ._data_raw .columns = ["time" , "thrust" ]
157159 self ._file_name : str = file_name
158- self ._input_voltage : float = input_voltage
160+ self ._excitation_voltage : float = excitation_voltage
159161 self ._resistance : float = resistance
160162
161163 self ._logger .info ("0. Initialization complete." )
@@ -200,14 +202,38 @@ def _convert_voltage_to_thrust(self, data: pd.DataFrame) -> pd.DataFrame:
200202 """
201203 self ._logger .info (" 1-1. Converting voltage to thrust." )
202204 try :
205+ # Validate required config parameters
206+ missing_params : list [str ] = []
207+ if self ._sensitivity_mv_per_v is None :
208+ missing_params .append ("sensitivity_mv_per_v" )
209+ if self ._rated_capacity_kgf is None :
210+ missing_params .append ("rated_capacity_kgf" )
211+ if self ._gain_internal_resistance_kohm is None :
212+ missing_params .append ("gain_internal_resistance_kohm" )
213+ if self ._gain_offset is None :
214+ missing_params .append ("gain_offset" )
215+ if missing_params :
216+ self ._logger .error (
217+ "Missing required load cell config: %s" , ", " .join (missing_params )
218+ )
219+ raise ValueError (
220+ "Missing required load cell configuration: "
221+ + ", " .join (missing_params )
222+ )
203223 # 전압 값을 추력으로 변환
224+ # Convert volts -> thrust(N) using sensitivity (mV/V), capacity(kgf), excitation voltage(V),
225+ # amplifier internal resistance (kOhm) and gain offset.
226+ # Formula adapted to new config naming; assumes linear behavior.
204227 data ["thrust" ] = (
205228 data ["thrust" ]
206229 * 1000
207- / (self ._rated_output * self ._input_voltage )
208- * self ._rated_load
230+ / (self ._sensitivity_mv_per_v * self ._excitation_voltage )
231+ * self ._rated_capacity_kgf
209232 * self ._g
210- / (1 + 49.4 * 1000 / self ._resistance )
233+ / (
234+ self ._gain_offset
235+ + self ._gain_internal_resistance_kohm * 1000 / self ._resistance
236+ )
211237 )
212238 except Exception as e :
213239 self ._logger .error ("Error converting voltage to thrust: %s" , e )
@@ -636,10 +662,12 @@ def _thrust_plot(self) -> None:
636662 )
637663
638664 ax .annotate (
639- "Impulse " + str (round (self ._impulse , 2 )) + " Ns\n "
640- "Input Voltage " + str (round (self ._input_voltage , 2 )) + " V\n "
641- "Resistance " + str (round (self ._resistance , 2 )) + r" $\Omega$" ,
642- xy = (0.72 , 0.85 ),
665+ "Impulse " + str (round (self ._impulse , 2 )) + " Ns\n "
666+ "Excitation Voltage " + str (round (self ._excitation_voltage , 2 )) + " V\n "
667+ "Resistance "
668+ + str (round (self ._resistance , 2 ))
669+ + r" $\Omega$" ,
670+ xy = (0.67 , 0.85 ),
643671 xycoords = "axes fraction" ,
644672 size = 20 ,
645673 font = "Arial" ,
@@ -707,7 +735,15 @@ def run(self) -> pd.DataFrame:
707735 config = pd .read_excel (config_path , sheet_name = 0 , header = 0 , index_col = 0 )
708736 idx = len (config ) - 1
709737 expt_file_name = config ["expt_file_name" ][idx ]
710- expt_input_voltage = config ["expt_input_voltage [V]" ][idx ]
738+ # Backward-compatible: read excitation voltage from new or legacy column
739+ if "expt_excitation_voltage [V]" in config .columns :
740+ expt_excitation_voltage = config ["expt_excitation_voltage [V]" ][idx ]
741+ elif "expt_input_voltage [V]" in config .columns :
742+ expt_excitation_voltage = config ["expt_input_voltage [V]" ][idx ]
743+ else :
744+ raise ValueError (
745+ "Missing excitation voltage column: expected 'expt_excitation_voltage [V]' or legacy 'expt_input_voltage [V]'"
746+ )
711747 expt_resistance = config ["expt_resistance [Ohm]" ][idx ]
712748
713749 print (f"Loaded configuration for experiment: { expt_file_name } " )
@@ -738,6 +774,6 @@ def run(self) -> pd.DataFrame:
738774 print ("Successfully loaded input data file." )
739775
740776 process = ThrustPostProcess (
741- thrust_data , expt_file_name , expt_input_voltage , expt_resistance
777+ thrust_data , expt_file_name , expt_excitation_voltage , expt_resistance
742778 )
743779 _ = process .run ()
0 commit comments