Close

Log 3: A Simple Example

A project log for Electronics Power and Energy Modeling Tool

Python tools for predicting a design's power consumption over time. Support for battery models and energy harvesting such as solar power.

jake-wachlinJake Wachlin 01/29/2022 at 21:580 Comments

The code snippets below provide a complete example. First, we must define the threads and their components and rated power.

accel_thread = epm.Thread(name="Accelerometer Sampling", stages=[
        epm.Stage(delta_t_sec=0.5,components=[
            epm.Component(name="ESP32",mode_name="Active",current_ma=100.0),
            epm.Component(name="Accelerometer",mode_name="Active",current_ma=1.5)
        ]),
        epm.Stage(delta_t_sec=20.0,components=[
            epm.Component(name="ESP32",mode_name="Sleep",current_ma=0.05),
            epm.Component(name="Accelerometer",mode_name="Sleep",current_ma=0.001)
        ])
    ])

led_thread = epm.Thread(name="LED", stages=[
        epm.Stage(delta_t_sec=0.1,components=[
            epm.Component(name="LED",mode_name="On",current_ma=5.0)
        ]),
        epm.Stage(delta_t_sec=4.9,components=[
            epm.Component(name="LED",mode_name="Off",current_ma=0.0)
        ])
    ])

Next, we build the system, with its threads, battery, and energy harvesting. Finally, we calculate the power profile for 3 days while saving the outputs. By default, total net energy will be reported but time histories are not.

this_sys = epm.EmbeddedSystem(name="Test", threads=[accel_thread,led_thread], 
        energy_storage=epm.LithiumBattery(number_cells=1,capacity_mAh=1000.0,current_charge_mAh=500.0,internal_resistance_ohm=0.065),
        voltage_reg=epm.VoltageRegulator(efficiency=0.8),nominal_voltage=3.3,
        energy_harvesting=epm.SolarPanel(rated_power_W=1.5,t_offset_sec=0.0))

    
this_sys.power_profile(3*86400.0, True)

That's it!

Discussions