/Designs/Measuring_instruments/RMDS01C/SW/Host_controller/frequency_log.py
18,10 → 18,8
cfg = config.Config(
port = port,
bus = [
{
"name": "counter",
"type": "acount02",
},
{ "name":"counter", "type":"acount02"},
{ "name":"clkgen", "type":"clkgen01"},
],
)
cfg.initialize()
28,9 → 26,19
 
print "Frequency counter readout example \r\n"
fcount = cfg.get_device("counter")
fgen = cfg.get_device("clkgen")
time.sleep(0.5)
frequency = fcount.get_freq()
rfreq = fgen.get_rfreq()
hsdiv = fgen.get_hs_div()
n1 = fgen.get_n1_div()
fdco = 0
fxtal = 0
 
fgen.set_rfreq(0x2D1E127AD)
fgen.set_hs_div(4)
fgen.set_n1_div(8)
 
#### Data Logging ###################################################
 
try:
41,7 → 49,15
frequency = fcount.get_freq()
now = datetime.datetime.now()
 
sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second) + "\r")
rfreq = fgen.get_rfreq()
hsdiv = fgen.get_hs_div()
n1 = fgen.get_n1_div()
fdco = (frequency/1000000) * hsdiv * n1
fxtal = fdco / rfreq
 
sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second))
sys.stdout.write(" RFREQ: " + str(rfreq) + " HSDIV: " + str(hsdiv) + " N1: " + str(n1))
sys.stdout.write(" fdco: " + str(fdco) + " fxtal: " + str(fxtal) + "\r\n")
f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency))
 
sys.stdout.flush()