Announcement

Collapse
No announcement yet.

Algorithm Challenge

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Algorithm Challenge

    OK, here is a mini-challenge. Let's say you design a mixed analog/digital detector. You read in the X & R signals to the micro, and at some point you want to calculate the magnitude and phase. Mathematically, they are:





    However, these can be slow calculations in a micro. The challenge is this: Come up with magnitude and phase calculations which seek to minimize both execution time and memory requirement, and produce acceptably accurate results. "Acceptably accurate" is up to you to define, and to explain and rationalize if necessary.

    I have possible solutions but will wait to see what others come up with.

  • #2
    Just use X + R and R/X , the numbers remain dependent on the amplitude and phase shift. Instead 10 degrees you have 35 fox ( a new unit with any name )

    Comment


    • #3
      Thats strange. I was just working on this.

      By taking the log of the input signals ( ref and sig ) all the trig math is dispensed with.

      Vmag = K log ( Va / Vb ) + c ..... K and c are trivial constants.
      Vphase = S ( Qa - Qb ) ...... S is the Phase slope ( eg millivolts per degree ) and Qa and Qb are the phases of Va and Vb respectively

      conceptually it looks like this. PD is the phase detector.



      the whole thing can be done in real circuits or partial or fully digital ... same result ( depending on your ADCs etc ).​

      In the real world my workbench circuit is recovering the amplitude and phase of a 50 millivolt signal in 10 volts pp noise with around 1% of phase and magnitude error @ 40 Khz.

      Comment


      • #4
        Originally posted by pito View Post
        Just use X + R and R/X , the numbers remain dependent on the amplitude and phase shift. Instead 10 degrees you have 35 fox ( a new unit with any name )
        I should have pointed out that this needs to work for the entire 180° of target space. I like to draw polar plots with 0° on the left and 180° on the right, opposite from normal trig, because that's how detector meters operate.

        Click image for larger version

Name:	image.png
Views:	381
Size:	15.4 KB
ID:	417455

        So, for example, R/X goes to infinity for small foil. And X+R is negative for ferrous targets.

        Comment


        • #5
          Originally posted by moodz View Post
          Thats strange. I was just working on this.
          ...
          Your attachments didn't come through.

          Comment


          • #6
            Originally posted by Carl-NC View Post
            1. So, for example, R/X goes to infinity for small foil.
            2. And X+R is negative for ferrous targets
            .
            1. so put limit ( threshold ) if value is higher we know that is a foil.
            2. use abs( X+R )​,
            √(x2 + y2)​ it is some kind of abs

            Comment


            • #7
              Originally posted by moodz View Post

              1% of phase and magnitude error
              In my opinion VDI is about + /-10% accurate

              Comment


              • #8
                Originally posted by Carl-NC View Post

                Your attachments didn't come through.
                I only embedded a graphic. Didnt attach anything.

                To get 180 degrees just need the right sort of phase detector ... eg ( dual D Flip flop type or reciprocal counting etc ).

                Comment


                • #9
                  Originally posted by pito View Post

                  In my opinion VDI is about + /-10% accurate
                  You are right but I am using a signal recovery technique before I measure the VDI .. in most detectors they just amplify / filter the RX signal then measure the VDI.
                  The signal recovery technique allows for phase and amplitude recovery without the distortion ( phase due to filtering and amplitude due to non linearity in amplification ).

                  Comment


                  • #10
                    I think you are talking about: lock - in amplifier, which is not so good for metal detectors applications.

                    Comment


                    • #11
                      Originally posted by pito View Post
                      I think you are talking about: lock - in amplifier, which is not so good for metal detectors applications.
                      Can you explain your reasoning ? ( its not a lockin amplifier though )

                      Comment


                      • #12
                        another solution ...
                        fast artan calculation using vector rotation.
                        Click image for larger version

Name:	artancalc.jpg
Views:	356
Size:	45.4 KB
ID:	417465

                        Comment


                        • #13
                          Originally posted by moodz View Post

                          Can you explain your reasoning ? ( its not a lockin amplifier though )
                          Click image for larger version

Name:	image.png
Views:	358
Size:	7.0 KB
ID:	417467Click image for larger version

Name:	image.jpg
Views:	368
Size:	13.1 KB
ID:	417468
                          to big

                          Comment


                          • #14
                            hmm .. there are smaller ones on ebay etc ..

                            Click image for larger version

Name:	LockInAmpli3.png
Views:	352
Size:	304.9 KB
ID:	417470

                            Comment


                            • #15
                              They are pricey ... or you can roll your own sig recovery and get results like this ...

                              Click image for larger version

Name:	inout.png
Views:	354
Size:	93.0 KB
ID:	417472

                              Comment

                              Working...
                              X