Announcement

Collapse
No announcement yet.

Announcement

Collapse
No announcement yet.

Android Phone Based Metal Detector - FCMD

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

  • #61
    Added more sophisticated audio with selectable tone and morse code target ID. The morse code is the first letter of the target type ... eg "I" or "dit dit" for Iron etc. Its surprising but you can recognise the tones much faster than looking at display and reading a moving VDI.
    Some people can read morse at 100 wpm ... not me . I ( and me AI mate ) also added haptic output ... to drive a vibrating target indicator with selectable threshold. Finally added a rotary encoder also for controlling stuff manually for those who like playing with knobs.

    Click image for larger version

Name:	image.png
Views:	305
Size:	124.0 KB
ID:	443358


    Click image for larger version

Name:	image.png
Views:	355
Size:	496.5 KB
ID:	443357

    Comment


    • #62
      Came to realise that in a multifrequency VLF detector GB has to be done at each frequency. So that means if you say have 10 frequencies then you need 10 tracking GB values.
      The code now supports tracking on 2 - 50 frequencies. The GB is greatly control simplified now ... its either on ( tracking ) or paused ( fixed ). To GB you just pump the coil over the ground and hit the GB reset button and it will track the ground. For fine target resolution the GB is paused. The code also provides a GSI ... ground signal intensity signal from the GB code that tells you what the ground is like. On the waveform display you can see a frequency switch occurring as we use stepped frequency sweep to maintain s/n ratio.

      Click image for larger version

Name:	image.png
Views:	336
Size:	444.7 KB
ID:	443367

      Comment


      • #63
        Nearly finished

        VLF Metal Detector Theory - Multi-Frequency Ground Balance

        Basic Principle

        A VLF (Very Low Frequency) metal detector works by transmitting a sinusoidal magnetic field and measuring the response from the ground and targets.

        TX Coil -> Magnetic Field -> Target/Ground -> Induced Currents -> Secondary Field -> RX Coil

        Synchronous Detection (IQ Demodulation)

        The received signal is mixed with the transmitted frequency to extract two components:

        - I (In-phase): Component in phase with TX - represents resistive response
        - Q (Quadrature): Component 90° out of phase - represents reactive response

        Signal = I*cos(wt) + Q*sin(wt)

        From I and Q we derive:
        - Amplitude = sqrt(I^2 + Q^2)
        - Phase = atan2(Q, I)

        Why Ground is a Problem

        Mineralized soil contains iron oxides (magnetite, maghemite) that respond to the magnetic field. This ground signal can be 100-1000x stronger than a coin at depth.

        Ground characteristics:
        - Primarily resistive (high I component)
        - Phase typically 0-30 degrees (close to TX phase)
        - Response varies with frequency (dispersive)

        Target characteristics:
        - Non-ferrous metals are primarily reactive (high Q component)
        - Phase typically 60-90 degrees for good conductors
        - Different metals have characteristic phase angles

        Ground Balance by Vector Subtraction

        The key insight: ground response is relatively stable over time, while targets appear and disappear as the coil moves.

        Raw Signal = Ground Vector + Target Vector

        If we know Ground Vector:
        Target Vector = Raw Signal - Ground Vector

        Why Multi-Frequency?

        Ground mineralization is dispersive - its response changes with frequency:

        Frequency Ground Phase Ground Amplitude
        --------- ------------ ----------------
        5 kHz 15 deg 0.8
        10 kHz 18 deg 0.6
        20 kHz 22 deg 0.4
        40 kHz 28 deg 0.3

        Single-frequency GB can only cancel ground at one frequency. Multi-frequency GB tracks the ground vector at each frequency independently, providing better cancellation
        across the spectrum.

        Tracking Ground Balance

        Rather than manual calibration (pumping coil), tracking GB continuously adapts:

        // Exponential moving average
        ground_i = ground_i + alpha * (new_i - ground_i)
        ground_q = ground_q + alpha * (new_q - ground_q)

        Where alpha (tracking_alpha) is small (0.001-0.01) for slow adaptation.

        Motion detection prevents target signals from corrupting the ground estimate:
        - If amplitude changes rapidly -> target detected -> pause tracking
        - Resume tracking after signal stabilizes

        VDI (Visual Discrimination Index)

        Phase angle correlates with target conductivity:

        VDI Range Phase Typical Targets
        --------- ----- ---------------
        -95 to -40 0-20 deg Iron, steel
        -40 to 0 20-40 deg Ferrous, foil
        0 to 40 40-60 deg Nickel, pull tabs, zinc
        40 to 70 60-75 deg Copper, brass
        70 to 95 75-90 deg Silver, large copper

        Multi-frequency improves VDI accuracy by averaging across frequencies and detecting frequency-dependent behavior (ferrous targets show phase reversal at different
        frequencies).

        Ground Severity Index (GSI)

        Quantifies how mineralized the ground is (0-100):

        GSI = f(ground_amplitude, phase_spread, frequency_response)

        - 0-20: Clean ground (beach sand, low mineral)
        - 20-50: Moderate (typical soil)
        - 50-80: Difficult (red clay, black sand)
        - 80-100: Extreme (hot rocks, heavy mineralization)

        Higher GSI means the detector is working harder to reject ground, potentially reducing depth on small targets.

        Signal Flow Summary

        NCO (DAC) -> TX Coil -> Ground/Target -> RX Coil -> ADC
        |
        v
        Sync Detector (I, Q)
        |
        v
        Ground Balance Subtract
        |
        v
        VDI Calculation
        |
        v
        Target ID / Audio

        Comment


        • #64
          Project - Lines of Code Summary

          | Component | Lines |
          |--------------|--------|
          | Firmware (C) | 11,056 |
          | Python GUI | 2,851 |
          | Total | 13,907 |

          Firmware Breakdown (largest files)

          | File | Lines | Purpose |
          |---------------------|-------|----------------------------------------------|
          | main.c | 2,153 | Main loop, CLI commands, initialization |
          | ground_balance.c | 1,231 | Multi-frequency ground balance tracking |
          | adc_dma.c | 745 | ADC sampling, packet building, USB streaming |
          | stm32h7xx_hal_msp.c | 621 | HAL peripheral initialization |
          | uart_packet.c | 599 | UART packet protocol (for VLFDEV) |
          | mf_sweep.c | 492 | Multi-frequency sweep control |
          | target_audio.c | 467 | Audio feedback generation |
          | ground_balance.h | 431 | GB structures and API |
          | dac_nco.c | 408 | NCO sine wave generation |

          Python GUI Breakdown

          | File | Lines | Purpose |
          |------------------|-------|---------------------------------------|
          | stm32_adc_gui.py | 2,186 | PyQt5 GUI with plots, controls |
          | serial_thread.py | 665 | USB CDC communication, packet parsing |


          ⏺ Flash Image Size

          | Section | Size | Description |
          |---------|--------------|--------------------------------------------------------|
          | text | 75,116 bytes | Code + constants (stored in Flash) |
          | data | 416 bytes | Initialized variables (stored in Flash, copied to RAM) |
          | bss | 29,496 bytes | Uninitialized variables (RAM only, not in Flash) |

          Flash usage: 75.5 KB (text + data)

          RAM usage: 29.9 KB (data + bss)

          The STM32H750VB has 128 KB of Flash, so you're using about 59% of available Flash.​

          Comment


          • #65
            Amazing job, thank you for sharing. Is it all on your Github?

            Comment


            • #66
              Originally posted by cristiano.sar View Post
              Amazing job, thank you for sharing. Is it all on your Github?
              it will be when I can stop the AI fixing things that are already fixed. ( building the android app for the phone ).

              This is the app ( not fully working yet ).

              Click image for larger version

Name:	image.png
Views:	310
Size:	121.5 KB
ID:	443378

              Comment


              • #67
                ..well I hit the limitations of the AI. You cant develop a serial port and a USB port using serial over USB aka "CDC" at the same time ... it was just too hard for its conceptual machinery to split the concept of the requirements for a relatively low speed uart and a high speed USB interface using packetised data transfer. Anyway the realtime data needs the speed of the USB port so why compromise ?
                I was interested to see if the ground balance would actually work across 50 frequencies ( it has to GB each separately ) ...it does seem to be working. If it was not I would not get the nice smooth phase curves below.
                Its been said that so many frequencies is overkill but this is as much an experiment as a project. Besides you can use it to do bode plots to test coils etc for resonances or impedance changes.
                The sweep repetition rate is 0.5 hz .... useable for fine descrimination. The fastest sweep rate with two frequency points is 25 sweeps/sec. The default ( bootup ) is 4 frequency points at 12.5 sweeps / sec.

                ... and what is truly amazing is I got to this point without writing / editing a single line of code using a 3 step process.
                1. request
                2. test
                3. goto step 1.

                Click image for larger version

Name:	image.png
Views:	294
Size:	462.8 KB
ID:	443390

                Comment


                • #68
                  Android USB v1.0 app completed!
                  3 screens main ( detector ) , sweep for profiling and testing, configuration.

                  The stm32 board is powered by the phone over usb.

                  I did a 50 point sweep from 100 Hz to 99Khz with GB on ... seems to be working like a charm.

                  Very little cpu usage on the phone as all the DSP is done in the STM32.


                  Click image for larger version

Name:	image.png
Views:	323
Size:	134.5 KB
ID:	443397


                  Click image for larger version

Name:	image.png
Views:	326
Size:	128.5 KB
ID:	443399


                  Click image for larger version

Name:	image.png
Views:	333
Size:	176.7 KB
ID:	443401
                  Attached Files

                  Comment


                  • #69
                    .. now we will need a broadband coil so we chop the capacitor out of our test coil Leaving us with two coils one at 3.2 mH and the other 2.6 mH ..
                    Its likely due to the high inductance that we will only be able to reach 50 Khz ...

                    Click image for larger version

Name:	image.png
Views:	260
Size:	1.05 MB
ID:	443502

                    Comment


                    • #70
                      Target ID works?

                      Then you should watch this "learning video about targets and target ID's". This video actually confirms what I monitored about "traget ID's" in many metal detector videos.
                      Facebook link (www.facebook.com/reel/1280100617492805)​​

                      Comment


                      • #71
                        Originally posted by GeoMax View Post
                        Target ID works?

                        Then you should watch this "learning video about targets and target ID's". This video actually confirms what I monitored about "traget ID's" in many metal detector videos.
                        Facebook link (www.facebook.com/reel/1280100617492805)​​
                        ... the link seems to be broken. Personally I am happy with Iron / not iron.

                        Comment


                        • #72
                          If you click on "Facebook" you still can see the video clip. The other link seems to be broken.

                          Comment


                          • #73
                            Originally posted by GeoMax View Post
                            If you click on "Facebook" you still can see the video clip. The other link seems to be broken.
                            Ivica could tell you if that guy has his deusII set up properly or not .

                            I dig everything ... VDI is a take it or leave it preference.

                            Comment


                            • #74
                              Originally posted by moodz View Post
                              .. now we will need a broadband coil so we chop the capacitor out of our test coil Leaving us with two coils one at 3.2 mH and the other 2.6 mH ..
                              Its likely due to the high inductance that we will only be able to reach 50 Khz ...
                              How did it go with the modified coil?

                              Comment


                              • #75
                                Originally posted by Repwoc View Post

                                How did it go with the modified coil?
                                Usually the hardware is quick and the software takes longer .. now I have found the situation is reversed. I am modifying the driver hardware to compensate for the increasing reactance of the coil with frequency so that the transmit power is flat across the spectrum from around 5 khz to 100 khz. The resonance point of the coil cant fall in this range so working on minimising the driver capacitance etc .... so getting there.

                                Comment

                                Working...
                                X