Announcement

Collapse
No announcement yet.

Arduino metal detector?

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

  • kosacid
    replied
    yes works fine but i did add a 205 trimmer to R8 and turned the trimmer till i got a flat line on the scope
    Click image for larger version

Name:	2017-05-18_132314.png
Views:	1
Size:	9.2 KB
ID:	348525
    this is when i put a coin near it
    Click image for larger version

Name:	2017-05-18_132350.png
Views:	1
Size:	10.3 KB
ID:	348527
    this is the output from the opamp to the arduino

    Leave a comment:


  • 6666
    replied
    Originally posted by 6666 View Post
    Thanks I will alter the delay and see what happens .

    The longer delay makes a difference, it is making more sense now, I will be back later

    Leave a comment:


  • 6666
    replied
    Thanks I will alter the delay and see what happens .

    Leave a comment:


  • homefire
    replied
    Try adding a few more uS of delay at each delay point. Make a Delay 1 Delay 5..


    ======


    delay(3);
    }
    c0 = c0 / 255;
    c0 = c0 - 5;
    c1 = c1 / 255;
    c1 = c1 - 5;
    c2 = c2 / 255;
    c2 = c2 - 5;


    }

    void loop()
    {
    PORTB = B11111111; // переводим пины порта B в 1, открывая т.о. ключ (turn on)
    delayMicroseconds(200); // wait 200 microseconds
    PORTB = 0; // закрывааем ключ, прерывая ток в поисковой катушке (turn off - interrupt circut in search coil )
    delayMicroseconds(20);
    s0 = analogRead(A0);
    s1 = analogRead(A0);
    s2 = analogRead(A0);
    ss0 = s0 - c0;

    if (ss0 < 0)
    {
    sss0 = 1;
    }
    ss0 = ss0 / 16;
    PORTD = ss0; // посылаем на индикатор (send to LEDs)
    delay(1);

    ss1 = s1 - c1;
    if (ss1 < 0)
    {
    sss1 = 1;
    }
    ss1 = ss1 / 16;
    PORTD = ss1; // посылаем на индикатор (send to LEDs)
    delay(1); ------------------------------------------------------------------------------------------ Add Here


    ss2 = s2 - c2;
    if (ss2 < 0)
    {
    sss2 = 1;
    }
    ss2 = ss2 / 16;
    PORTD = ss2; // посылаем на индикатор (send to LEDs)
    delay(1); -----------------------------------------------------------------------------------------------Add Here

    if ( sss0+sss1+sss2 > 1)
    {
    digitalWrite(0,HIGH);
    delay(2);
    if ( sss0+sss1+sss2 > 2)
    {
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    delay(1); ------------------------------------------------------------------------------------Add Here
    }
    if ( sss0+sss1+sss2 > 3)
    {
    digitalWrite(2,HIGH);
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    }
    if ( sss0+sss1+sss2 > 4)
    {
    digitalWrite(3,HIGH);
    digitalWrite(2,HIGH);
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    delay(1); -----------------------------------------------------------------------------------------------------Add Here
    }
    if ( sss0+sss1+sss2 > 5)
    {

    digitalWrite(4,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(2,HIGH);
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    delay(1); -------------------------------------------------------------------------------Add Here
    }
    if ( sss0+sss1+sss2 > 6)
    {

    digitalWrite(5,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(2,HIGH);
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    delay(1); ---------------------------------------------------------------------------------------Add Here
    }
    if ( sss0+sss1+sss2 > 7)
    {

    digitalWrite(6,HIGH);
    digitalWrite(5,HIGH);
    digitalWrite(4,HIGH);
    digitalWrite(3,HIGH);
    digitalWrite(2,HIGH);
    digitalWrite(1,HIGH);
    digitalWrite(0,HIGH);
    delay(1); -----------------------------------------------------------Add Here
    sss0 = 0;
    sss1 = 0;
    sss2 = 0;
    }
    }

    Leave a comment:


  • 6666
    replied
    Originally posted by kosacid View Post
    fix the 8 and add a } at the end

    Thanks for the information, yes it worked, I took a fresh copy of Homefires code in post #86 (Thanks Homey) and fixed the "8' and added an extra } at the very end of the code and it verify's and uploads to the nano, it does work a little better than the original code you can see some progression in the BRIGHTNESS and flickering of the led's, to a point, but the way the leds are so erratic its very hard to work out what the meaning of the erratic flickering leds are indicating. It was fun trying.

    Leave a comment:


  • 6666
    replied
    Thanks for the code, it will verify and upload to the nano, but all that happens with any signal input to A0, is the led that is connected to pin 2 / D0/ RX stays permanently lit and nothing else changes.





    Originally posted by Teleno View Post
    The code can be made a lot more compact.

    PHP Code:
    int s[3] = {0};
    int ss[3] = {0};
    int sss[3] = {0};
    long c[3] = {0};
    
    void setup()
      {
      DDRB = 0xFF; // port B - all out
      DDRD = 0xFF; // port D - all out
      
      for (char i = 0; i <255; i++) // калибровка / calibration
        {
        PORTB = 0b11111111; // переводим пины порта B в 1, открывая т.о. ключ (turn on)
        delayMicroseconds(200); // wait 200 microseconds
        PORTB = 0; //
        delayMicroseconds(20);
        s[0] = analogRead(A0);
        s[1] = analogRead(A0);
        s[2] = analogRead(A0);
        c[i] += s[i];
        delay(3);
      }
      for (char i = 0; i <3; i++)  c[i] = (c[i] >> 8) - 5;
    }
    
    void loop()
      {
      PORTB = 0b11111111; // переводим пины порта B в 1, открывая т.о. ключ (turn on)
      delayMicroseconds(200); // wait 200 microseconds
      PORTB = 0; // закрывааем ключ, прерывая ток в поисковой катушке (turn off - interrupt circut in search coil )
      delayMicroseconds(20);
      s[0] = analogRead(A0);
      s[1] = analogRead(A0);
      s[2] = analogRead(A0);
    
      for (char i = 0; i < 3; i++) 
        {
        ss[i] = s[i] - c[i];
        if (ss[i] < 0) sss[i] = 1;
        ss[i] = ss[i] >> 4;
        PORTD = ss[i]; // посылаем на индикатор (send to LEDs)
        delay(1);
      }
    
      int code =  sss[0] + sss[1] + sss[2];
      PORTD = (code > 8)? 0xFF : (1 << code) - 1;
      delay(1);
      sss[0] = 0;
      sss[1] = 0;
      sss[2] = 0;
    } 
    

    Leave a comment:


  • 6666
    replied
    Thanks guys for the responses, I have some results which I post individually.

    Leave a comment:


  • homefire
    replied
    Way above my pay scale ! LOL

    Leave a comment:


  • Teleno
    replied
    The code can be made a lot more compact.

    PHP Code:
    int s[3] = {0};
    int ss[3] = {0};
    int sss[3] = {0};
    long c[3] = {0};
    
    void setup()
      {
      DDRB = 0xFF; // port B - all out
      DDRD = 0xFF; // port D - all out
      
      for (char i = 0; i <255; i++) // калибровка / calibration
        {
        PORTB = 0b11111111; // переводим пины порта B в 1, открывая т.о. ключ (turn on)
        delayMicroseconds(200); // wait 200 microseconds
        PORTB = 0; //
        delayMicroseconds(20);
        s[0] = analogRead(A0);
        s[1] = analogRead(A0);
        s[2] = analogRead(A0);
        c[i] += s[i];
        delay(3);
      }
      for (char i = 0; i <3; i++)  c[i] = (c[i] >> 8) - 5;
    }
    
    void loop()
      {
      PORTB = 0b11111111; // переводим пины порта B в 1, открывая т.о. ключ (turn on)
      delayMicroseconds(200); // wait 200 microseconds
      PORTB = 0; // закрывааем ключ, прерывая ток в поисковой катушке (turn off - interrupt circut in search coil )
      delayMicroseconds(20);
      s[0] = analogRead(A0);
      s[1] = analogRead(A0);
      s[2] = analogRead(A0);
    
      for (char i = 0; i < 3; i++) 
        {
        ss[i] = s[i] - c[i];
        if (ss[i] < 0) sss[i] = 1;
        ss[i] = ss[i] >> 4;
        PORTD = ss[i]; // посылаем на индикатор (send to LEDs)
        delay(1);
      }
    
      int code =  sss[0] + sss[1] + sss[2];
      PORTD = (code > 8)? 0xFF : (1 << code) - 1;
      delay(1);
      sss[0] = 0;
      sss[1] = 0;
      sss[2] = 0;
    } 
    

    Leave a comment:


  • homefire
    replied
    Hope this does the job. Modified the Digital Write to progress in step with Int ss levels keeping LED's ON until end of cycle at which time they are cleared.

    You said LED were Jumping. Did you wire LED in sequence ? On the NANO D0 and D1 are Reversed.

    I'm a NU BEE at this Arduino thing too so I hope I got this right.






    ArduinoNano30Schematic.pdf

    RussianPIModifiedCode1.txt

    Leave a comment:


  • homefire
    replied
    Just scratch that . I used cut and past to copy the Write to commands and forgot to delete the Clear commands on each step so it would never see any progression. I'll correct it and post as attachment. Sorry. http://www.pacdv.com/sounds/fart-sounds/fart-7.mp3

    Leave a comment:


  • kosacid
    replied
    fix the 8 and add a } at the end

    Leave a comment:


  • Qiaozhi
    replied
    Originally posted by 6666 View Post
    Thanks for the tip about the glasses, I fixed that part of the code but it still says an error somewhere here is the error message

    Arduino: 1.6.11 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Felz\sketch_may01a\sketch_may17a\sketch_may17a\ sketch_may17a.ino: In function 'void loop()':

    sketch_may17a:168: error: expected '}' at end of input

    }

    ^

    exit status 1
    expected '}' at end of input

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    Sorry - I cannot help you with that, as I've never used an Arduino.

    Leave a comment:


  • 6666
    replied
    Thanks for the tip about the glasses, I fixed that part of the code but it still says an error somewhere here is the error message

    Arduino: 1.6.11 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Felz\sketch_may01a\sketch_may17a\sketch_may17a\ sketch_may17a.ino: In function 'void loop()':

    sketch_may17a:168: error: expected '}' at end of input

    }

    ^

    exit status 1
    expected '}' at end of input

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    Leave a comment:


  • Qiaozhi
    replied
    Originally posted by 6666 View Post
    Thanks for the code, but there is a small error when I try and verify the code here is the error message (there is a smiley face in the code would that cause a problem ?)

    Arduino: 1.6.11 (Windows 7), Board: "Arduino Nano, ATmega328"

    C:\Felz\sketch_may01a\sketch_may17a\sketch_may17a. ino: In function 'void loop()':

    sketch_may17a:154: error: expected primary-expression before '{' token

    {

    ^

    sketch_may17a:154: error: expected ')' before '{' token

    sketch_may17a:168: error: expected primary-expression before '}' token

    }

    ^

    sketch_may17a:168: error: expected '}' at end of input

    exit status 1
    expected primary-expression before '{' token
    You need to replace with "8" followed by ")".
    The bulletin board interprets this as "glasses".

    Leave a comment:

Working...
X