Rev 3492 Rev 3498
Line 16... Line 16...
16 #### Sensor Configuration ########################################### 16 #### Sensor Configuration ###########################################
17   17  
18 cfg = config.Config( 18 cfg = config.Config(
19 port = port, 19 port = port,
20 bus = [ 20 bus = [
21 { -  
22 "name": "counter", 21 { "name":"counter", "type":"acount02"},
23 "type": "acount02", 22 { "name":"clkgen", "type":"clkgen01"},
24 }, -  
25 ], 23 ],
26 ) 24 )
27 cfg.initialize() 25 cfg.initialize()
28   26  
29 print "Frequency counter readout example \r\n" 27 print "Frequency counter readout example \r\n"
30 fcount = cfg.get_device("counter") 28 fcount = cfg.get_device("counter")
-   29 fgen = cfg.get_device("clkgen")
31 time.sleep(0.5) 30 time.sleep(0.5)
32 frequency = fcount.get_freq() 31 frequency = fcount.get_freq()
-   32 rfreq = fgen.get_rfreq()
-   33 hsdiv = fgen.get_hs_div()
-   34 n1 = fgen.get_n1_div()
-   35 fdco = 0
-   36 fxtal = 0
-   37  
-   38 fgen.set_rfreq(0x2D1E127AD)
-   39 fgen.set_hs_div(4)
-   40 fgen.set_n1_div(8)
33   41  
34 #### Data Logging ################################################### 42 #### Data Logging ###################################################
35   43  
36 try: 44 try:
37 with open("temperature.log", "a") as f: 45 with open("temperature.log", "a") as f:
Line 39... Line 47...
39 now = datetime.datetime.now() 47 now = datetime.datetime.now()
40 if (now.second == 15) or (now.second == 35) or (now.second == 55): 48 if (now.second == 15) or (now.second == 35) or (now.second == 55):
41 frequency = fcount.get_freq() 49 frequency = fcount.get_freq()
42 now = datetime.datetime.now() 50 now = datetime.datetime.now()
43   51  
-   52 rfreq = fgen.get_rfreq()
-   53 hsdiv = fgen.get_hs_div()
-   54 n1 = fgen.get_n1_div()
-   55 fdco = (frequency/1000000) * hsdiv * n1
-   56 fxtal = fdco / rfreq
-   57  
44 sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second) + "\r") 58 sys.stdout.write("frequency: " + str(frequency) + " Hz Time: " + str(now.second))
-   59 sys.stdout.write(" RFREQ: " + str(rfreq) + " HSDIV: " + str(hsdiv) + " N1: " + str(n1))
-   60 sys.stdout.write(" fdco: " + str(fdco) + " fxtal: " + str(fxtal) + "\r\n")
45 f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency)) 61 f.write("%d\t%s\t%.3f\n" % (time.time(), datetime.datetime.now().isoformat(), frequency))
46   62  
47 sys.stdout.flush() 63 sys.stdout.flush()
48 time.sleep(1) 64 time.sleep(1)
49 except KeyboardInterrupt: 65 except KeyboardInterrupt: