def calibrate_load_cell(self): print 'Place sensor in zero load configuration' print 'Hit any key to continue' raw_input() sensors = [ 'adc_load_0', 'adc_load_1', 'adc_load_2', 'adc_load_3', 'adc_load_4', 'adc_load_5' ] self.step() z = self.get_sensor_list_avg(sensors, 3.0) print 'Zero' print z self.comp_rt.config['calib']['wrench']['cb_adc_bias'][0] = float( z['adc_load_0']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][1] = float( z['adc_load_1']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][2] = float( z['adc_load_2']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][3] = float( z['adc_load_3']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][4] = float( z['adc_load_4']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][5] = float( z['adc_load_5']) m = [500.0, 1000.0, 2000.0] log_mN = [] log_fZ = [] for g in m: print 'Place ', g, '(g) load on sensor in negative Fz direction' print 'Hit any key to continue' raw_input() sensors = [ 'adc_load_0', 'adc_load_1', 'adc_load_2', 'adc_load_3', 'adc_load_4', 'adc_load_5' ] self.step() z = self.get_sensor_list_avg(sensors, 2.0) self.comp_rt.config['calib']['wrench'][ 'cb_scale'] = 1.0 #just determin this and zero w = self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) #print 'Enter weight (g)' mN = -1.0 * m3u.g2mN(g) #m3u.g2mN(m3t.get_float()) log_mN.append(mN) est = w[2] #current Fz estimation, N log_fZ.append(est) print 'Measured (g)', m3u.mN2g(mN) print 'Estimated (g)', m3u.mN2g(est) scale = mN / est print 'Scale', scale poly, inv_poly = self.get_polyfit_to_data(x=log_fZ, y=log_mN, n=1) print 'Estimated scale', poly[0] self.comp_rt.config['calib']['wrench']['cb_scale'] = poly[0] self.comp_rt.config['calib']['wrench']['cb_bias'] = [0.0] * 6 w = self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5'])
def display_sensors(self): M3Calibrate.display_sensors(self) w = self.wrench.raw_2_mNm( self.comp_rt.config['calib']['wrench'], self.comp_ec.status.adc_load_0, self.comp_ec.status.adc_load_1, self.comp_ec.status.adc_load_2, self.comp_ec.status.adc_load_3, self.comp_ec.status.adc_load_4, self.comp_ec.status.adc_load_5) print '--------------Ec--------------------' print 0, self.comp_ec.status.adc_load_0 print 1, self.comp_ec.status.adc_load_1 print 2, self.comp_ec.status.adc_load_2 print 3, self.comp_ec.status.adc_load_3 print 4, self.comp_ec.status.adc_load_4 print 5, self.comp_ec.status.adc_load_5 print '--------------Calib-----------------' print 'Fx (g)', m3u.mN2g(w[0]) print 'Fy (g)', m3u.mN2g(w[1]) print 'Fz (g)', m3u.mN2g(w[2]) print 'Tx (mNm)', w[3] print 'Ty (mNm)', w[4] print 'Tz (mNm)', w[5] print '---------------Rt-------------------' print 'Fx (g)', self.comp_rt.get_Fx_Kg() * 1000.0 print 'Fy (g)', self.comp_rt.get_Fy_Kg() * 1000.0 print 'Fz (g)', self.comp_rt.get_Fz_Kg() * 1000.0 print 'Tx (mNm)', self.comp_rt.get_Tx_mNm() print 'Ty (mNm)', self.comp_rt.get_Ty_mNm() print 'Tz (mNm)', self.comp_rt.get_Tz_mNm()
def zero_load_cell_with_payload(self): print 'Place arm with mass pulling straight down on FTS' print 'Enter payload mass (g) [834g=H2R2wFTS]' payload = m3u.g2mN(m3t.get_float(834)) sensors = [ 'adc_load_0', 'adc_load_1', 'adc_load_2', 'adc_load_3', 'adc_load_4', 'adc_load_5' ] self.step() z = self.get_sensor_list_avg(sensors, 3.0) print 'Sensor readings: ', z w = self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) print 'Old payload', m3u.mN2g(w[2]) w[2] = w[2] - payload bc = nu.array(self.comp_rt.config['calib']['wrench']['cb_bias']) self.comp_rt.config['calib']['wrench']['cb_bias'] = list(bc - w) w = self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) print 'New payload: ', m3u.mN2g(w[2]) print 'New wrench', w
def display_sensors(self): M3Calibrate.display_sensors(self) w=self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], self.comp_ec.status.adc_load_0, self.comp_ec.status.adc_load_1, self.comp_ec.status.adc_load_2, self.comp_ec.status.adc_load_3, self.comp_ec.status.adc_load_4, self.comp_ec.status.adc_load_5) print '--------------Ec--------------------' print 0,self.comp_ec.status.adc_load_0 print 1,self.comp_ec.status.adc_load_1 print 2,self.comp_ec.status.adc_load_2 print 3,self.comp_ec.status.adc_load_3 print 4,self.comp_ec.status.adc_load_4 print 5,self.comp_ec.status.adc_load_5 print '--------------Calib-----------------' print 'Fx (g)',m3u.mN2g(w[0]) print 'Fy (g)',m3u.mN2g(w[1]) print 'Fz (g)',m3u.mN2g(w[2]) print 'Tx (mNm)',w[3] print 'Ty (mNm)',w[4] print 'Tz (mNm)',w[5] print '---------------Rt-------------------' print 'Fx (g)',self.comp_rt.get_Fx_Kg()*1000.0 print 'Fy (g)',self.comp_rt.get_Fy_Kg()*1000.0 print 'Fz (g)',self.comp_rt.get_Fz_Kg()*1000.0 print 'Tx (mNm)',self.comp_rt.get_Tx_mNm() print 'Ty (mNm)',self.comp_rt.get_Ty_mNm() print 'Tz (mNm)',self.comp_rt.get_Tz_mNm()
def zero_load_cell_with_payload(self): print 'Place arm with mass pulling straight down on FTS' print 'Enter payload mass (g) [834g=H2R2wFTS]' payload=m3u.g2mN(m3t.get_float(834)) sensors=['adc_load_0','adc_load_1','adc_load_2','adc_load_3','adc_load_4','adc_load_5'] self.step() z=self.get_sensor_list_avg(sensors,3.0) print 'Sensor readings: ',z w=self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) print 'Old payload',m3u.mN2g(w[2]) w[2]=w[2]-payload bc=nu.array(self.comp_rt.config['calib']['wrench']['cb_bias']) self.comp_rt.config['calib']['wrench']['cb_bias']=list(bc-w) w=self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) print 'New payload: ',m3u.mN2g(w[2]) print 'New wrench',w
def calibrate_load_cell(self): print 'Place sensor in zero load configuration' print 'Hit any key to continue' raw_input() sensors=['adc_load_0','adc_load_1','adc_load_2','adc_load_3','adc_load_4','adc_load_5'] self.step() z=self.get_sensor_list_avg(sensors,3.0) print 'Zero' print z self.comp_rt.config['calib']['wrench']['cb_adc_bias'][0]=float(z['adc_load_0']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][1]=float(z['adc_load_1']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][2]=float(z['adc_load_2']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][3]=float(z['adc_load_3']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][4]=float(z['adc_load_4']) self.comp_rt.config['calib']['wrench']['cb_adc_bias'][5]=float(z['adc_load_5']) m=[500.0,1000.0,2000.0] log_mN=[] log_fZ=[] for g in m: print 'Place ',g,'(g) load on sensor in negative Fz direction' print 'Hit any key to continue' raw_input() sensors=['adc_load_0','adc_load_1','adc_load_2','adc_load_3','adc_load_4','adc_load_5'] self.step() z=self.get_sensor_list_avg(sensors,2.0) self.comp_rt.config['calib']['wrench']['cb_scale']=1.0 #just determin this and zero w=self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5']) #print 'Enter weight (g)' mN=-1.0*m3u.g2mN(g)#m3u.g2mN(m3t.get_float()) log_mN.append(mN) est=w[2] #current Fz estimation, N log_fZ.append(est) print 'Measured (g)',m3u.mN2g(mN) print 'Estimated (g)',m3u.mN2g(est) scale=mN/est print 'Scale',scale poly,inv_poly=self.get_polyfit_to_data(x=log_fZ,y=log_mN,n=1) print 'Estimated scale',poly[0] self.comp_rt.config['calib']['wrench']['cb_scale']=poly[0] self.comp_rt.config['calib']['wrench']['cb_bias']=[0.0]*6 w=self.wrench.raw_2_mNm(self.comp_rt.config['calib']['wrench'], z['adc_load_0'], z['adc_load_1'], z['adc_load_2'], z['adc_load_3'], z['adc_load_4'], z['adc_load_5'])
def display_sensors(self): M3CalibrateActuatorEcR1.display_sensors(self) q_on=self.comp_ec.status.qei_on q_p=self.comp_ec.status.qei_period q_r=self.comp_ec.status.qei_rollover c=self.theta.raw_2_deg(self.comp_rt.config['calib']['theta'],q_on,q_p,q_r) pos=1000.0*math.pi*2*self.comp_j.config['calib']['cb_drive_radius_m']*c/360.0 print 'Pos: (mm) : '+'%3.3f'%pos+' Qei On '+'%d'%q_on+' Qei Period '+'%d'%q_p+' Qei Rollover '+'%d'%q_r raw=self.comp_ec.status.adc_torque c=self.torque.raw_2_mNm(self.comp_rt.config['calib']['torque'],raw) mN=c/self.comp_j.config['calib']['cb_drive_radius_m'] print 'Force: (g) : '+'%3.2f'%m3u.mN2g(mN)+' (mN): '+'%3.2f'%mN+' (ADC) '+'%d'%raw
def analyze_torque_hub(self): print 'Calibration hub diameter (mm)[70]?' ch=m3t.get_float(70) while True: print 'Add calibration weight' print 'Continue [y]?' if m3t.get_yes_no('y'): for i in range(100): self.step(time_sleep=0.1) raw=self.comp_ec.status.adc_torque c=self.torque.raw_2_mNm(self.comp_rt.config['calib']['torque'],raw) c=m3u.mN2g(c/(ch/1000.0)) print 'Estimated weight (g)',c else: break
def get_force_g(self): return m3u.mN2g(self.get_force_mN())