DeaD_EyE

calculation of distances for a FMCW Radar

Jan 31st, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. """
  2. Calculation of the distances for a FMCW Radar
  3.  
  4. http://radartutorial.de/02.basics/Frequency%20Modulated%20Continuous%20Wave%20Radar.en.html
  5.  
  6. R = (c0 · |Δf|) / (2 · (df/dt))
  7.  
  8.  
  9. Condition
  10. =========
  11. A chirp has the length of the window_size
  12. """
  13.  
  14. def radar_range(sampling_rate, bandwidth, window_size):
  15.     delta_t = 1 / sampling_rate * window_size
  16.     chirp = bandwidth / delta_t
  17.     dist = lambda fB: (3e8 * fB) / (2 * chirp)
  18.     return [round(dist(sampling_rate / window_size * n), 2) for n in range(window_size // 2 + 1)]
  19.  
  20.  
  21. def radar_range_simple(bandwidth, window_size):
  22.     dist_step = 3e8 / bandwidth / 2
  23.     return [round(dist_step * n, 2) for n in range(window_size // 2 + 1)]
  24.  
  25. low_sampling_rate  = 122_880    # S/s
  26. high_sampling_rate = 2_000_000  # S/s
  27. window_size        = 64         # Samples
  28. bandwidth          = 180e6      # MHz
  29.  
  30. dists1 = radar_range(low_sampling_rate, bandwidth, window_size)
  31. dists2 = radar_range(high_sampling_rate, bandwidth, window_size)
  32. dists3 = radar_range_simple(bandwidth, window_size)
  33.  
  34. if dists1 == dists2 == dists3:
  35.     print('Both functions returns equal distances')
  36.  
  37.  
  38. # Conclusion: The sampling_rate does not affect the resolution.
  39. # The higher the sampling rate, the shorter the chirp, the higher the beat frequency for same distance
  40.  
  41. # I hope I got everything right
Add Comment
Please, Sign In to add comment