Beispiel #1
0
    if raw2 > 250 or value2 <= 0:  # same as for 1st channel
        gain2[gain] = 1
    else:
        gain2[gain] = target / value2

ee_gain = bytearray(16)

config.write("\n[gain]\n")

for index, gainID in enumerate(gains):
    voltID = V_div[index]
    g1 = gain1[gainID]
    g2 = gain2[gainID]
    config.write("ch0\\%dmV=%6.4f\n" % (voltID, g1))
    config.write("ch1\\%dmV=%6.4f\n" % (voltID, g2))
    # convert double 0.75 ... 1.25 -> byte 0x80-125 ... 0x80+125
    ee_gain[2 * index] = int((g1 - 1) * 500 + 0x80 + 0.5)
    ee_gain[2 * index + 1] = int((g2 - 1) * 500 + 0x80 + 0.5)

config.close()

print("eeprom gain content [ 40 .. 55 ]: ", ee_gain)

scope.set_calibration_values(ee_offset + ee_gain)

scope.close_handle()

print(
    "\nReady, now install the configuration file '%s' into directory '~/.config/OpenHantek'\n"
    % configfile)
        g1 = gain1[ gainID ]
        g2 = gain2[ gainID ]
        if ( g1 ):
            # convert double 0.75 ... 1.25 -> byte 0x80-125 ... 0x80+125
            ee_calibration[ 2 * index + 32] = int( round( ( g1 - 1 ) * 500 + 0x80 ) )
        if ( g2 ):
            # convert double 0.75 ... 1.25 -> byte 0x80-125 ... 0x80+125
            ee_calibration[ 2 * index + 33 ] = int( round( ( g2 - 1 ) * 500 + 0x80 ) )
        if ( create_config ):
            if ( g1 ):
                config.write( "ch0\\%dmV=%6.4f\n" % ( voltID, g1 ) )
            if ( g2 ):
                config.write( "ch1\\%dmV=%6.4f\n" % ( voltID, g2 ) )

# endif ( measure_gain )


if ( create_config ):
    config.close()


if ( eeprom ):
    print( "eeprom content [  8 .. 39 ]: ", binascii.hexlify( ee_calibration[  0:32 ] ) )
    print( "eeprom content [ 40 .. 55 ]: ", binascii.hexlify( ee_calibration[ 32:48 ] ) )
    print( "eeprom content [ 56 .. 87 ]: ", binascii.hexlify( ee_calibration[ 48:80 ] ) )
    # finally store the calibration values into eeprom
    scope.set_calibration_values( ee_calibration )


scope.close_handle()
Beispiel #3
0
offset2 = {}
offhi1 = {}
offhi2 = {}

for gain in gainSteps:
	# average 10 times over 100 ms (cancel 50 Hz / 60 Hz)
	print( "Measure offset at low speed for gain ", gain )
	raw1, raw2 = read_avg( gain, 110, 10 )
	offset1[ gain ] = 0x80 - raw1
	offset2[ gain ] = 0x80 - raw2
	print( "Measure offset at high speed for gain ", gain )
	raw1, raw2 = read_avg( gain, 30, 10 )
	offhi1[ gain ] = 0x80 - raw1
	offhi2[ gain ] = 0x80 - raw2

ee_offset = bytearray( 32 )

for index, gainID in enumerate( gains ):
	# prepare eeprom content
	ee_offset[ 2 * index ] = 0x80 - offset1[ gainID ]
	ee_offset[ 2 * index + 1 ] = 0x80 - offset2[ gainID ]
	ee_offset[ 2 * index + 16 ] = 0x80 - offhi1[ gainID ]
	ee_offset[ 2 * index + 17 ] = 0x80 - offhi2[ gainID ]

print( "eeprom content [ 8 .. 39 ]: ", binascii.hexlify(ee_offset) )


scope.set_calibration_values( ee_offset )

scope.close_handle()