How to process analog waveform from metal detector in arduino

Hi guys

I need some help regarding programming. I have made a metal detector, when metal is detected I am getting pretty clear waveform from detector

attachment ( PXL_20210702_060158139.jpg) shows waveform when no metal is near the coil

attachment ( PXL_20210702_060159594.jpg) shows waveform when metal is detected

now I am giving this waveform to arduino analog pin A0. What I need to do is when metal is detected I need buzzer to simply give a tune and other thing is to show when ferrous material is detected and when non-ferrious is detected. And when there is ferrous material in front of the coil the waveform is as shown above and when non-ferious the waveform slightly changes.

The only thing I am stuck at I have single signal how can I make a reference signal from it to differentiate through it, I hope u guys get what I am trying to say/achieve

All the metal detector timing stuff is done by 555 IC and monostable ICs. I just need to process this waveform in arduino.

just to be clear

The highlighted Red part is what tells you that no metal is detected and when it's not there then it means you have metal

what's the spike meaning? is that the response to your "ping" ?

I can't see the scale so it's hard to be sure.
What is the value of the lowest reading with and without metal? It appears that your difference is there and if there is a large enough difference you can just use that as an indicator.

  • waveform is generated and fed to a coil. this is the reference waveform
  • same waveform is generated and sent to another coil, with reversed polarity
  • headphones are wired to present the difference in the two coils
  • the detector is equipped with controls that let you balance the voltage in the coils, so when the coils are in the air, you hear nothing.
  • pass the coil over metal; some of the energy from the coil creates an eddy current in the metal. this momentarily unbalances the coils. you hear the difference.
  • different metals create different delays in the returning signal. this delay can be measured in phase angle. if the waveform is a constant fixed frequency, that phase angle can be measured in milliseconds. gold, silver, ferrous, aluminum - different delays.

Garret, pioneer in metal detection, has written many books on this subject. he was open source long before it was named that. I would start by searching for metal detector theory of operation, and read anything from Garret first.

You can record the 'number's' of the various wave forms detected. Save those numbers as models. Then using Linear Regression or TensorFlow and a 32 bit MCU you'd be able to code to analyze the received signals and compare them against the training model for a correlation.

Get started with machine learning on Arduino

I don't think machine learning is necessary here. There are other ways also more simple.

I tried making an array and save the signal values in that array. But i dont know how do i put a checker on that array when difference occurs so buzzer beeps.

when metal is detected the waveform shift downwards to 0 value.

There you go. What is the lowest value when there's no metal?


as u can see in this red circle this is the lowest part when no metal is near the coil this is zero portion

I can see that, yes. I'm just curious what the actual voltage reads.
I think there enough difference there to just compare that and ignore the rest of the waveform as it's nearly identical in both cases. This type of simple voltage range sampling was used to trigger alarms in the Apollo guidance computer. If it put men on the moon it should help you find metal :wink:
This simple sampling will also take much less processor time which means more sample per second, within the limits of the sensor of course.

I know this is simple task because the difference is really huge. If I take the sample in array . how do I put a checker on it so the buzzer only beeps when the metal is near I am just confused in this part

Search the array for the lowest value using a for loop.

What are the other ways? The OP would be interested.