sensorStop flushCfg dfeDataOutputMode 1 channelCfg 15 3 0 adcCfg 2 1 adcbufCfg -1 0 0 1 0 profileCfg 0 77 429 7 57.14 0 0 70 1 256 5209 0 0 30 chirpCfg 0 0 0 0 0 0 0 1 chirpCfg 1 1 0 0 0 0 0 2 frameCfg 0 1 16 0 100 1 0 lowPower 0 1 guiMonitor -1 1 1 0 0 0 1 cfarCfg -1 0 0 8 4 4 0 5120 cfarCfg -1 1 0 4 2 3 0 5120 peakGrouping -1 1 1 1 1 255 multiObjBeamForming -1 1 0.5 clutterRemoval -1 0 calibDcRangeSig -1 0 -5 8 256 extendedMaxVelocity -1 0 bpmCfg -1 0 0 1 lvdsStreamCfg -1 0 1 0 nearFieldCfg -1 0 0 0 compRangeBiasAndRxChanPhase 0.0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 measureRangeBiasAndRxChanPhase 0 1.5 0.2 CQRxSatMonitor 0 3 5 123 0 CQSigImgMonitor 0 127 4 analogMonitor 1 1 sensorStart這樣,adc.py 的chirp/frame 參數是:
ADC_PARAMS = {'chirps': 16,
'rx': 4,
'tx': 2,
'samples': 256,
'IQ': 2,
'bytes': 2}
用 dca1000test:tryadc 的 testadc.c...
from adc import DCA1000
import numpy as np
dca = DCA1000()
dca.send_start_command()
adc_data = dca.read(timeout=.1)
np.save('framedata',adc_data)
dca.send_stop_command()
save 一個 frame 的資料 framedata.npy。
import numpy as np
import matplotlib.pyplot as plt
rawdata = np.load('framedata.npy')
rxdata = np.zeros(len(rawdata)//2, dtype=complex)
rxdata[0::2] = rawdata[0::4] + 1j * rawdata[2::4]
rxdata[1::2] = rawdata[1::4] + 1j * rawdata[3::4]
rxchirp = rxdata.reshape((16*4*2,256))
把 data 讀進來,依照 udp data format 的順序,和 chirp parameters, 轉成 complex,然後再改成二維陣列,每個 chirp 一個element.
然後把一個rx 的 chirp 畫出來看...
plt.plot(np.abs(rxchirp[0])) plt.show()

這個樣子..感覺應該是 signed 才對 (值很靠近 0, 所以負值以unsigned 看來看0xFFxx 變得很大)
看 OpenRadar 的 basic/range.ipynb,其中有說明:
#Read in chirp data
addc_samples = np.loadtxt('../assets/chirp.txt',dtype=np.complex)
#Manually cast to signed ints
adc_samples.real = adc_samples.real.astype(np.int16)
adc_samples.imag = adc_samples.imag.astype(np.int16)
#Take FFT across ADC samples
range_bins = np.fft.fft(adc_samples)
# Plot the magnititude of the range bins
plt.plot(np.abs(range_bins))
plt.show()
果然,讀近來之後,要 cast 成 int16所以修改 adc.py,存的時候就用 int16,不用 uint16,這樣np.load 後,也會是 int16.
上面的 code ,不用修改,就變成:

看起來比剛剛正常。
進型 FFT 後...
plt.plot(np.abs(np.fft.fft(rxchirp[0]))) plt.show( )顯示正確的 range peak:
沒有留言:
張貼留言