Repository navigation
Open
Description
Hi .. I am running PPK2 GUI and it works as expected .
trying to automate the current consumption measurement using ppk2-api but after few samples I get unrealistic measurements .
I know nothing is wrong with the connections as I get the expected measurement from PPK2 GUI .
My tests takes a long(ish) time as I want to measure consumption as different states .
I notice after ~ 20 minutes the samples looks unrealistic giving ~ 933333333 mA .
I set delay_between_samples_in_sec to 1 sec .
measurment logic runs in a thread and prints samples
def _measurement_logic(self):
while True and not self.stop_thread:
if self.ongoing_capture:
read_data = self.ppk2_device.get_data()
if read_data != b"":
samples, _ = self.ppk2_device.get_samples(read_data)
self.stored_current_samples += samples
print(f"Average of {len(samples)} samples is: {sum(samples) / len(samples)}uA")
time.sleep(self.delay_between_samples_in_sec)
Script I run to automate measurement - I save all the samples in a csv file to post process it later
if __name__ == "__main__":
voltage = "3750" # in mV
nordic_ppk2 = PPK2(source_voltage_in_mV=voltage)
nordic_ppk2.initialize_ppk2()
nordic_ppk2.set_ppk2_power_state_on()
time.sleep(50)
csv_file_name = nordic_ppk2.start_capture(file_prefix="1st_run")
time.sleep(600)
nordic_ppk2.stop_capture()
print(f"Generated file: {csv_file_name}")
df = pd.read_csv(csv_file_name)
# FINDING AVG,MAX AND MIN
maximum = float(df.iloc[:,1].max())/1000
minimum = float(df.iloc[:,1].min())/1000
average = float(df.iloc[:,1].mean())/1000
print(f'file = {csv_file_name} \n'
f'Average = {average} mA\n'
f'Maximum = {maximum} mA\n'
f'Minimum = {minimum} mA\n')
time.sleep(10)
csv_file_name = nordic_ppk2.start_capture(file_prefix="2nd_run")
time.sleep(600)
nordic_ppk2.stop_capture()
print(f"Generated file: {csv_file_name}")
df = pd.read_csv(csv_file_name)
# FINDING AVG,MAX AND MIN
maximum = float(df.iloc[:,1].max())/1000
minimum = float(df.iloc[:,1].min())/1000
average = float(df.iloc[:,1].mean())/1000
print(f'file = {csv_file_name} \n'
f'Average = {average} mA\n'
f'Maximum = {maximum} mA\n'
f'Minimum = {minimum} mA\n')
time.sleep(10)
nordic_ppk2.set_ppk2_power_state_off()
nordic_ppk2.terminate_ppk2()
Unrealistic output that I get after sometime
Average of 255 samples is: 201.08003375301806uA
Average of 255 samples is: 9180480.471826369uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9433153.33932497uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9610732.127517093uA
Average of 255 samples is: 9433715.411266329uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9530250.845644489uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430043.706021905uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9543359.397351908uA
Average of 255 samples is: 9433184.076690257uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499032.128314802uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499021.454707844uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9464867.022682201uA
Average of 255 samples is: 9528133.342755748uA
Average of 255 samples is: 9429927.242173648uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9562305.30156186uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9492217.184726877uA
Average of 255 samples is: 9498870.427615838uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9441757.668911548uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9450267.254938764uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499020.710508693uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9492365.621076312uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9431206.030643925uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430046.134434432uA
Average of 255 samples is: 9499029.582258144uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9442397.463163968uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430038.49626446uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9561069.033534253uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9519729.856048381uA
Average of 255 samples is: 9460137.32903363uA
Average of 255 samples is: 9532202.159327868uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9498821.900509326uA
Average of 255 samples is: 9430018.578808472uA
Average of 255 samples is: 9499020.710508693uA
Average of 255 samples is: 9440338.992101854uA
Average of 255 samples is: 9499021.454707842uA
Average of 255 samples is: 9438480.773886917uA
Average of 255 samples is: 9552899.290645674uA
Average of 255 samples is: 9430109.921257356uA
Average of 255 samples is: 9499014.443456272uA
Average of 255 samples is: 9430018.578808472uA
Metadata
Metadata
Assignees
Labels
No labels
Activity
NejcKle commentedon Jun 18, 2024
Hello @RehabAbdAllah
Please try the suggestion posted here: #36 (comment)
Please report your findings.
RehabAbdAllah commentedon Jun 19, 2024
Hi @NejcKle
Thank you for your reply .
I used the suggested fix .
but I see a gradual increase to the total samples because the read samples are again unrealistic after a certain amount of time .
I cannot add all the samples but this are the samples after 12 seconds and after 599 seconds.
After 12 seconds
After 599 seconds
wlgrd commentedon Jul 3, 2024
Have you tried with the official software and confirmed that is behaving correctly?
RehabAbdAllah commentedon Jul 3, 2024
yes it works fine on GUI application on my Mac and the python scripts works well on Raspberry pi .
I can only see this problem with python scripts on Mac M1 .
I am asumming it is something to do with the USB ports on Mac but I am not sure .
for now I am using RPI to measure the current consumption with PPK2 .
wlgrd commentedon Oct 14, 2024
Weird. Have you tried with the latest firmware?
bradanlane commentedon Apr 19, 2025
I encountered this issue. Here are some data points which may help:
start_measuring()and onestop_measuring())get_data()andget_samples()get_samples()always returns 255The problem can occur at most anytime within the 60 seconds but most often happens after the test hardware has entered sleep mode.
When using Nordic Power Profiler, the test completes without incident.
FYI: Scanning for the PPK2 does not work as the serial ports created on MacOS are formatted as
/dev/cu.usbmodem<SerialNumber>2and/dev/cu.usbmodem<SerialNumber>4. using the port string directly in the PPK2-API constructor works.UPDATE: running a test of my same python code within a linux VM on the same Mac Apple Silicon and there have been no errors after more than 100 tests.
MrKevinWeiss commentedon Mar 13, 2026
So can we conclude it is some interaction with the MacOS? Unfortunately, I do not have access to a mac so it would be hard to reproduce and debug this problem.
fix(get_samples): stop byte-framing desync on sub-word serial reads