open-sdr / openwifi

open-source IEEE 802.11 WiFi baseband FPGA (chip) design: driver, software
GNU Affero General Public License v3.0
3.82k stars 647 forks source link

CSI Phase keeps changing Despite relatively stable environment #396

Closed ThETyMaNp closed 4 months ago

ThETyMaNp commented 6 months ago

Hi, I tried to use this demo and was able to get a better looking constellation(https://github.com/open-sdr/openwifi/blob/master/doc/app_notes/radar-self-csi.md), but the problem is thar the CSI phase keeps changing abruptly despite relatively stable environment.

[What is your own modification?]I modified the code in python so that it displays the csi and its phase, as well as the frequency deviation.

I measured the CSI while keeping the transceiver antenna stationary and the surroundings relatively stable (I even went to a darkroom to measure it), but found that even though the surroundings were relatively stable, the phase of the CSI still changed abruptly, and the value of this abrupt change is relatively regular.I initially thought it was due to a sudden phase change in the CSI due to the frequency offset, however, during later tests, the CSI still had a sudden phase change with a frequency offset of 0 (the amplitude information was normal)

Snipaste_2024-03-18_20-44-19

In this picture, I have printed only one subcarrier information, which are phase(angle), frequency offset, csi.Inside each bracket is a time frame (there seem to be several timestamps inside each frame), printed in chronological order

Snipaste_2024-03-18_20-52-19

As a sophomore in college, I am limited in my ability and shallow in my knowledge.Therefore ,this question has been troubling me for a long time, so I'm taking the liberty of asking for your advice, hoping that my question wouldn't bother you and you'll come to help me out! Sincerely, Guang Liu.

JiaoXianjun commented 6 months ago

to have stable wifi radar signal/phase, you need to use the iq capture functionality: https://github.com/open-sdr/openwifi/blob/master/doc/app_notes/packet-iq-self-loopback-test.md#iq-self-loopback-quick-start

Please use the trigger condition 3: 3 the tx_intf_iq0 becomes non zero (the 1st I/Q out) https://github.com/open-sdr/openwifi-hw/blob/900aa8f4c330d047660e10ac871fff922f44aa98/ip/side_ch/src/side_ch_control.v#L460C35-L460C55

You should start to do this from a setup with tx antenna rx antenna co-located very closely, and a quite low rx gain (check how to set rx gain in manual gain mode not AGC gain mode : https://github.com/open-sdr/openwifi/blob/master/doc/app_notes/frequent_trick.md ) to avoid interference in the air/environment.

You can monitor the iq plot via our python script, and adjust the rx gain manually to have IQ amplitude not too big (clipping) not too small (too low SNR).

After you have stable iq loop back over the air (closely co-located tx and rx antenna), you should see very stable stf and ltf at the beginning in the captured IQ real-time plot.

You can calculate the IQ sample phase difference between "all captures" and "the 1st captures". it is very stable.

You can also easily write a python script to calculate real-time CSI based on captured ltf IQ. (fft, divided by the tx ltf frequency domain signal, etc.)

ThETyMaNp commented 6 months ago

Thx very much for your help!I'll try it as soon as I can

ThETyMaNp commented 6 months ago

Thank you again for your sincere help, I followed your instructions, first I put the transceiver antennas very close to each other (I used two horn antennas about 30cm apart), then I adjusted the gain of the RX to 30 (I got a gain of about 41 at the actual reception), and adjusted the trigger mode to 3. Here are the commands I used to run it:

In one ssh: ssh root@192.168.10.122 cd openwifi ./wgd.sh ./monitor_ch.sh sdr0 44
./sdrctl dev sdr0 set reg xpu 8 1000
insmod side_ch.ko iq_len_init=4095
./side_ch_ctl wh11d100
./side_ch_ctl wh8d3
./sdrctl dev sdr0 set reg xpu 1 1
./side_ch_ctl wh5h0 ./set_rx_gain_manual.sh 30 //30dB ./side_ch_ctl g0

In another ssh: cd openwifi/inject_80211/ (make) ./inject_80211 -m n -r 5 -n 1 sdr0

on computer: python iq_capture.py 4095

I then ran it several times in the second ssh session: /inject_80211 -m n -r 5 -n 1 sdr0

I have endeavored to generate LTF and STF sequences using Python, as depicted in Figures 3 and 6, and aligned them with the sampling rate of OpenWIFI (an LTF or STF sequence is 8 microseconds, which corresponds to 160 sample points at 20MHz). After obtaining the LTF and STF sequences, I removed the DC component and performed correlation calculations with the IQ sample signals that had also had their DC components removed. The resulting correlation magnitudes are shown in Figure 1, with the highest values occurring at 166 of STF and 315 of LTF(I am uncertain why the intervals are not 160 samples apart). From these peak values, I extracted 160 samples each to serve as the STF and LTF sequences, as presented in Figures 5 and 2, respectively. Subsequently, I conducted an FFT on the STF sequence (as the FFT results for the LTF sequence are more complex, I started with the simpler STF), and the outcome is illustrated in Figure 4:

Snipaste_2024-03-22_09-55-43

Question: 1.I hope you don't mind me reaching out for further clarification. I'm still learning about the characteristics of STF and LTF sequences and how to assess their stability. Could you kindly confirm if the stable section I observed is indeed indicative of a stable LTF sequence? 2.Additionally, I've attempted to apply an FFT to the STF signal and extract the phase information for frequency points with amplitudes exceeding 3000. However, I've encountered some phase discontinuities of 180 degrees, which I find puzzling. Could you provide some insight into why this might be occurring? Here are the phase values I've obtained:

Snipaste_2024-03-21_14-53-17 Snipaste_2024-03-21_14-53-30

Then, I also tried using MATLAB to perform FFT on the LTF sequence in the IQ signal and divide it by the LTF sequence at the transmitter to obtain CSI. The results were still the same: sometimes the phase information of CSI for two consecutive data packets was the same, and sometimes it would suddenly change by nearly 180 degrees.In the figure below, the first diagram shows the CSI phase of two consecutive data packets suddenly changing by 180 degrees. The second diagram is the normal one, where the horizontal axis represents the subcarrier sequence, the vertical axis represents the phase (from -π to π), and different colors represent the CSI phase of different data packets.

Snipaste_2024-05-03_18-28-44 Snipaste_2024-05-03_18-29-08

And after unwrapping the CSI phase for different subcarriers, the results are shown in the following figure.

Snipaste_2024-05-03_18-30-23

I sincerely hope that you can give me some advice.Thank you again!!!:) Sincerely, Guangteng Liu.

petrichorZSY commented 5 months ago

Hello, I would like to ask you how you process CSI, frequency offset and other information, and how you print it out. What does this information have to do with the side_info.txt file? I would really appreciate it if you could reply to me

ThETyMaNp commented 5 months ago

Hello,

You can obtain the measurement information by running side_info_display.py, which will save it to side_info.txt for further MATLAB data processing. CSI and frequency offset data can also be acquired by creating Python scripts based on side_info_display.py.

JiaoXianjun commented 4 months ago

You might also need to disable our Tx LO automatic control. Because each time LO ON/OFF, the phase might be different.

Check the xpu register 13. Set it to 1 will disable it.

ThETyMaNp commented 4 months ago

Made it!!! Thanks for your generous help!!!My gratitude is beyond words! :)