You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dmi.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import SoapySDR
  2. import numpy as np
  3. import gc
  4. from noptica import *
  5. def main():
  6. # For this PoC code, a small memory leak is less harmful than random overflows.
  7. gc.disable()
  8. freq_sample = 5e6
  9. freq_base = 1086e6
  10. bufsize = 4096
  11. induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
  12. induction.start()
  13. try:
  14. stabilizer = Stabilizer(freq_sample, 0.4, 1088.1e6 - freq_base, 50e-6, induction)
  15. position_tracker = PositionTracker(int(0.1*freq_sample/bufsize))
  16. sdr = SoapySDR.Device()
  17. for channel in range(2):
  18. sdr.setSampleRate(SoapySDR.SOAPY_SDR_RX, channel, freq_sample)
  19. sdr.setFrequency(SoapySDR.SOAPY_SDR_RX, channel, freq_base)
  20. buf_sdr = BufferedSDR(sdr, [0, 1], bufsize, 256)
  21. buf_sdr.start()
  22. try:
  23. stabilizer_throttle = 0
  24. while True:
  25. buffers = buf_sdr.get()
  26. try:
  27. samples_ref, samples_meas = buffers
  28. # We can't update faster than the MHS5200A serial interface
  29. stabilizer_throttle += 1
  30. if stabilizer_throttle == 40:
  31. stabilizer.input(samples_ref)
  32. stabilizer_throttle = 0
  33. position, leakage = position_tracker.input(samples_ref, samples_meas)
  34. print(np.sum(position)/len(position), leakage)
  35. finally:
  36. buf_sdr.dispose(buffers)
  37. finally:
  38. buf_sdr.stop()
  39. finally:
  40. induction.stop()
  41. if __name__ == "__main__":
  42. main()