Esempio n. 1
0
def calcCoeffTransf(I):
	# Исходная зашумленная зависимость
	#multer = Splitter	# с делителя на АЦП
	multer = 1	# если напрямую с датчик Холла
	U = I * Kiu + dU
	co.printW( 'Udac : ' + str( U )+'\n')
	Udig_f = toDigitalFull( U, multer, toDigital )
	Udig = int( Udig_f )
	
	# Рассчитываем шум - смещение по Y
	Udig_noise_f = toDigitalFull( dU, multer, toDigital )
	
	# Очищенное значение - без шума
	Udig_corr = int(Udig_f - Udig_noise_f)	# суммируются перед оцифровкой

	# коэффициент перевода. Это чистое значение тока - для рассчетов и отображения
	# Warning : немного расходится с прошитым, но прошитый откалиброван, поэтому 
	#   наверное пусть как есть
	Ktrans = I/Udig_corr  # A/ue
	
	# переводим в плавающую точку
	print 'capacity : ' + str( capacity )
	co.printN( 'Udig_src, ue : ' )
	co.printE( tc.byte4strhex( Udig )+'\n')
	print 'Udig_cor, ue :  ' + tc.byte4strhex( Udig_corr )
Esempio n. 2
0
def shift2Code( fShift ):
	Usm_needed = fShift

	# 2. Переводим в код
	V_test = 1.433	# V - на транзисторе при коде 0xFFF
	V_test_code = '0FFF'
	V_test_code = hexWordToInt( V_test_code ) # вид для расчета
	K_V2code = V_test_code / V_test
	Code =K_V2code * Usm_needed
	
	# Report
	co.printE( 'U : ' + str( Usm_needed )+'\n') 
	co.printW( 'Code : ' + str( int(Code) )+'\n')
	msg = 'Hex code, LH: : '
	ui.plotWord(msg, Code)
	
	# Выходные параметры
	return Code
Esempio n. 3
0
	co.printE( tc.byte4strhex( Udig )+'\n')
	print 'Udig_cor, ue :  ' + tc.byte4strhex( Udig_corr )

''' Просто заглушка '''
def printRpt( value, valueDisplacemented, valueScaled, valueCode, Kda ):
	print '\n<< Output values:'
	print 'Code : '+str(valueCode)
	print 'Kda : '+str(Kda)

# Run 
if __name__ == '__main__':
	# расчет коэффициентов трансформации
	listOfCurrents = [15, 10, 5]
	for current in listOfCurrents :
		msg = '\nI,A : ' + str( current ) + '\n'
		co.printW( msg )
		calcCoeffTransf( current )
	
	# проверяем
	'''valueDict = {}
	valueDict[ 'value' ] = I
	valueDict['displacement'] = dU
	valueDict['converter' ] = Kiu
	valueDict['scale'] = Splitter
	valueDict['capacity'] = capacity
	valueDict['Vmax'] = Vmax 
	code, Kda = adda.modelADC( valueDict, printRpt, adda.calcZeroDisplacmentY )'''



Esempio n. 4
0
	co.printW( 'Code : ' + str( int(Code) )+'\n')
	msg = 'Hex code, LH: : '
	ui.plotWord(msg, Code)
	
	# Выходные параметры
	return Code

# Перобразование смещения
T = 26.0	# Температура 8 бит бит/градус

# температурный коэффициент
corrected_mult = 4.9 * 5 * 1e-3	# V/oC

# расчет
dUsm = T * corrected_mult

# В виде кода
dUsm_code = shift2Code( dUsm )
K_oC2Code = dUsm_code / T
# переводим в плавающую точку
msg = 'T to code, float32:'
ui.plot(msg, K_oC2Code)
co.printW( 'T to code : '+str(K_oC2Code)+'\n' )

# нулевое приближение в коде
#U = 1.433
#U_code = shift2Code( U )