Announcement

Collapse
No announcement yet.

Let's made a PC-base metal detector with usb interface !!!

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

  • #61
    NO... My soft is not wrong... just is first step of tests...
    I find one problem - Soundcard Hardware DC offset
    and Amplitude and Phase result need to have very low-pass filter
    filter with a cut-off frequency of 10 Hz and down (AN1115 Microchip)

    PS: Sound Card is good for learning of LockIn process but for MD I am not agree....
    If you read AN1115 - current MCUs and DSP microcontrolers is ready for Digital IB Metal Detectors

    Comment


    • #62
      Originally posted by gwzd View Post
      You got this the other way around Aziz, that's a common mistake on EE 101:

      Decibels are unit less and therefore always imply a comparison.

      dB(P)=10*LOG(Pout/Pin)

      P= V^2/R

      dB(P)=10*LOG((Vout^2/R)/(Vin^2/R))

      dB(P)=10*LOG(Vout^2/Vin^2)

      dB(P)=10*2*LOG(Vout/Vin)

      dB(P)=20*LOG(Vout/Vin)

      the same can be proven true for currents also.
      Hi gwzd,

      you are right! Thanks for your attention and excellent mathematical conclusion.
      The factor 10 and 20 must be exchanged.
      10 for power relations
      20 for voltage relations

      Comment


      • #63
        Hi TheWizard,

        DC offset can be occured due to different packing format to the sound card driver. It depends on the wFormatTag (WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT, WAVE_FORMAT_EXTENSIBLE, ..) and wBitsPerSample defined in WAVEFORMATPCMEX.Format structure (if you use the Win32-API).

        Generally, you will have an internal sound format in which all calculations done. When you sending some sound data, this must be converted before sending to the sound driver. When acquiring sound data, unpacking must be applied.
        I am using internally single precision float format in range of: -1.0 .. +1.0.

        That was my first mistake I did in the past.

        Originally posted by TheWizard View Post
        PS: Sound Card is good for learning of LockIn process but for MD I am not agree....
        I am wondering, what a mysterious machine I have at home . It is a MD based on Sound Card.

        Aziz

        Comment


        • #64
          By the way, your guys called my interest to lock-in amps. So I will test a bad coil in low-power (low signal level) VLF mode to proof the result of TheWizard. He claims still, it won't work. I don't believe in that. So I am going to test this by myself on the coming weekend.

          This would increase the SNR dramatically on perfectly balanced IB coils probably. Of course, balancing is made with a second signal source, which adds very small magnetic field strength/density with specified amplitude and phase corrections to the coil configuration. This means, I can create a total flat signal line on the RX-signal with some high noise level. The signal then will be buried in total noise level!

          It's going to be very interesting.
          Aziz

          Comment


          • #65

            Lock-in with Sound-Cards is working!


            I will comment this later. It is too late now!
            Aziz
            Attached Files

            Comment


            • #66
              Some comments on my last Lock-in experiment on Laptop/PC with Sound-Card:

              IB-Coil (PCB-Coil) with high impedance connected directly to sound card output (left channel). IB-Coil is not fine balanced. The signal is the minimum possible balanced signal given only by the PCB-traces of the coil.
              RX coil is not shielded and will show a high level of broadband induced noise. Also no amplifier is connected to the RX-coil. RX-coil is connected directly to microphone input (microphone amplifier is on) and the sensitivity is set to max.
              There is a phase shift between TX and RX signal physically.

              Sampling rate is 96 kHz, 24 Bit resolution. Signal frequency is 24 kHz.

              Despite of the high operating frequency and only four samples for one wave of signal, the Lock-in output is responding to any phase and amplitude changes very sensitiv and quite stable. More better results than I had with very small bandwidth FFT-filtering methods.

              The Lock-in method allows shorter filter bandwidths of filtering the signal of interest. And this goes by far further than FFT-filter or any other filter. So there is much more potential of detecting even very small signals buried in high noise.

              Lock-in should be also applied on PI's. There are some ready-for-use IC's on the market or can be easyly implemented on a RISC µC/DSP. Of course, on the Laptop with ease.

              I will do some more experiments with signal levels from mV to µV. Also will connect an amplifier to RX signal and will watch the response. There is more to discover.

              Aziz

              Comment


              • #67
                Can you make graphic/diagram of phase and amplitude - some like my soft....

                Comment


                • #68
                  Originally posted by TheWizard View Post
                  Can you make graphic/diagram of phase and amplitude - some like my soft....
                  Amplitude is colored magenta, phase is colored yellow in the time-domain. Due to low-pass filtering of I (Y) & Q (X) channels, you see almost the DC level of the values. If you are interested, I can also show the pure I & Q channels before filtering (after mixer), after filtering (realtime I & Q channels), etc. It is interesting to see, how lock-in amplifier is working.
                  Aziz

                  Comment


                  • #69
                    I want to know how is phase noise amplitude in DEG
                    in my picture - phase(and I & Q) have not filtering - it is "RAW" data from AcrTan2 function and amplitude Sqrt....

                    in my second pictures phase noise is big from DC offset - soundcard problem... and I use microphone and speaker... it is audio/room phase reverb
                    I have not time now to make coil test...
                    Attached Files

                    Comment


                    • #70
                      Originally posted by TheWizard View Post
                      I want to know how is phase noise amplitude in DEG
                      in my picture - phase(and I & Q) have not filtering - it is "RAW" data from AcrTan2 function and amplitude Sqrt....

                      in my second pictures phase noise is big from DC offset - soundcard problem... and I use microphone and speaker... it is audio/room phase reverb
                      I have not time now to make coil test...
                      TheWizard,

                      the reason for lock-in is to eliminate the noise. After having multiplied the signal with Reference I and Q, you have to low-pass it. We are not interested on noise amplifiying. We are only interested on the pure signal on specified frequency. My low-pass filter is a very sharp FFT filter at 0 Hz with some bandwidth.
                      The noise can be seen on the FFT-Spectrum. It is typical for my worst case coil configuration (very noisy environment). Even with a bad sound card, it should work anyway!

                      Comment


                      • #71
                        I know that....you dont understand me... np...
                        how you make I and Q :
                        0 and 90 deg samples or
                        f/4 frequency translation (Down-conversion method)

                        Comment


                        • #72
                          I forgot to mention:

                          The sqrt() and atan2() must be applied after the low-pass filtering.
                          R = sqrt(I*I+Q*Q) (magnitude of r.m.s. AC-signal)
                          P = atan(Q/I) or better
                          P = atan2(Q, I) (phase relative the reference in radians)

                          Regards,
                          Aziz

                          Comment


                          • #73
                            Originally posted by TheWizard View Post
                            I know that....you dont understand me... np...
                            how you make I and Q :
                            0 and 90 deg samples or
                            f/4 frequency translation (Down-conversion method)
                            Source:
                            Signal(t): A*sin(wt)

                            Reference:
                            Ref-I(t): B*sin(wt+ref-phase)
                            Ref-Q(t):B*sin(wt+ref-phase+90°) = B*cos(wt+ref-phase)

                            Mixer:
                            I&Q-Channel:
                            I(t) = Signal(t) * Ref-I(t)
                            Q(t)= Signal(t) * Ref-Q(t)

                            Low-pass filtering of I&Q-Channel:
                            Removing all the high frequency parts of uninterested spectrum + noise.

                            I&Q(t)-Channel is now LP-filtered.

                            Calculating R&P-Channel:
                            Using sqrt() and atan2() as described above for all entries of I(t) and Q(t) and calculating R(t) and P(t).
                            The low-pass bandwith and response time determines, how smooth the I(t), Q(t), R(t) and P(t) will be.

                            Thats all.

                            Comment


                            • #74
                              Some comments on signal and reference generation:

                              If they are not totally synchronized together, all the output of the Lock-in will be wrong (mainly other). So you must ensure, that there is on the received signal stream and internally generated reference stream no time gap or out of synchronisation.

                              All the other parts are very easy to calculate. Probably, the LP-filter has more complexity. But you can even use the averaged mean values as a approximation for LP-filter.

                              Aziz

                              Comment


                              • #75
                                Here is the main c-code of Lock-in amp for all others:

                                //------------Lock-in-------------
                                if (pMetDet->Config.bLockin)
                                {
                                fsample fi,fq, *pInp,
                                *pRefI,*pRefQ,
                                *pI, *pQ,
                                *pIOut, *pQOut,
                                *pMag, *pPh, *pF, *pIm, *pRe;
                                double f;
                                int i;

                                // Wave-Frame channels für Lock-in bereitstellen
                                //
                                pInp = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_INPUTL);
                                pRefI = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_REF_I);
                                pRefQ = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_REF_Q);
                                pI = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_I);
                                pQ = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_Q);
                                pIOut = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_IOUT);
                                pQOut = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_QOUT);
                                pMag = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_MAGNITUDE);
                                pPh = Wave_GetChannelPtr(pMetDet->pWaveSig, METDETCH_LOCKIN_PHASE);

                                // Buffer for FFT-Filter
                                pRe = Wave_GetChannelPtr(pTmpWave, 0);
                                pIm = Wave_GetChannelPtr(pTmpWave, 1);

                                // LP-Filter spectrum
                                pF = Wave_GetChannelPtr(pTmpWave, 2);

                                // I und Q Mixer
                                //
                                for (i=0; i < nFrameSize; i++)
                                {
                                f = pInp[i]; // signal(t)
                                pI[i] = (fsample)(f*pRefI[i]); // X
                                pQ[i] = (fsample)(f*pRefQ[i]); // Y

                                } // for i

                                // LP-filter I und Q
                                //
                                memcpy(pIOut, pI, nFrameSize*sizeof(fsample));
                                memcpy(pQOut, pQ, nFrameSize*sizeof(fsample));
                                FFTFilter(nFrameSize, pIOut, pF, pRe, pIm, FALSE, &Result.fLockinDCI);
                                FFTFilter(nFrameSize, pQOut, pF, pRe, pIm, FALSE, &Result.fLockinDCQ);

                                // R,P of DC Level of I und Q
                                //
                                Result.fLockinDCMagnitude = sqrt(Result.fLockinDCI*Result.fLockinDCI + Result.fLockinDCQ*Result.fLockinDCQ);
                                Result.fLockinDCPhase = atan2(Result.fLockinDCQ, Result.fLockinDCI)*NACH_GRAD;

                                // Amplitude and Phase
                                //
                                Result.fLockinAvgMagnitude = Result.fLockinAvgPhase = 0.0;
                                for (i=0; i < nFrameSize; i++)
                                {
                                fi = (fsample)(pIOut[i]); // Y: sin
                                fq = (fsample)(pQOut[i]); // X: sin+90 = cos

                                // Magnitude = sqrt(I*I + Q*Q)
                                f = sqrt(fi*fi + fq*fq);
                                pMag[i] = (fsample)f;
                                Result.fLockinAvgMagnitude += f;
                                // Phase = atan(Q/I), atan2(Q,I)
                                f = atan2(fq, fi)*NACH_GRAD;
                                pPh[i] = (fsample)f;
                                Result.fLockinAvgPhase += f;

                                } // for i

                                f = 1.0 / nFrameSize;
                                Result.fLockinAvgMagnitude *= f;
                                Result.fLockinAvgPhase *= f;

                                Result.dwFlags |= METDETRESULT_LOCKIN;
                                }
                                //------------Lock-in-------------

                                Damn! Format is gone to the hell!

                                Comment

                                Working...
                                X