Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPK2 gives unrealistic measurments after some time #45

Open
RehabAbdAllah opened this issue Jun 18, 2024 · 5 comments
Open

PPK2 gives unrealistic measurments after some time #45

RehabAbdAllah opened this issue Jun 18, 2024 · 5 comments

Comments

@RehabAbdAllah
Copy link

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
@NejcKle
Copy link
Collaborator

NejcKle commented Jun 18, 2024

Hello @RehabAbdAllah
Please try the suggestion posted here: #36 (comment)

Please report your findings.

@RehabAbdAllah
Copy link
Author

RehabAbdAllah commented 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

Average of 10000 samples is: 1.0613972225712949mA
[12.643112897872925]Average current: 2.5463548116633516mA
[12.648344993591309]Average current: 2.5463548116633516mA
[12.653423070907593]Average current: 2.5463548116633516mA
[12.658760070800781]Average current: 2.5463548116633516mA
[12.663992881774902]Average current: 2.5463548116633516mA
[12.669111013412476]Average current: 2.5463548116633516mA
[12.674423933029175]Average current: 2.5463548116633516mA
[12.67964792251587]Average current: 2.5463548116633516mA
[12.685637950897217]Average current: 2.5463548116633516mA
[12.691624879837036]Average current: 2.5463548116633516mA
[12.698649883270264]Average current: 2.5463548116633516mA
[12.704917907714844]Average current: 2.5463548116633516mA
[12.710555076599121]Average current: 2.5463548116633516mA
[12.71591591835022]Average current: 2.5463548116633516mA
[12.725473880767822]Average current: 2.5463548116633516mA
[12.744505882263184]Average current: 2.5463548116633516mA
[12.756057024002075]Average current: 2.5463548116633516mA
Average of 10000 samples is: 0.8791979206356576mA
[12.769118785858154]Average current: 2.533227592048855mA
[12.77507996559143]Average current: 2.533227592048855mA
[12.780687093734741]Average current: 2.533227592048855mA
[12.786417007446289]Average current: 2.533227592048855mA
[12.791770935058594]Average current: 2.533227592048855mA
[12.797851085662842]Average current: 2.533227592048855mA
[12.803261756896973]Average current: 2.533227592048855mA
[12.810301065444946]Average current: 2.533227592048855mA
[12.822291851043701]Average current: 2.533227592048855mA
[12.831923961639404]Average current: 2.533227592048855mA
[12.842575073242188]Average current: 2.533227592048855mA
Average of 10000 samples is: 1.0778059890655785mA

After 599 seconds

[599.2935330867767]Average current: 7164.5617474398705mA
[599.3699128627777]Average current: 7167.4175782322545mA
[599.4410929679871]Average current: 7167.4175782322545mA
[599.5158860683441]Average current: 7167.4175782322545mA
[599.5906610488892]Average current: 7167.4175782322545mA
[599.6636469364166]Average current: 7167.4175782322545mA
Average of 10000 samples is: 6816.917575591368mA
[599.7597930431366]Average current: 7167.266500644936mA
[599.8310089111328]Average current: 7167.266500644936mA
[599.903904914856]Average current: 7167.266500644936mA
[599.9753179550171]Average current: 7167.266500644936m

@wlgrd
Copy link
Collaborator

wlgrd commented Jul 3, 2024

Have you tried with the official software and confirmed that is behaving correctly?

@RehabAbdAllah
Copy link
Author

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
Copy link
Collaborator

wlgrd commented Oct 14, 2024

Weird. Have you tried with the latest firmware?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants