Skip to content

Commit

Permalink
CG-533: rework CDT calibration and add new --scalr option
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Wickins committed May 9, 2024
1 parent 9d67a32 commit 8560540
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pylinkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def deplw(self):
def scalw(self, sensor, step, value=0):
self._dte.scalw(sensor, step, value)

def scalr(self, sensor, step):
return self._dte.scalr(sensor, step)

def argostx(self, mod, power, freq, size, tcxo):
self._dte.argostx(mod, power, freq, size, tcxo)

Expand Down
27 changes: 25 additions & 2 deletions pylinkit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
erase_options = ['sensor', 'system', 'all', 'als', 'ph', 'rtd', 'cdt', 'axl', 'pressure']
dumpd_options = ['system', 'gnss', 'als', 'ph', 'rtd', 'cdt', 'axl', 'pressure']
scalw_options = ['cdt', 'ph', 'rtd', 'mcp47x6']
scalr_options = ['cdt']
resetv_options = {'tx_counter': 1, 'rx_counter': 3, 'rx_time': 4}
modulation_options = {'A2':0, 'A3': 1, 'A4': 2}

Expand Down Expand Up @@ -36,7 +37,8 @@
parser.add_argument('--argossize', type=int, default=15, required=False, help='Packet size in bytes')
parser.add_argument('--argostcxo', type=int, default=5, required=False, help='TCXO warm-up in seconds')
parser.add_argument('--argospower', type=int, default=350, required=False, help='TX power in mW')
parser.add_argument('--scalw', type=str, choices=scalw_options, required=False, help='Run a calibration command')
parser.add_argument('--scalw', type=str, choices=scalw_options, required=False, help='Run a calibration write command')
parser.add_argument('--scalr', type=str, choices=scalr_options, required=False, help='Run a calibration read command')
parser.add_argument('--command', type=int, required=False, help='Calibration command number')
parser.add_argument('--value', type=float, default=0, required=False, help='Calibration command value')
parser.add_argument('--ano', type=argparse.FileType('rb'), required=False, help='GNSS AssistNow Offline filename')
Expand Down Expand Up @@ -141,11 +143,13 @@ def main():
cdt::
--scalw cdt --command 0 ; to reset existing CDT calibration
--scalw cdt --command 1 --value 200000 ; to measure and compute gain factor for 200K
--scalw cdt --command 2 --value xxxx ; to override CA polynomial coefficient
--scalw cdt --command 3 --value xxxx ; to override CB polynomial coefficient
--scalw cdt --command 4 --value xxxx ; to override CC polynomial coefficient
--scalw cdt --command 5 ; to save all CDT calibration values to filesystem
--scalw cdt --command 6 --value xxxx ; set gain factor calibration value
--scalw cdt --command 7 --value xxxx; power on and configure AD9533 for sweep @ frequency xxxx
--scalw cdt --command 8 ; power off AD9533
ph::
Expand Down Expand Up @@ -174,6 +178,25 @@ def main():
return
dev.scalw(args.scalw, args.command, args.value)

if args.scalr:
if args.command is None:
print("""
Calibration requires a command. Use --command to provide a command:
cdt::
--scalr cdt --command 0 ; read CA polynomial coefficient
--scalr cdt --command 1 ; read CB polynomial coefficient
--scalr cdt --command 2 ; read CC polynomial coefficient
--scalr cdt --command 3 ; read gain factor
--scalr cdt --command 4 ; read AD5933 raw sensor real value
--scalr cdt --command 5 ; read AD5933 raw sensor imaginary value
--scalr cdt --command 6 ; read impedence value using stored calibrated gain factor
; note: must use --scalw --command 6 --value xxx first
""")
return
print(dev.scalr(args.scalr, args.command))

if args.argostx:
dev.argostx(args.argosmod, args.argospower, args.argosfreq, args.argossize, args.argostcxo)

Expand Down
11 changes: 11 additions & 0 deletions pylinkit/dte.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ def scalw(self, sensor, step, value):
resp = self._nus.send(self._encode_command('SCALW', args=[str(sensor_d[sensor]), str(step), str(value)]))
self._decode_response(resp)

def scalr(self, sensor, step):
sensor_d = {'axl': 0,
'pressure': 1,
'als': 2,
'ph': 3,
'rtd': 4,
'cdt': 5,
'mcp47x6': 6 }
resp = self._nus.send(self._encode_command('SCALR', args=[str(sensor_d[sensor]), str(step)]))
return self._decode_response(resp)

def argostx(self, mod, power, freq, size, tcxo):
mod_d = {'A2': 0,
'A3': 1,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='pylinkit',
version='3.4.0',
version='3.4.1',
description='Python LinkIt BLE configuration tool',
author='Liam Wickins',
author_email='[email protected]',
Expand Down

0 comments on commit 8560540

Please sign in to comment.