Announcement

Collapse
No announcement yet.

Arduino Mini MDee

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

  • #16
    Code:
    #include <LiquidCrystal.h>
    
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
    
    int Coil =  13;      // the number of the Coil pin
    int led = 10;        // detection led can add a buzzer here
    int analogPin = 0;   // pin to read the samples
    int cSamples = 20;  // how much samples are taken the lower its set the faster the samples more ustable though 10 min
    int SampleDelay = 0;  // delay before gathering the samples adjustable via the buttons
    int SampleCounter = 0;
    float tempc = 0.0f;
    float Sensor = 1.0f;  // default sensor offset adjustable via buttons
    float testresults = 0.0f;
    float cal = 0.0f;  // store the calibration setting
    float val = 0.0f;
    float readSamples = 0.0f;
    float results = 0.0f;
    bool calibrate = false;
    
    int button_up_Sensor = 7;
    int button_down_Sensor = 6;
    int button_up_SampleDelay = 9;
    int button_down_SampleDelay = 8;
    
    void setup ()
    {
      lcd.begin(16, 2);
      pinMode(Coil, OUTPUT);
      pinMode(led, OUTPUT);
      pinMode (A0, INPUT);
      Serial.begin (115200);
    }
    
    void loop ()
    {
      
      digitalWrite(Coil, HIGH);
      delayMicroseconds(50); // how long the gate is open to charge the coil
      digitalWrite(Coil, LOW);
      delayMicroseconds(SampleDelay);
      for(int i = 0; i < cSamples; i++)
      {
        val = analogRead(analogPin);
        readSamples+=val;
        val = 0.0f;
      }
      
      results = (readSamples/cSamples);
      
      if(results < 0.0f)
      {
        results = fabsf(results); // if the results are - flip them to +
      }
    
      if(SampleCounter <= cSamples)
      {
        tempc += results; // recast to a int easy to deal with the display
        SampleCounter++;
      }else
      {
        if(calibrate == false)
        {
          cal = tempc/cSamples;
          calibrate = true;
          lcd.setCursor(0, 1);
          lcd.print("          ");
          lcd.setCursor(0, 1);
          lcd.print("CL ");
          lcd.print(cal);
        }
        testresults = tempc/cSamples;
        lcd.setCursor(0, 0);
        lcd.print("          ");
        lcd.setCursor(0, 0);
        lcd.print("DP ");
        lcd.print(testresults);
        digitalWrite(led, LOW);
        if(cal > (testresults + Sensor) || cal < (testresults - Sensor)) digitalWrite(led, HIGH);
        tempc = 0;
        SampleCounter = 0;
      }
      
      
      readSamples = 0.0f;
    
      if(digitalRead(button_up_Sensor) == HIGH)
      {
        Sensor+=0.1f;
        lcd.setCursor(10, 0);
        lcd.print("         ");
        lcd.setCursor(10, 0);
        lcd.print("SN ");
        lcd.print(Sensor);
        digitalWrite(Coil, LOW);
        delay(200);
      }
    
      if(digitalRead(button_down_Sensor) == HIGH)
      {
        Sensor+=-0.1f;
        lcd.setCursor(10, 0);
        lcd.print("         ");
        lcd.setCursor(10, 0);
        lcd.print("SN ");
        lcd.print(Sensor);
        digitalWrite(Coil, LOW);
        delay(200);
      }
    
      if(digitalRead(button_up_SampleDelay) == HIGH)
      {
        SampleDelay++;
        lcd.setCursor(10, 1);
        lcd.print("      ");
        lcd.setCursor(10, 1);
        lcd.print("SM ");
        lcd.print(SampleDelay);
        digitalWrite(Coil, LOW);
        delay(200);
        calibrate = false;
      }
    
      if(digitalRead(button_down_SampleDelay) == HIGH)
      {
        SampleDelay--;
        if(SampleDelay < 0)SampleDelay = 0;
        lcd.setCursor(10, 1);
        lcd.print("      ");
        lcd.setCursor(10, 1);
        lcd.print("SM ");
        lcd.print(SampleDelay);
        digitalWrite(Coil, LOW);
        delay(200);
        calibrate = false;
      }
    }

    Comment


    • #17
      Can you make short video demonstration?

      Comment


      • #18
        https://youtu.be/pmXeZw5gbeE
        i gave it a test im using a 6" 350mh coil the gold ring detects at 7" solid at 6", the buckle at 8" a coke can at 13" i need to build it up for ground tests
        and fix the calibration just now clicking the SM up and down calibrates it, i think i will add a average there DP CL must be a close as it can then adjust SN
        its adding a buzzer im having problems with it sends ripples through the detector disrupting the detection need ideas on that one

        Comment


        • #19
          Originally posted by kosacid View Post
          https://youtu.be/pmXeZw5gbeE
          i gave it a test im using a 6" 350mh coil the gold ring detects at 7" solid at 6", the buckle at 8" a coke can at 13" i need to build it up for ground tests
          and fix the calibration just now clicking the SM up and down calibrates it, i think i will add a average there DP CL must be a close as it can then adjust SN
          its adding a buzzer im having problems with it sends ripples through the detector disrupting the detection need ideas on that one

          Comment


          • #20
            Originally posted by kosacid View Post
            https://youtu.be/pmXeZw5gbeE
            i gave it a test im using a 6" 350mh coil the gold ring detects at 7" solid at 6", the buckle at 8" a coke can at 13" i need to build it up for ground tests
            and fix the calibration just now clicking the SM up and down calibrates it, i think i will add a average there DP CL must be a close as it can then adjust SN
            its adding a buzzer im having problems with it sends ripples through the detector disrupting the detection need ideas on that one

            What was happening around .37 in the video ?

            Comment


            • #21
              I suppose "..a coke can at 13"...

              Comment


              • #22
                yes the can lol it would not fit in, im not very good at making videos can you tell

                Comment


                • #23
                  Originally posted by kosacid View Post
                  yes the can lol it would not fit in, im not very good at making videos can you tell

                  OK , looks like a good project.

                  Comment


                  • #24
                    Code:
                    #include <LiquidCrystal.h>
                    
                    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
                    int Coil = 13;
                    int led = 10;        // detection led can add a buzzer here
                    int analogPin = 0;   // pin to read the samples
                    int Counter = 10; // main sample counter
                    int SampleCounter = 0;
                    int SampleDelay = 0;
                    float tempc = 0.0f;
                    float Sensor = 0.0f;  // default sensor offset adjustable via buttons
                    float testresults = 0.0f;
                    float cal = 0.0f;  // store the calibration setting
                    int val = 0;
                    float results = 0.0f;
                    bool calibrate = false;
                    
                    int button_up_Sensor = 7;
                    int button_down_Sensor = 6;
                    int button_up_SampleDelay = 9;
                    int button_down_SampleDelay = 8;
                    
                    void setup ()
                    {
                      lcd.begin(16, 2);
                      pinMode(Coil, OUTPUT);
                      pinMode(led, OUTPUT);
                      pinMode (A0, INPUT);
                      Serial.begin (115200);
                    }
                    
                    void loop ()
                    {
                      digitalWrite(Coil, HIGH);
                      delayMicroseconds(60); // charge the coil
                      digitalWrite(Coil, LOW);
                      delayMicroseconds(SampleDelay);
                      val = analogRead(analogPin);
                      results = val * (5.0 / 1023.0);
                      val = 0;
                      
                      if(SampleCounter <= Counter)
                      {
                        tempc += results;
                        SampleCounter++;
                      }else
                      {
                        
                        testresults = tempc/Counter;
                        if(calibrate == false)
                        {
                          cal = testresults;
                          calibrate = true;
                          lcd.setCursor(0, 1);
                          lcd.print("       ");
                          lcd.setCursor(0, 1);
                          lcd.print("CL ");
                          lcd.print(cal);
                        }
                        lcd.setCursor(0, 0);
                        lcd.print("       ");
                        lcd.setCursor(0, 0);
                        lcd.print("DP ");
                        lcd.print(testresults);
                        digitalWrite(led, LOW);
                        if(cal > (testresults + Sensor) || cal < (testresults - Sensor)) digitalWrite(led, HIGH);
                        tempc = 0;
                        SampleCounter = 0;
                      }
                      
                      if(digitalRead(button_up_Sensor) == HIGH)
                      {
                        Sensor+=0.001f;
                        lcd.setCursor(8, 0);
                        lcd.print("         ");
                        lcd.setCursor(8, 0);
                        lcd.print("SN ");
                        lcd.print(Sensor);
                        delay(150);
                      }
                    
                      if(digitalRead(button_down_Sensor) == HIGH)
                      {
                        Sensor+=-0.001f;
                        lcd.setCursor(8, 0);
                        lcd.print("         ");
                        lcd.setCursor(8, 0);
                        lcd.print("SN ");
                        lcd.print(Sensor);
                        delay(150);
                      }
                    
                      if(digitalRead(button_up_SampleDelay) == HIGH)
                      {
                        SampleDelay++;
                        lcd.setCursor(8, 1);
                        lcd.print("      ");
                        lcd.setCursor(8, 1);
                        lcd.print("SD ");
                        lcd.print(SampleDelay);
                        digitalWrite(Coil, LOW);
                        delay(200);
                        calibrate = false;
                      }
                    
                      if(digitalRead(button_down_SampleDelay) == HIGH)
                      {
                        SampleDelay--;
                        if(SampleDelay < 0)SampleDelay = 0;
                        lcd.setCursor(8, 1);
                        lcd.print("      ");
                        lcd.setCursor(8, 1);
                        lcd.print("SD ");
                        lcd.print(SampleDelay);
                        digitalWrite(Coil, LOW);
                        delay(200);
                        calibrate = false;
                      }
                      delayMicroseconds(1666-SampleDelay);
                    }
                    arduino_mdee_final.zip

                    think thats the best you will get out a arduino just adjust the trimmer until you get a steady 2v after the pulse then your setup

                    Comment


                    • #25
                      Is this how you wire the LCD ?

                      * LCD RS pin to digital pin 12
                      * LCD Enable pin to digital pin 11
                      * LCD D4 pin to digital pin 5
                      * LCD D5 pin to digital pin 4
                      * LCD D6 pin to digital pin 3
                      * LCD D7 pin to digital pin 2
                      * LCD R/W pin to ground
                      * LCD VSS pin to ground
                      * LCD VCC pin to 5V
                      * 10K resistor:
                      * ends to +5V and ground
                      * wiper to LCD VO pin (pin 3)

                      Comment


                      • #26
                        the digram is in the link further up the hello world link, you can remove the delay buttons if you have a scope and manually set the delay where you want it to detect, i changed everything so its detecting voltage, the range is from 0v to 4v and all timings you should be able to relate with a scope
                        @ivconic
                        Timer1.initialize(1666); // 600Hz
                        Timer1.pwm( 13, 50);
                        Timer1.attachInterrupt(callback,1666+SampleDelay);
                        i tested that but had synce problems with the main loop

                        Comment


                        • #27
                          Code:
                          int calibrationcounter = 0;
                          int Coil = 13;
                          int led = 10;        // detection led can add a buzzer here
                          int analogPin = 0;   // pin to read the samples
                          int Counter = 10; // main sample counter
                          int SampleCounter = 0;
                          int SampleDelay = 115;
                          float tempc = 0.0f;
                          float Sensor = 0.1f;  // default sensor offset adjustable via buttons
                          float testresults = 0.0f;
                          float cal = 0.0f;  // store the calibration setting
                          int val = 0;
                          float results = 0.0f;
                          bool calibrate = false;
                          
                          void setup ()
                          {
                            pinMode(Coil, OUTPUT);
                            pinMode(led, OUTPUT);
                            pinMode (A0, INPUT);
                            Serial.begin (115200);
                          }
                          
                          void loop ()
                          {
                            digitalWrite(Coil, HIGH);
                            delayMicroseconds(60); // charge the coil
                            digitalWrite(Coil, LOW);
                            delayMicroseconds(SampleDelay);
                            val = analogRead(analogPin);
                            results = val * (5.0 / 1023.0);
                            val = 0;
                            
                            if(SampleCounter <= Counter)
                            {
                              tempc += results;
                              SampleCounter++;
                            }else
                            {
                              
                              testresults = tempc/Counter;
                              if(calibrationcounter >= 50)
                              {
                                if(calibrate == false)
                                {
                                  cal = testresults;
                                  calibrate = true;
                                }
                                calibrationcounter=0;
                              }
                              digitalWrite(led, LOW);
                              if(cal > (testresults + Sensor) || cal < (testresults - Sensor)) digitalWrite(led, HIGH);
                              tempc = 0;
                              SampleCounter = 0;
                              calibrationcounter++;
                            }
                            delayMicroseconds(1666-SampleDelay);
                          }
                          this is what im using for my pinpointer no buttons or display just using a nano

                          Comment


                          • #28
                            arduino_mdee_pinpointer.zip
                            https://youtu.be/F9I11qfqrA8
                            Code:
                            int calibrationcounter = 0;
                            int Coil = 13;
                            int led = 10;
                            int analogPin = 0;
                            int Counter = 10;
                            int SampleCounter = 0;
                            int SampleDelay = 120;
                            float tempc = 0.0f;
                            float Sensor = 0.1f;
                            float testresults = 0.0f;
                            float cal = 0.0f;
                            int val = 0;
                            float results = 0.0f;
                            bool calibrate = false;
                            
                            void setup ()
                            {
                              pinMode(Coil, OUTPUT);
                              pinMode(led, OUTPUT);
                              pinMode (A0, INPUT);
                              Serial.begin (115200);
                            }
                            
                            void loop ()
                            {
                              digitalWrite(Coil, HIGH);
                              delayMicroseconds(40); // charge the coil
                              digitalWrite(Coil, LOW);
                              delayMicroseconds(SampleDelay);
                              val = analogRead(analogPin);
                              results = val * (5.0 / 1023.0);
                              val = 0;
                              
                              if(SampleCounter <= Counter)
                              {
                                tempc += results;
                                SampleCounter++;
                              }else
                              {
                                
                                testresults = tempc/Counter;
                                if(calibrationcounter >= 35)
                                {
                                  if(calibrate == false)
                                  {
                                    cal = testresults;
                                    calibrate = true;
                                  }
                                  calibrationcounter=0;
                                }
                                digitalWrite(led, LOW);
                                if(cal > (testresults + Sensor) || cal < (testresults - Sensor)) digitalWrite(led, HIGH);
                                tempc = 0;
                                SampleCounter = 0;
                                calibrationcounter++;
                              }
                              delayMicroseconds(1626-SampleDelay);
                            }
                            i had to change the digram for some reason the coil pulls to much power and slows the arduino down so added a 100ohm resistor and pulled out the damping resistor it runs on a pp3 so any improvements will be appreciated
                            forgot to add you can use about any coil on it i had a few on it of different uh they all work

                            Comment


                            • #29
                              Could you please provide a PCB Trace only so I can burn a board ?

                              Comment


                              • #30
                                arduino_mdee_pinpointer.zip
                                arduino_mdee_final.zip
                                i haven't got to the pcb stage yet i used strip board
                                Click image for larger version

Name:	pinpointer.jpg
Views:	1
Size:	84.9 KB
ID:	348382
                                as you can see it fits in that cheap pointer box and when i get some etching stuff i will make a smt version using a smt fet
                                also i updated the layout it looked like the + rail joined to the output

                                Comment

                                Working...
                                X