/Designs/Measuring_instruments/RMDS01C/SW/Host_controller/frequency_log.py
26,33 → 26,27
)
cfg.initialize()
 
print "LTS01 temperature sensor module example \r\n"
print "Temperature Humidity[%%] \r\n"
print "Frequency counter readout example \r\n"
fcount = cfg.get_device("counter")
time.sleep(0.5)
frequency = fcount.get_freq()
 
#### Data Logging ###################################################
 
tune = 143050000
set_freq = 10000000
 
try:
while True:
now = datetime.datetime.now()
if (now.second == 15) or (now.second == 35) or (now.second == 55):
frequency = fcount.get_freq()
f = open('/sys/bus/i2c/devices/7-0055/frequency', 'a', buffering = 0)
# set_freq = set_freq + (tune - frequency)
with open("temperature.log", "a") as f:
while True:
now = datetime.datetime.now()
if (now.second == 15) or (now.second == 35) or (now.second == 55):
frequency = fcount.get_freq()
now = datetime.datetime.now()
 
if (tune > frequency):
set_freq = set_freq + 1
else: set_freq = set_freq - 1
f.write(str(int(set_freq)))
sys.stdout.write("frequency:" + str(frequency) + "\r\n")
f.close()
sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second) + "\r")
f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency))
 
sys.stdout.write("Time:" + str(now.second) + "\r\n")
sys.stdout.flush()
time.sleep(1)
sys.stdout.flush()
time.sleep(1)
except KeyboardInterrupt:
sys.stdout.write("\r\n")
sys.exit(0)
f.close()
/Designs/Measuring_instruments/RMDS01C/SW/Host_controller/plot.gp
0,0 → 1,12
set terminal png size 800,640
 
set output "Frequency_time.png"
set xdata time
set timefmt "%s"
set format x "%H:%M:%S"
set key under
set xlabel "Time"
set ylabel "Freq deviation [Hz]"
f0=140000000
plot "temperature.log" using 1:($3-f0) with linespoints title "CLKGEN01B 140 MHz"