From a7f4aad8071b2a968161939b46eac934b562d055 Mon Sep 17 00:00:00 2001 From: Aren Leishman Date: Mon, 13 Jan 2025 20:02:01 +0800 Subject: [PATCH 1/3] Replace voltage calculation with bit manipulation from js source --- src/ppk2_api/ppk2_api.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/ppk2_api/ppk2_api.py b/src/ppk2_api/ppk2_api.py index 4b39a69..dccfa84 100644 --- a/src/ppk2_api/ppk2_api.py +++ b/src/ppk2_api/ppk2_api.py @@ -134,18 +134,8 @@ def _convert_source_voltage(self, mV): if mV > self.vdd_high: mV = self.vdd_high - offset = 32 - # get difference to baseline (the baseline is 800mV but the initial offset is 32) - diff_to_baseline = mV - self.vdd_low + offset - base_b_1 = 3 - base_b_2 = 0 # is actually 32 - compensated with above offset - - # get the number of times we have to increase the first byte of the command - ratio = int(diff_to_baseline / 256) - remainder = diff_to_baseline % 256 # get the remainder for byte 2 - - set_b_1 = base_b_1 + ratio - set_b_2 = base_b_2 + remainder + set_b_1 = mV >> 8 + set_b_2 = mV & 0xFF return set_b_1, set_b_2 From d4a45da6e68d2476fbdf490e2c69a6b73bc607e3 Mon Sep 17 00:00:00 2001 From: Aren Leishman Date: Sun, 23 Mar 2025 00:29:31 +0800 Subject: [PATCH 2/3] Update ppk2_api.py Don't reset device on deconstruction of the connection --- src/ppk2_api/ppk2_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ppk2_api/ppk2_api.py b/src/ppk2_api/ppk2_api.py index dccfa84..54b8ef5 100644 --- a/src/ppk2_api/ppk2_api.py +++ b/src/ppk2_api/ppk2_api.py @@ -99,7 +99,7 @@ def __del__(self): """Destructor""" try: # reset device - self._write_serial((PPK2_Command.RESET,)) + #self._write_serial((PPK2_Command.RESET,)) if self.ser: self.ser.close() From 9f41f72efd09e59b0aae97cd919e468129388dbd Mon Sep 17 00:00:00 2001 From: Aren Leishman Date: Sun, 23 Mar 2025 00:30:32 +0800 Subject: [PATCH 3/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ed0e941..ad34df9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +Modified for embedded testing + ## Description The new Nordic Semiconductor's [Power Profiler Kit II (PPK 2)](https://www.nordicsemi.com/Software-and-tools/Development-Tools/Power-Profiler-Kit-2) is very useful for real time measurement of device power consumption. The official [nRF Connect Power Profiler tool](https://github.com/NordicSemiconductor/pc-nrfconnect-ppk) provides a friendly GUI with real-time data display. However there is no support for automated power monitoring. The puropose of this Python API is to enable automated power monitoring and data logging in Python applications.