Announcement

Collapse
No announcement yet.

Arduino based VDI!

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

  • manny77
    replied
    Originally posted by Daren View Post
    I spent last few weeks experimenting with TGLS and Arduino VDI. Here are the findings.

    Deriving VDI from TGLS X,R signals can be improved if we analyze the signals a little more.

    Here is the aluminum foil as seen by the Arduino.
    [ATTACH]30924[/ATTACH]

    We can see that the angle is all over the place. I we select minimum signal strength then we may get lucky and fall in the right place.

    Here is the copper 1 cent US
    [ATTACH]30923[/ATTACH]

    The angle is mostly around 80 but is does swing to -80.

    Silver ring
    [ATTACH]30920[/ATTACH]

    Both of the signals have something in common; when R is positive then the angle is in the phase we want.

    So requirements to get correct angle are:
    - minimum signal level to distinguish the signal from the noise
    - positive R value

    This should get us into the right ballpark. At this point we can assume several approaches to get the better value of the angle. We could monitor the value of the signals X,R and return the angle when the signals are at their peak. (It should work fine, haven't tried). We could cluster angle values and get the biggest cluster (most common angle measured). I used this second approach, I liked it because we base the decision on the larger population of data points.

    There are number of additional tweaks that allow to control the behavior of algorithm; for example we could give more weight in the decision making to the readings that have stronger signal.
    Two last parms in the VDI menu allow to control the R polarity to use and the signal weight. (R polarity may have to be flopped if you take your signals 1 opamp earlier in the signal path than U104/U105)

    (if you going to use software make sure that you set "BPin" correctly; schematic calls for A2, its A3 in code)

    Sound support was added, you can enable/disable it in the menu. Sound does take a lot resources so if you don;t use turn it off.
    I had piezzo buzzer connected and it does not sound that good at all. Real speaker or phones would be better...

    I haven't tried the system in the field since I switched to this new algorithm, but it should be a definite improvement over the old method (laugh with me now...).

    Arduino program:
    [ATTACH]30922[/ATTACH]

    Maybe I should start a new thread... Let me know... I'm not sure what is the proper board etiquette
    Thank you very much Daren for this upgrade!

    But it don't work well like previous version in my MD.

    While detecting, sound buzzer work every time, but display not...very rarely it refresh accordingly to detected target, most of time it show zero. But every beep could be listen from arduino. I tweaked params but this can't be solved.

    With your default params, calibrating to my ADC Max and Zero, buzzer is always on, sounding high note. Display VDI show zero. I have to raise min signal from 20 (default) to about 150 to mute it and sound only with detection.

    My ADC MAX is about 950. What is yours? Maybe new algorithm need a lower input? (I can tweak amplification and offset with trimmers for the two channels).

    Reading from battery voltage was very precise in previous version, now it show a decreasing value that stabilize around a wrong (higher) real value. I used my battery params in the SW, like in previous version.
    Battery icon shows right despite internal battery voltage menu.

    In this way software is unusable...maybe you have a clue of the problem?

    Leave a comment:


  • der_fisherman
    replied
    Originally posted by Daren View Post
    I did some experiments with the sound too, there was not enough fluidity.. Yes you can beep while you display the phase and base your pitch on the phase number. But its not good enough. Original audio conveys more info; signal strength, breaking signal, immediate feedback, etc. Using digital audio all this is lost. You can do very nice digital audio, but at this moment I don't how. Low CPU clock and processing power restricts using more fancy stuff.
    You need to express a lot of nuances in the sound to be useful and analog audio does it naturally.

    The schematic is basically IDX - VDI front-end with Arduino in the back. Don't mix VCC and RAW on Arduino

    [ATTACH]30564[/ATTACH]
    Have you thought about adding another small processor just to perform the audio for example, a small PICAXE 08M for example....

    Just a thought

    Andy

    Leave a comment:


  • Daren
    replied
    Originally posted by Qiaozhi View Post
    The way I solved this problem was to only read the X and Y channels if a target has been detected. i.e. when the audio is told to beep by the PIC.
    Makes sense; in this implementation above functionality is simulated by watching signal strength. If the either signal exceeds "min sig value" then its OK to collect samples. It never occurred to me that signal that enables audio could be reused to "gate" the sampling. It is much simpler.. Oh, well.. Using "min sig value" does have some benefits, it allows for independent "sens" setting

    Leave a comment:


  • Qiaozhi
    replied
    Originally posted by Daren View Post
    Yeah, the code is using atan for calculating the VDI value. Each internal data point is a deg angle derived from the atan that is in turn derived from the ratio. (Code uses atan2, but its the same thing)
    OK, that's good. I did have a quick look at the code, but couldn't see the atan function. Also, I'm not familiar with the Arduino.

    Originally posted by Daren View Post
    The interesting part it how to get most information from the right part of the signal and discard the rest.
    The number of data points obtained from the target pulse can vary from 100 (faint signal) to more than a thousand(strong big X,R pulse) (with the target present I collect 3 data point pairs X,R for each millisecond). These data points are collected only when the signal is strong enough and the polarity is the one we want (the second condition is not critical but helps). If you plot angle distribution for collected samples you will realize that they are nicely clustered around one value. This is the value that algorithm returns.
    The way I solved this problem was to only read the X and Y channels if a target has been detected. i.e. when the audio is told to beep by the PIC. Previously I stated that I took 25 readings, but in fact it was 50. So the process is actually quite simple. Whenever the signal is above the threshold (audio oscillator enabled) take a reading from both the X and Y channels. After counting 50 readings for both the X and Y channels, take the average and calculate arctan(Y/X) and display result on the LCD. The VDI number is quite stable, and consistent with variations in depth. It also works for the full detection depth.

    Leave a comment:


  • Daren
    replied
    Bernte,
    makes sense, thanks.

    I'll test in the field and see how it goes.. When all looks good I'll create new thread with a more detailed instructions.
    daren

    Leave a comment:


  • Daren
    replied
    Originally posted by Qiaozhi View Post
    For an accurate VDI you need to calculate the arctangent of R/X, not simply take the ratio.
    Yeah, the code is using atan for calculating the VDI value. Each internal data point is a deg angle derived from the atan that is in turn derived from the ratio. (Code uses atan2, but its the same thing)
    The interesting part it how to get most information from the right part of the signal and discard the rest.
    The number of data points obtained from the target pulse can vary from 100 (faint signal) to more than a thousand(strong big X,R pulse) (with the target present I collect 3 data point pairs X,R for each millisecond). These data points are collected only when the signal is strong enough and the polarity is the one we want (the second condition is not critical but helps). If you plot angle distribution for collected samples you will realize that they are nicely clustered around one value. This is the value that algorithm returns.

    Leave a comment:


  • Qiaozhi
    replied
    For an accurate VDI you need to calculate the arctangent of R/X, not simply take the ratio.
    I've done this in the past using a PIC. Take 25 samples and find the average, then do the arctan calculation. The result is a stable and reliable VDI.

    Leave a comment:


  • bernte_one
    replied
    hello daren

    looks very good
    would you open a new thread where you can write all details form Arduino vdi with TGSL
    wiring diagram
    signal amplifier shematic (if neccessary)
    pcb layout if you made some extra pcb for this project

    many thanks for your time and work

    Leave a comment:


  • Daren
    replied
    Going deeper

    I spent last few weeks experimenting with TGLS and Arduino VDI. Here are the findings.

    Deriving VDI from TGLS X,R signals can be improved if we analyze the signals a little more.

    Here is the aluminum foil as seen by the Arduino.
    Click image for larger version

Name:	foil.jpg
Views:	1
Size:	119.2 KB
ID:	341507

    We can see that the angle is all over the place. I we select minimum signal strength then we may get lucky and fall in the right place.

    Here is the copper 1 cent US
    Click image for larger version

Name:	copper.jpg
Views:	1
Size:	143.5 KB
ID:	341506

    The angle is mostly around 80 but is does swing to -80.

    Silver ring
    Click image for larger version

Name:	silver.jpg
Views:	1
Size:	115.9 KB
ID:	341503

    Both of the signals have something in common; when R is positive then the angle is in the phase we want.

    So requirements to get correct angle are:
    - minimum signal level to distinguish the signal from the noise
    - positive R value

    This should get us into the right ballpark. At this point we can assume several approaches to get the better value of the angle. We could monitor the value of the signals X,R and return the angle when the signals are at their peak. (It should work fine, haven't tried). We could cluster angle values and get the biggest cluster (most common angle measured). I used this second approach, I liked it because we base the decision on the larger population of data points.

    There are number of additional tweaks that allow to control the behavior of algorithm; for example we could give more weight in the decision making to the readings that have stronger signal.
    Two last parms in the VDI menu allow to control the R polarity to use and the signal weight. (R polarity may have to be flopped if you take your signals 1 opamp earlier in the signal path than U104/U105)

    (if you going to use software make sure that you set "BPin" correctly; schematic calls for A2, its A3 in code)

    Sound support was added, you can enable/disable it in the menu. Sound does take a lot resources so if you don;t use turn it off.
    I had piezzo buzzer connected and it does not sound that good at all. Real speaker or phones would be better...

    I haven't tried the system in the field since I switched to this new algorithm, but it should be a definite improvement over the old method (laugh with me now...).

    Arduino program:
    MD_V11.zip

    Maybe I should start a new thread... Let me know... I'm not sure what is the proper board etiquette

    Leave a comment:


  • manny77
    replied
    Thanks now I understand better. Probably al these settings could make this vdi better than factory made ones, with fixed parameters etc. It is really a good sw...hope in low enough s/n from my tgsl now.

    I'll probably post a new version at some point; I'll add the sound then..
    We can add a little scope to the display with the res of 16x80 pixels, and display plots of X,R ADC values; This could be useful to make sure that opamp is setup correctly
    ...this should be a very very nice addition...hope you'll make it some day...hehe! Great programming skills you have!

    Leave a comment:


  • Daren
    replied
    Originally posted by manny77 View Post
    Oversample is the only thing not very clear...despite that your description is detailed...sorry...
    let's say oversample is 2 then the algorithm will:
    x =0; r =0;
    x = x + sample ADC channel X
    r = r + sample ADC channel R
    x = x + sample ADC channel X
    r = r + sample ADC channel R
    x = x/2
    r = r/2
    Then we proceed to use x, r as they were simple ADC samples; The idea is to sample signal multiple times thus improving ADC accuracy;
    I don't think it really adds a lot, but the we would have to use sleep to slow down the sampling. We may as well do something possibly useful; One possible test to find out if its useful is ti set oversampling to 1 and watch "raw signal" note the sigma; then bump oversampling to 10 and repeat; if oversampling makes diff, then sigma should be smaller.

    I'll probably post a new version at some point; I'll add the sound then..
    We can add a little scope to the display with the res of 16x80 pixels, and display plots of X,R ADC values; This could be useful to make sure that opamp is setup correctly

    Leave a comment:


  • manny77
    replied
    Thank you for the manual Daren! Very well accepted!

    Oversample is the only thing not very clear...despite that your description is detailed...sorry...

    Probably I get 330 in max adc because the mod I made on the feedback of U104 and U105, suggested by Silver Dollar here:

    http://www.geotech1.com/forums/showthread.php?21579-TGSL-EDU-Mod


    Perhaps the amplification is lower...anyway I add some more gain in vdi preamp, raising feedback resistors, using trimmers to adjust amplification.
    Now I get about 900 as you... I think that now works even better!

    Because you can control "min sample count" you will screen out a lot of small noise spikes even if you lower the "min signal value"
    Yes this is a very valuable setting! I'm finishing the boxing of the board...it's very rainy here in Italy...summer is still not arrived... i wanna try it on the field!

    You can easily add voice menu; use "oversampling" value as a template; add something like "int m_voiceOn;" 1 - will be voice on... If you'll have problems I can add it in...
    I'll try Daren...may I count on you otherwise? Thanks!

    Leave a comment:


  • Daren
    replied
    "Min signal" - min ADC value for X and R avoce the calibrated ADC "zero" to be considered a valid signal
    "Calib ADC zero" - "zero" ADC; calibrate no target in the field of coil
    "Calib ADC max" - ADC value when opamp maxes out; calibrate with waving big target close to coil; metal type does not matter
    "Sig end count" - number of consecutive samples with the value below "min signal" that flags "end of signal"
    "Min sample cnt" - min number of samples to be considered a valid reading
    "Max sample cnt" - max number of samples to be collected before returning a reading
    "Filter type" - sample filtering; either average or mean
    "Filter size" - filter size; bigger values smooth the signals more; too big values remove small; short signals
    "Oversampling" - number of samples X, R interleaved to be used to created single X and R "master" sample; 1 to 10 are useful values

    with oversample at set to 5 each sample takes about 1 millisecond; so sample counts ("master" sample count) can be thought of as a ms; passing target in the front of the coil takes 300-900ms (very roughly); so if you setup "Max sample count" at 1000 you should be able to catch the whole target signal; It may not be the best; smaller max counts could be better;
    single ADC conversion takes about 120us (ballpark); so with oversampling at 5 you will get total on 10 samples (5x2 because of X,R) that's ~ 1.2ms

    manny77; you should get more like 900 for the ADC "max"; 300 means that max opamp output level is low.. (do you have scope?)
    ferrite jumps from -80 to 80; its like the angle wraps around; it could be -80, -90 or 90, 80.. I don't know what to make of it.. its not a deal breaker
    You could use VDI's sound; if you optimize amp for the low signals (crank up amplification) you could probably have slightly better sensitivity than original TGSL
    ; Because you can control "min sample count" you will screen out a lot of small noise spikes even if you lower the "min signal value"
    I boxed the arduino VDI; I try to do more field testing but I don't plan on putting more time into it; The code could use refactoring; it really was a "quick and dirty"
    You can easily add voice menu; use "oversampling" value as a template; add something like "int m_voiceOn;" 1 - will be voice on... If you'll have problems I can add it in...

    Leave a comment:


  • manny77
    replied
    Thank you daren! It works on the bench!
    Lot of params...really like to have a manual to understand every menu setting....

    I try and learn but some setting was not so clear...

    What you get when calibrate max signal? Me about 330...what do you use for it? Ferrite...iron..coin...aluminium?

    Very responsive beeps now respect first version! I'd like to have a menu voice to active or turn off speaker....

    My problems are big drain of battery using 7805 external of arduino. I dont know if internal is better...7 volt drop from 12 are a lot... 7805 turn very warm....

    Other problem is ferrite...it should not give vdi but really it does... A problem in real soil?

    Seems that sensitivity of vdi and buzzer is more than tgsl itself! It should be used in normal operation to find targets? With right settings now is very fast and responsive!

    Great work mate!
    Anyway i hope this thing will be a useful addiction not only a nice thing to see...

    Leave a comment:


  • Daren
    replied
    manny77: congrats on getting it to work; the credit goes to Don, all contributors to thread "Discrimination + VDI Theory" and others here that described the concepts and built previous implementations. I'm just trying to learn more about the metal detector concepts... I can write software but my hardware knowledge is very limited.
    Here is the version that I use currently. Make sure that you calibrate the MAX ADC signal. VDI will flag the saturated samples after you do.
    The strength was redefined to simulate "distance". It is basically square root of proper strength.
    float strength = sqrt(float(Xstrength)*float(Xstrength) + float(Rstrength) * float(Rstrength));
    float distance = sqrt(strength);
    m_lcd->print(int(distance+0.5F));
    I find it more useful.
    I did some field testing, but not enough to get a feel for it. There is a lot of params to tweak, and I'm not really sure how they affect the readings in the field.
    MD_V6.zip
    Click image for larger version

Name:	IMG_1952 (Small).JPG
Views:	2
Size:	119.9 KB
ID:	341336

    Here is an idea for sound: Keep the TGSL's analog sound, but mix in the digital sound from the Arduino.

    Leave a comment:

Working...
X