コード例 #1
0
 def test_get_cal_values(self):
     print "Testing getting calibration values."
     scope = Oscilloscope()
     assert scope.setup()
     assert scope.open_handle()
     assert scope.flash_firmware()
     cal_values = scope.get_calibration_values()
     assert cal_values
     assert scope.close_handle()
コード例 #2
0
ファイル: cal_zero.py プロジェクト: litospain/Hantek6022API
    offhi1[gain] = raw1
    offhi_1[gain] = fine1
    offhi2[gain] = raw2
    offhi_2[gain] = fine2

# get calibration values stored in the scope (all values are 0x80 binary offset, 0x80 = 0)
# use these values as default if new values are not plausible
# structure and representation of these values due to historical reason
# 32 byte integer offset CH1, CH2,... for 8 input ranges (20mV, 50mV,..., 5V) for low and high speed
# these are also the factory calibration settings (0x80 = no offset)
# next 16 bytes are the gain correction values CH1, CH2, ... same voltage range, only one speed
# 0x80 = 1.0, 0x80-125 = 0.75, 0x80+125 = 1.25
# next 32 bytes are the fractional error (range -0.5 ... +0.5) of the offset values above,
# 0x80 = 0, 0x80-125 = -0.5, 0x80+125 = +0.5
#
ee_offset = bytearray(scope.get_calibration_values(32 + 16 + 32))

for index, gainID in enumerate(gains):
    # print( gains[index], offset1[gainID], offset2[gainID], offhi1[gainID], offhi2[gainID],  )
    # prepare eeprom content
    if (abs(offset1[gainID]) <= 25):  # offset too high -> skip
        ee_offset[2 *
                  index] = 0x80 + offset1[gainID]  # CH1 offset integer part
    if (abs(offset_1[gainID]) <= 125):  # frac part not plausible
        ee_offset[2 * index +
                  48] = 0x80 + offset_1[gainID]  # CH1 offset fractional part
    if (abs(offset2[gainID]) <= 25):
        ee_offset[2 * index +
                  1] = 0x80 + offset2[gainID]  # CH2 offset integer part
    if (abs(offset_2[gainID]) <= 125):
        ee_offset[2 * index +
コード例 #3
0
    argerror = True
if argerror:
    sys.exit()
#
############

scope = Oscilloscope()
scope.setup()
scope.open_handle()

# upload correct firmware into device's RAM
if (not scope.is_device_firmware_present):
    scope.flash_firmware()

# read calibration values from EEPROM
calibration = scope.get_calibration_values()

# set interface: 0 = BULK, >0 = ISO, 1=3072,2=2048,3=1024 bytes per 125 us
scope.set_interface(0)  # use BULK unless you have specific need for ISO xfer

scope.set_num_channels(channels)

# calculate and set the sample rate ID from real sample rate value
if sample_rate < 1e6:
    sample_id = int(100 + sample_rate / 10e3)
else:
    sample_id = int(sample_rate / 1e6)
scope.set_sample_rate(sample_id)

# set the gain for CH1 and CH2
scope.set_ch1_voltage_range(ch1gain)