Advertisement
Guest User

FE5680A logging script example, Fabio Eboli

a guest
May 24th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. #FE5680A Logging example, Fabio Eboli
  2.  
  3. from FE5680A import*
  4. import time
  5.  
  6. logfile=open("log_FE5680_adc_dds.txt",'wb')
  7.  
  8. beginning=time.time()
  9. logfile.write("Elapsed s,Sample #,CH1 ,CH2 ,CH3 ,CH4 ,DDS1 ,DDS2,DDSF1,DDSF2\r\n")
  10. numcampioni=0
  11.  
  12. p=SetPort(8)
  13.  
  14. while 1:
  15.     try:
  16.         T=time.time()
  17.         T1=T
  18.         adc=GetADC(p)
  19.         dds=GetDDS(p)
  20.         numcampioni=numcampioni+1
  21.         print("Elapsed: "+format(time.time()-beginning,".3f")+"; Samples: "+str(numcampioni))
  22.         print("ADC CH1="+str(adc[0]))
  23.         print("ADC CH2="+str(adc[1]))
  24.         print("ADC CH3="+str(adc[2]))
  25.         print("ADC CH4="+str(adc[3]))
  26.         print("DDS1="+str(dds[0]))
  27.         print("DDS2="+str(dds[1]))
  28.         print("DDS1 Freq="+str(dds[2]))
  29.         print("DDS2 Freq="+str(dds[3]))
  30.         logfile.write(format(time.time()-beginning,".3f")+","+str(numcampioni)+\
  31.                       ","+str(adc[0])+","+str(adc[1])+\
  32.                       ","+str(adc[2])+","+str(adc[3])+\
  33.                       ","+str(dds[0])+","+str(dds[1])+\
  34.                       ","+str(dds[2])+","+str(dds[3])+"\r\n")
  35.         logfile.flush()
  36.  
  37.         time.sleep(20)
  38.  
  39.     except KeyboardInterrupt:
  40.         logfile.close()
  41.         exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement