Announcement

Collapse
No announcement yet.

Arduino metal detector?

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

  • #91
    fix the 8 and add a } at the end

    Comment


    • #92
      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

      Comment


      • #93
        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

        Comment


        • #94
          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<255i++) // калибровка / 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<3i++)  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 03i++) 
              {
              
          ss[i] = s[i] - c[i];
              if (
          ss[i] < 0sss[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 : (<< code) - 1;
            
          delay(1);
            
          sss[0] = 0;
            
          sss[1] = 0;
            
          sss[2] = 0;

          Comment


          • #95
            Way above my pay scale ! LOL

            Comment


            • #96
              Thanks guys for the responses, I have some results which I post individually.

              Comment


              • #97
                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<255i++) // калибровка / 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<3i++)  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 03i++) 
                    {
                    
                ss[i] = s[i] - c[i];
                    if (
                ss[i] < 0sss[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 : (<< code) - 1;
                  
                delay(1);
                  
                sss[0] = 0;
                  
                sss[1] = 0;
                  
                sss[2] = 0;

                Comment


                • #98
                  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.

                  Comment


                  • #99
                    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;
                    }
                    }

                    Comment


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

                      Comment


                      • 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

                        Comment


                        • 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

                          Comment


                          • Added Trim. Series? Parallel ? Or Replaced R8 ?

                            Looks like the output of Op Amp is ringing. That's why the Erratic indications I bet. I don't know what the Hysteresis or trigger level is on the Arduino.

                            I assume this is BreadBoard work ? Add a Integrator section with off set adjustments and I bet this thing will work quite well taming down the ring and getting the Arduino input stable.


                            Just Thinking here. Try adding like a 50pF in parallel with R8 to Integrate the signal into the Arduino. See if things tame down some.

                            Comment


                            • i replaced R8 with a trimmer to fine tune the gain i dont see no ringing it only changes when it detects metal ? the cap works to i used a 101 cap

                              Comment


                              • In your screen shot it goes from some what square wave to sign. What's that about ? Try adding the Cap. See what it does.

                                Comment

                                Working...
                                X