Floating point operation fixed - previous calculation result type was integer.
This commit is contained in:
parent
267ce2b3a4
commit
753d91457a
1 changed files with 5 additions and 4 deletions
|
@ -8,6 +8,7 @@ import serial
|
|||
import copy
|
||||
import binascii
|
||||
import matplotlib.pyplot as plt
|
||||
import math
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -488,7 +489,7 @@ if __name__ == "__main__":
|
|||
meas_r = []
|
||||
meas_p = []
|
||||
|
||||
i = ((drive_str + 1) * 2) / 1000
|
||||
i = ((drive_str + 1) * 2.0) / 1000.0
|
||||
|
||||
if args.output_file != None or args.show_graph == True:
|
||||
for m in meas_data:
|
||||
|
@ -503,12 +504,12 @@ if __name__ == "__main__":
|
|||
meas_ratio.append(1)
|
||||
|
||||
# R = meas_data[0] * 5V / 1023 * I
|
||||
r = (m[1] * 5 / 1023) / i
|
||||
r = (m[1] * 5.0 / 1023.0) / i
|
||||
meas_r.append(r)
|
||||
|
||||
# P = meas_data[0] * 5V ^ 2 / r
|
||||
if r > 0:
|
||||
meas_p.append(i**2 * r)
|
||||
meas_p.append(math.pow(i, 2) * r)
|
||||
else:
|
||||
meas_p.append(0)
|
||||
|
||||
|
@ -519,8 +520,8 @@ if __name__ == "__main__":
|
|||
plt.plot(meas_freq, meas_ratio)
|
||||
plt.plot(meas_freq, meas_r)
|
||||
plt.plot(meas_freq, meas_p)
|
||||
print meas_r
|
||||
|
||||
print meas_ratio
|
||||
print "Please close the mathplot window to exit..."
|
||||
plt.show()
|
||||
|
||||
|
|
Loading…
Reference in a new issue