Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unaccurate measurments vs nrf connect #53

Copy link
Copy link

Description

@klaudiawro
Issue body actions

Hello i am using the API for an automated production script, one of the steps is measuring power consumption, the API works as intended maybe 50% of the time, the other times it returns values that are very low (0.03 - 0.08 mA) compared to what it should be (around 2.7mA) when the same pcb is measured with nrf connect the correct value is disaplayed, this is the code that is used:

def connect_ppk2_mp():
    stem.usb.setPortEnable(USBHubPort.PPK2)
    ppk2s_connected = PPK2_API.list_devices()
    global ppk2_test

    if len(ppk2s_connected) == 1:
        ppk2_port = ppk2s_connected[0][0]
        ppk2_serial = ppk2s_connected[0][1]
    else:
        print(f"error: none.or.too.many.connected.PPK2: {ppk2s_connected}")
        sys.exit(1)

    ppk2_test = PPK2_API(ppk2_port, exclusive=True)
    
    ppk2_test.ser.reset_input_buffer()
    ppk2_test.ser.reset_output_buffer()
    sleep(0.1)

    ppk2_test.get_modifiers()
    ppk2_test.use_source_meter()
    ppk2_test.set_source_voltage(3000)
    ppk2_test.toggle_DUT_power('ON')
    
    sleep(0.1)
    ppk2_ready_event.set()

def measure_current_ppk2_mp(seconds):
    all_samples = []
    start_time = time.time()

    # Clear buffer to ensure fresh data
    ppk2_test.get_data()
    sleep(0.1)

    # Start measuring and allow stabilization
    ppk2_test.start_measuring()
    time.sleep(0.2)

    end_time = start_time + float(seconds)

    while time.time() < end_time:
        read_data = ppk2_test.get_data()
        if read_data:
            samples, _ = ppk2_test.get_samples(read_data)
            all_samples.extend(samples)  # Keep all data (no [::100] filtering)

    ppk2_test.stop_measuring()

    if all_samples:
        average = sum(all_samples) / len(all_samples)
        print(len(all_samples))
        print(f"{average:.6f} mA")
        return f"{average:.6f}"

    print("error: current measuring failed")
    return "0.000000"

For the record, i am using the PPK2_MP version

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.