diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-04 09:16:17 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-04 09:16:17 +0100 |
commit | 33de86bdad4e0fcf7064aa8b346c23dbca4049ad (patch) | |
tree | ccc88c28bcb39b26df8b9979c205d24f753ce329 /bin | |
parent | bac876794c0b162014beb841f21c5b62f9298091 (diff) |
switch to integer energytrace-util output
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/msp430-etv | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/bin/msp430-etv b/bin/msp430-etv index 206a7c2..b4f1b89 100755 --- a/bin/msp430-etv +++ b/bin/msp430-etv @@ -180,19 +180,21 @@ if __name__ == '__main__': timestamp, current, voltage, total_energy = map(float, line.split(' ')) data[i - opt['skip']] = [timestamp, current, voltage, total_energy] - m_duration = data[-1, 0] - data[0, 0] - m_energy = data[-1, 3] - data[0, 3] - m_calc_energy = np.sum(data[1:, 1] * data[1:, 2] * (data[1:, 0] - data[:-1, 0])) - m_energy_deviation = np.abs(m_energy - m_calc_energy) / np.max([m_energy, m_calc_energy]) + m_duration_us = data[-1, 0] - data[0, 0] + m_energy_nj = data[-1, 3] - data[0, 3] + # mV * nA * us = aJ (1e-18 J) -> use factor 1e-6 to get pJ (1e-12 J) + m_calc_energy_pj = np.sum(data[1:, 1] * data[1:, 2] * 1e-6 * (data[1:, 0] - data[:-1, 0])) + m_energy_nj_deviation = np.abs(m_energy_nj - m_calc_energy_pj * 1e-3) / np.max([m_energy_nj, m_calc_energy_pj * 1e-3]) print('{:d} measurements in {:.2f} s = {:.0f} Hz sample rate'.format( - data_count, m_duration, data_count / m_duration)) + data_count, m_duration_us * 1e-6, data_count / (m_duration_us * 1e-6))) - print('Reported energy: E = {:f} J'.format(m_energy)) - print('Calculated energy: U*I*t = {:f} J'.format(m_calc_energy)) - print('Energy deviation: {:.1f}%'.format(m_energy_deviation * 100)) + print('Reported energy: E = {:f} J'.format(m_energy_nj * 1e-9)) + print('Calculated energy: U*I*t = {:f} J'.format(m_calc_energy_pj * 1e-12)) + print('Energy deviation: {:.1f}%'.format(m_energy_nj_deviation * 100)) - power = data[:, 1] * data[:, 2] + # nA * mV = pW + power = data[:, 1] * data[:, 2] * 1e-12 if 'threshold-peakcount' in opt: bs_mean = np.mean(power) @@ -273,11 +275,12 @@ if __name__ == '__main__': print('Mean voltage: {:.2f} V : {:.9f}'.format(mean_voltage, mean_voltage)) print('Mean current: {:.0f} µA : {:.9f}'.format(mean_current * 1e6, mean_current)) print('Mean power: {:.0f} µW : {:.9f}'.format(mean_power * 1e6, mean_power)) - print('Total energy: {:f} J : {:.9f}'.format(m_energy, m_energy)) + print('Total energy: {:f} J : {:.9f}'.format(m_energy_nj, m_energy_nj)) if 'plot' in opt: - pwrhandle, = plt.plot(data[:, 0], data[:, 1] * data[:, 2], 'b-', label='U*I', markersize=1) - #energyhandle, = plt.plot(data[1:, 0], (data[1:, 3] - data[:-1, 3]) / (data[1:, 0] - data[:-1, 0]), 'r-', label='E/Δt', markersize=1) + # nA * mV = pW + pwrhandle, = plt.plot(data[:, 0], data[:, 1] * data[:, 2] * 1e-12, 'b-', label='U*I', markersize=1) + energyhandle, = plt.plot(data[1:, 0], ((data[1:, 3] - data[:-1, 3]) * 1e-9) / ((data[1:, 0] - data[:-1, 0]) * 1e-6), 'r-', label='E/Δt', markersize=1) plt.legend(handles=[pwrhandle]) plt.xlabel('Time [s]') plt.ylabel('Power [W]') |