I have a Doppler sensor with I/Q channels for detecting moving object. I need to also detect the moving direction of the object. Due to the limited power and flash memory of my MCU, I cannot afford FFT() or atan() or sqrt() functions.

In order to determine the moving direction of the object, phase difference between I and Q need to be determined (positive or negative). And the following methods are the ones I'm aware of:

  1. FFT
  2. x-correlation
  3. atan(I/Q)
  4. search posive slope of I and Q signal and determine the phase shift

The first 3 methods, I cannot afford them due to MCU limit. The last one is very sensitive to noise.

Is there other simple ways to determine the phase difference between I/Q is negative or positive ?

  • \$\begingroup\$ Have you considered the venerable MC1496? \$\endgroup\$ – jonk Oct 7 '16 at 9:12
  • \$\begingroup\$ end a line with 2 spaces to keep the line breaks! \$\endgroup\$ – Neil_UK Oct 7 '16 at 9:14
  • \$\begingroup\$ Hi @jonk, unfortunately I don't have a choice which MCU I can have ! \$\endgroup\$ – bienle Oct 7 '16 at 11:23
  • 1
    \$\begingroup\$ The MC1496 isn't a MCU, it's a standalone IC which acts as a mixer and can do phase detection (although it's not very obvious from the datasheet) \$\endgroup\$ – pjc50 Oct 7 '16 at 13:54

'... the last one is very sensitive to noise'

They are all sensitive to noise, filtering reduces the noise. Some methods have filtering 'hidden' in them. For instance FFT processes a large amount of data, and then you use just one frequency bin, which is an implicit filter. If you use filtered data for your slope search estimation, then you will be more robust against noise.

Consider this. When the slope on one channel has the same polarity as the value of the other, the rotation will be in one direction, and when they are opposite polarity, the other.

How do you determine whether two values have the same polarity? Multiply them. A positive result and they are both + or both -, and vice versa. Or do XOR logic on their signs, whichever is quickest for the hardware instructions you have to hand.

So try this. Compute I slope at In by (In-1 - In+1), multiply by Q value Qn, and accumulate the answer. Repeat for subsequent ns as many times as required to reduce your noise to reasonable levels. The sign of the accumulated number indicates the polarity of the rotation.

| improve this answer | |
  • \$\begingroup\$ Hi Neil_UK I tried your suggestion and it seems to work very well. Occasionally it does not work as well as using FFT (occasionally it gives the wrong direction while FFT gives the correct direction), but i guess the reason is as you mentioned: I didn't apply a filter on the I/Q signals, while FFT uses kind of a filter by using frequency bin. However I still not understand how does it work? Why the sign of the accumulative value shows whether I-phase is earlier or later than Q-phase ? \$\endgroup\$ – bienle Oct 7 '16 at 11:21
  • 1
    \$\begingroup\$ @bienle sketch out an I and Q signal, with either leading, and 'play computer' for a few points, following my algorithm. It will either click for you, or it won't. Put them is a spreadsheet is a quicker way to run the algorithm with full visibility point by point to see what's happening. I should point out I'm only making use of half the information, so the noise will be higher than is necessary. If you run the algorithm on both I and Q (substitute I for Q, and -Q for I) then you'll get 3dB better signal to noise. \$\endgroup\$ – Neil_UK Oct 8 '16 at 8:02
  • \$\begingroup\$ I sketched out an I/Q signal pair and followed your algorithm step by step, now I'm able to understand how it works. Also I tried to use the all the information as you suggested and it shows the 3dB better as you mentioned. Thanks @Neil_UK \$\endgroup\$ – bienle Oct 10 '16 at 7:56

If you're generating a signal at the reference frequency, it should be easy to generate a quadrature signal. If one multiplies the incoming signal by the in-phase reference and time-averages the result, and simultaneously multiplies the incoming signal with the quadrature signal and time-averages that result, one will get a pair of signals which will move "around a circle" each time the returned signal gains or loses a cycle. If you observe the polarity of the quadrature product every time the in-phase product changes polarity, incrementing a counter when the new in-phase polarity matches the quadrature polarity, and decrementing the counter when it doesn't, you should get a relatively noise-resistant count (if noise causes a false rising edge to be observed, causing a false increment, the next reading of the correct polarity will be seen as a falling edge, likely causing a decrement to cancel the false increment).

| improve this answer | |
  • \$\begingroup\$ Hi @supercat, I'm not sure if I understand your suggestion correctly. As far as I understand: 1.) calculate cummulative product of I-signal (cumProI) and cummulative product of Q-signal (cumProQ). 2.) Whenever the polarity (or the sign) of cumProI changes, increament counter if sign_of_cumProI == sign_of_cumProQ, otherwise decrement counter. In the end the value of counter will show the number of positive/negative slopes. Is it correct ? \$\endgroup\$ – bienle Oct 10 '16 at 8:12
  • \$\begingroup\$ @bienle: That sounds right. \$\endgroup\$ – supercat Oct 10 '16 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.