Skip to content

Commit

Permalink
correct ini file offset sign (same value as in EEPROM), fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho-Ro committed Mar 6, 2023
1 parent 01b82fd commit d25822d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
2022-10-18: update build process, create OpenHantek6022 header file with FW version [01b82fd]
2022-07-29: update README, add status badges [00a965f]
2022-07-29: upversion to 2.10.4 [6737826]
2022-07-29: fix for #17 provided by guerby [b5fbe7b]
Expand Down
12 changes: 6 additions & 6 deletions PyHT6022/Firmware/DSO6022BE/scope6022.inc
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,18 @@ static BOOL set_samplerate( BYTE rate ) {
}

// new functon to set the calibration pulse frequency that allows
// to set all possible frequencies between 40 Hz and 100 kHz
// integer dividers of 2MHz Hz will be exact
// to set all possible frequencies between 32 Hz and 100 kHz
// integer dividers of 2MHz will be exact
// frequencies between 40 Hz and 1000 Hz can be multiples of 10 Hz
// frequencies between 100 Hz to 10 kHz can be multiples of 100 Hz
// frequencies between 1 kHz to 100 kHz can be multiples of 1 kHz
// frequencies between 100 Hz and 5500 Hz can be multiples of 100 Hz
// frequencies between 1 kHz and 100 kHz can be multiples of 1 kHz
// calibration frequency is coded into one byte parameter freq:
// freq == 0 -> 100 Hz (compatibility to old sigrok coding)
// freq 1..100 -> freq in kHz
// freq 101, 102 -> not possible
// freq == 103 -> 32 Hz (lowest possible frequency due to 16bit HW timer2)
// freq 104..200 -> (value-100)*10 is freq in Hz
// freq 201..255 -> (value-200)*100 is freq in Hz
// freq 104..200 -> (value-100)*10 is freq in Hz (40, 50, ... 1000)
// freq 201..255 -> (value-200)*100 is freq in Hz (100, 200, ... 5500)
// e.g. 105 -> 50 Hz, 216 -> 1600 Hz, 20 -> 20 kHz
//
static BOOL set_calibration_pulse( BYTE freq ) {
Expand Down
6 changes: 4 additions & 2 deletions examples/calibrate_6022.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,23 @@ def read_avg( voltage_range, sample_rate=110, repeat = 1, samples = 12 * 1024 ):
config.write( calFile )
config.write( "\n;Created by tool 'calibrate_6022.py'\n\n" )

# offset as measured: values > 0 correct downwards, values < 0 correct upwards
config.write( "[offset]\n" )
for index, gainID in enumerate( gains ):
voltID = V_div[ index ]
if ( abs( offset1[ gainID ] ) <= 25 ): # offset too high -> skip
config.write( "ch0\\%dmV=%6.2f\n" % ( voltID, -offset1[ gainID ] ) )
config.write( "ch0\\%dmV=%6.2f\n" % ( voltID, offset1[ gainID ] ) )
for index, gainID in enumerate( gains ):
voltID = V_div[ index ]
if ( abs( offset2[ gainID ] ) <= 25 ): # offset too high -> skip
config.write( "ch1\\%dmV=%6.2f\n" % ( voltID, -offset2[ gainID ] ) )
config.write( "ch1\\%dmV=%6.2f\n" % ( voltID, offset2[ gainID ] ) )


for index, gainID in enumerate( gains ):
# print( gains[index], offlo1[gainID], offlo2[gainID], offhi1[gainID], offhi2[gainID], )
# prepare eeprom content
# store values in offset binary format (zero = 0x80, as in factory setup)
# offset as measured: values > 0x80 correct downwards, values < 0x80 correct upwards
if ( abs( offlo1[ gainID ] ) <= 25 ): # offset too high -> skip
ee_calibration[ 2 * index ] = 0x80 + offlo1[ gainID ] # CH1 offset integer part
if ( abs( offlo_1[ gainID ] ) <= 125 ): # frac part not plausible
Expand Down

0 comments on commit d25822d

Please sign in to comment.