Guest User

Untitled

a guest
Jan 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import numpy as np
  3.  
  4.  
  5. '''
  6. B is not a strictly constant alway the time
  7. Generally we define B constant as an ratio at 298.15K and 323.15K
  8.  
  9.  
  10. \ ln(R1) - ln(R2) /
  11. B = -------------------
  12. / 1 1 \
  13. | -- - -- |
  14. \ T1 T2 /
  15. '''
  16. # specification of NTC
  17. B = 3434
  18. T0 = 273.15 # zero degree
  19. r0 = 30 # resistence when zero deree
  20.  
  21.  
  22. # how big should be the look up table
  23. r1_begin = 0.01 # -20 C
  24. r1_end = r0 * 3 # 125 C
  25. r1_step = 0.5
  26.  
  27. # write to header file
  28. with open("Ntc_LUT.h", "a") as f:
  29. print('/* LookUpTable below are auto-generated!!! */', file=f)
  30. written = 0
  31. for r1 in np.arange(r1_begin, r1_end, r1_step):
  32. T1 = B / (B/T0-(np.log(r0)-np.log(r1)))
  33. if written % 8 == 7:
  34. print (int(T1), file=f)
  35. else:
  36. print (int(T1), end='', file=f)
  37. print (',', end='', file=f)
  38. written += 1
Add Comment
Please, Sign In to add comment