Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import numpy as np
- '''
- B is not a strictly constant alway the time
- Generally we define B constant as an ratio at 298.15K and 323.15K
- \ ln(R1) - ln(R2) /
- B = -------------------
- / 1 1 \
- | -- - -- |
- \ T1 T2 /
- '''
- # specification of NTC
- B = 3434
- T0 = 273.15 # zero degree
- r0 = 30 # resistence when zero deree
- # how big should be the look up table
- r1_begin = 0.01 # -20 C
- r1_end = r0 * 3 # 125 C
- r1_step = 0.5
- # write to header file
- with open("Ntc_LUT.h", "a") as f:
- print('/* LookUpTable below are auto-generated!!! */', file=f)
- written = 0
- for r1 in np.arange(r1_begin, r1_end, r1_step):
- T1 = B / (B/T0-(np.log(r0)-np.log(r1)))
- if written % 8 == 7:
- print (int(T1), file=f)
- else:
- print (int(T1), end='', file=f)
- print (',', end='', file=f)
- written += 1
Add Comment
Please, Sign In to add comment