Announcement

Collapse
No announcement yet.

Arduino based VDI!

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

  • #16
    Don I was curious how you got around the ...

    " Problems I ran into were determining how long to sample each channel and inconsistent calculations using floating point numbers. "

    thats all. Ive struggled with 2byte math on a picaxe before!


    Is this in C code ?

    Can you post the header file .h content please. !



    You mention..
    You CAN translate that into an angle using the ARCTAN function and I think that's what others are doing

    Yes I also think Tan-1 is what is used.

    I THINK most Rx have quadrature L.O. so the Rx outputs are in quadrature this gets the genuine phase angle x degrees = Tan-1 (b/a) to give the phase of target.

    Targets like pure Silver have a response way over to RHS so you get a long a vector and a relatively short b vector


    ^ . ->
    . b .
    . . )
    . . x degrees )
    ..........................................)....... ........>
    a

    You see here that alloys worth digging always have a shorter b vector to boost resolution/accuracy you may scale up the b vector (maybe not necassary)?

    Steve

    Comment


    • #17
      add pic

      pic
      Attached Files

      Comment


      • #18
        Originally posted by golfnut View Post
        pic
        Exactly!

        As far as floating point numbers go, I'm not much of a whiz when it comes to programming. I hacked around until I figured out what worked and what did not. While reading about "C" programming and floating point numbers some people pointed out that you can get some really strange results when doing math functions with floating point numbers. I think I just used integers where possible before dividing, etc.

        If you monitor your channels on a scope and plot on on the X axis and one on the Y axis, the vector created by the combination of the two will advance somewhere between 0 and 90 degrees, for non ferrous items. During that time, I found that I can generally sample the vector around 95 times (with the Arduino UNO) before I begin to get funky results, possibly because things settle down or swing slightly negative.
        Up to about 85 samples, things become increasingly accurate.. to the point where U.S. coins will give a VDI reading with an accuracy of + or - 1!! I attempted to put as many comments as possible in the code to explain what is going on. Feel free to change anything you want.

        Anyway, here is a later rev of the code I am running on the Arduino, if that is what you are using, you can cut and paste it right into the compiler. I'm not "including" any .h files.
        Depending on what LCD display you might use, things may be wired differently, but I borrowed from this site for mine:
        http://www.hacktronics.com/Tutorials...-tutorial.html

        Don
        Attached Files

        Comment


        • #19
          I have not gone down this path yet
          but found a good starter page, the info on software setup is near the bottom of the page.


          http://www.hacktronics.com/Tutorials...shing-led.html



          Don is this the same as yours?, for $20 I will get one , onlooking around the net they seem to be changing the PCB and the chip, looks like R3 is latest.
          http://www.ebay.com.au/itm/Arduino-2...item3f17ad1af4


          "The latest board continues to be based on the ATMega328, with the major change being the replacement of the FTDI chip in favor of an ATmega8U2."

          Comment


          • #20
            Quality.


            I must commend your spirit taking this on.. I wrote C commercially for a year and now it all looks like jibberish - its alarming how I forget stuff.



            However - there is a an entry in the first line of the code which says..

            #include <LiquidCrystal.h>

            This is a separate file used around the build/compile time - it must be available to your build system or it would not compile! This is the file that is referenced in your build but I cant see its content, thats all. It probably helps the lcd to run.

            Comment it out and see if the build and the product works without out it and we can all remove it too!

            That would be mega helpful.


            With hardware platforms a cheap one is the Ti Launchpad. UK price £4 USA $3.85

            you get a small board, 2 msp 430 DIL Ics, a USB lead, and there is an IDE fron IAR free.


            Steve

            Comment


            • #21
              arduino

              hello can you tell me please which of these is like yours?

              http://www.ebay.com/itm/EKitsZone-UN...item43ac7346e9

              http://www.ebay.com/itm/New-UNO-ATME...item3cc7cc0938

              http://www.ebay.com/sch/i.html?_nkw=...0906&_osacat=0

              Comment


              • #22
                Originally posted by 6666 View Post
                I have not gone down this path yet
                but found a good starter page, the info on software setup is near the bottom of the page.


                http://www.hacktronics.com/Tutorials...shing-led.html



                Don is this the same as yours?, for $20 I will get one , onlooking around the net they seem to be changing the PCB and the chip, looks like R3 is latest.
                http://www.ebay.com.au/itm/Arduino-2...item3f17ad1af4


                "The latest board continues to be based on the ATMega328, with the major change being the replacement of the FTDI chip in favor of an ATmega8U2."
                That looks like the one I bought - the ATMega328 UNO from Radio Shack.

                Don

                Comment


                • #23
                  Launchpad MSP430

                  Keep a look out for the Texas Instruments Launchpad dev board.

                  You get a pcb, headers, 2 micros, USB lead for sub $4

                  ics are generally 10bit atod. some 12bit


                  Download the IAR dev suite for free (code limited)


                  I have one and I have done the flash a led program - need to get AtoDs going, and LCD display. Im going to use a nokia phone lcd as 3V to go with the micro.

                  Maybe never get it all going but fun trying.

                  S

                  Comment


                  • #24
                    Different sounds for different targets.. Please!!!!!!!

                    Thank you for the great !!!! OPEN SOURCE !!!! project.

                    Sound, sound, sound!!! How about to convert VDI numbers into some sound sequences and listen to the music instead of STOPPING and STARING on LCD 1000 times in shiny summer day like other Whites users.
                    After years of using Garret ACE 250 I can say that I am looking on LCD only to change settings because it makes different sounds for different targets. So I never stop for trash target that saving 50% of my time.

                    Comment


                    • #25
                      header file

                      Hi Don, the code you posted has this line at the top..

                      #include <LiquidCrystal.h>




                      LiquidCrystal.h is another file in your build area - it will have been supplied when you set your project area.

                      If you do a quick search for it and post we can use it too.

                      (If we use the same LCD that is!)

                      Stil waiting on my LCD displays from a scotland firm called Metatech (cheap Nokia parts ) poor service.


                      Steve

                      Comment


                      • #26
                        Originally posted by golfnut View Post
                        Hi Don, the code you posted has this line at the top..




                        #include <LiquidCrystal.h>

                        LiquidCrystal.h is another file in your build area - it will have been supplied when you set your project area.

                        If you do a quick search for it and post we can use it too.

                        (If we use the same LCD that is!)

                        Stil waiting on my LCD displays from a scotland firm called Metatech (cheap Nokia parts ) poor service.


                        Steve
                        Hi Steve! I downloaded the LCD code directly from here:

                        http://www.hacktronics.com/Tutorials...-tutorial.html

                        From this, I just just built the rest of the program around it.

                        But, I see your point. I just loaded it and there is no "sketch folder" in my Arduino app that shows the extra .h files so I'm wondering if it's leftover from something . I would expect the LCD library to have a .ino extension and then have it imported. I left that line in anyway(#include <LiquidCrystal.h>).


                        I'm wondering if you can add a sketch folder separately from here:

                        http://arduino.cc/en/Tutorial/LiquidCrystal

                        My understanding is that the libraries are just extra lines of code left out to simplify everything when you get started. Then you can add sketch folders later. But can't you just add the extra lines of code to the main body of the program?

                        Don

                        Don

                        Comment


                        • #27
                          Qu for Don

                          Hi, recently MSP430 Launchpad ( $4 ) sampling an a2d channel 10bits (1024 step) and wondered how you do the two channels!

                          I mean - do you sample your X-R channels at exact same time.? So you are sampling phase relationship between X-R at that same instant in time...

                          Or do you mux 2 analog channels to a single a2d, and toggle channel select, so read and convert the two input channels alternately..


                          Steve

                          Comment


                          • #28
                            Originally posted by golfnut View Post
                            Hi, recently MSP430 Launchpad ( $4 ) sampling an a2d channel 10bits (1024 step) and wondered how you do the two channels!

                            I mean - do you sample your X-R channels at exact same time.? So you are sampling phase relationship between X-R at that same instant in time...

                            Or do you mux 2 analog channels to a single a2d, and toggle channel select, so read and convert the two input channels alternately..


                            Steve

                            Steve,

                            I think the Arduino can only execute one line of code at a time, so I'm not sure how long it takes to sample both A0 and A1. I have attached my latest.. It ID's US coins pretty accurately and displays nothing if it comes across something that is Discriminated.
                            Don


                            #include <LiquidCrystal.h>
                            // Connections:
                            // rs (LCD pin 4) to Arduino pin 12
                            // rw (LCD pin 5) to Arduino pin 11
                            // enable (LCD pin 6) to Arduino pin 10
                            // LCD pin 15 to Arduino pin 13
                            // LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
                            LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); // assign liquid crystal pins
                            int backLight = 13; // pin 13 will control the backlight
                            // Sensors
                            int sensorPinx = A0; // Intialize analog pin A0 and name it "sensorPinx" for the all metal channel
                            int sensorPinr = A1; // Intialize analog pin A1 and name it "sensorPinr" for the all disc channel
                            //Variables
                            float sensorValuex = 0; // assign a floating point value of "0" to a variable called "sensorValuex"
                            float sensorValuer = 0; // assign a floating point value of "0" to a variable called "sensorValuer"
                            float slope; // assign a floating point value of "0" to a variable called "slope"
                            int n = 0; // assign an integer value of "0" to a variable called "n"
                            int cursorClmn = 0; // assign an integer value of "0" to a variable called "cursorClmn"
                            int numSamples = 0; // assign an integer value of "0" to a variable called "numsamples"
                            float slopeTotals; // assign an integer value of "0" to a variabel called "slopeTotals"
                            float slopeAve = 0; // assign an integer value of "0" to a variable called "slopeAve"
                            int VDI = 0; // assign an integer value of "0" to a variable called "VDI"


                            // program setup follows
                            void setup()
                            {
                            pinMode(backLight, OUTPUT);
                            digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
                            lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
                            lcd.clear(); // start with a blank screen
                            lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
                            lcd.print( " VDI Project "); // print whatever you want
                            lcd.setCursor(0,1); // set cursor to column 0, row 1
                            lcd.print("running 05152012"); // print whatever you want
                            delay (2000); // wait 1 second
                            lcd.clear(); // Clear the LCD



                            }

                            // The main loop follows
                            void loop()
                            {
                            first: //This is a label called "first" so a goto statement can find the beginning of the loop when called
                            sensorValuex = analogRead (sensorPinx); //Read the analog pin A0 and store it's value as sensorValuex (it will be between 0 and 1023)
                            sensorValuer = analogRead (sensorPinr); //Read the analog pin A1 and store it's value as sensorValuer (it will be between 0 and 1023)
                            //Change SensorValues below to adjust VDI sensitivity
                            if (sensorValuex > 5) { //If this sensorvalue becomes > 5 it executes the next line. If not, it drops to the "else" statement and goes to the beginning again ("first")
                            if (sensorValuer > 5) { //If this sensorvalue becomes > 5 it executes the next line. If not, it drops to the "else" statement and goes to the beginning again ("first")
                            for (int n = 0 ; n < 85 ; n ++) //Starts a counter to read the sensors again in a loop 85 times
                            reread: //A label called reread will check sensors again if a floating point calulation is bad {0 value)
                            {
                            sensorValuex = analogRead(sensorPinx); //Read the analog pin A0 and store it's value as sensorValuex (it will be between 0 and 1023)
                            sensorValuer = analogRead (sensorPinr); //Read the analog pin A1 and store it's value as sensorValuer (it will be between 0 and 1023)
                            slope=sensorValuer / sensorValuex; // calculate X/R ratio and call it "slope"
                            if (slope ==0) {
                            goto reread;
                            }
                            slopeTotals = slopeTotals + slope;
                            }


                            }

                            }
                            else {
                            goto first; // runs a loop until the sensors become low again
                            }
                            slopeAve = slopeTotals/85; // take all the slope values and average them.
                            VDI = ((10 - slopeAve) * 10);
                            // you can manipulate the range of how your VDI numbers are calulated by changing the line below

                            cursorClmn = (10 - slopeAve); // slopeAve will typically be between .1 and 9. It just converts it to an integer number between 1 and 10.. used to position the "*" character
                            tone (8 , (cursorClmn * 200), 100); // produces a tone of 200 Hz X the mumber above for 100 mS
                            lcd.clear(); //clear LCD
                            if (VDI > 98 ) {
                            lcd.clear();
                            goto finish;
                            }
                            lcd.setCursor(0,0); //Set cursor on line 0, column 0
                            lcd.print("VDI = "); // print "VDI ="
                            lcd.print (VDI) ; // prints the calculated number following "VDI ="
                            lcd.setCursor(9,0);
                            //if (VDI = 100 ); {
                            // lcd.clear();
                            // goto finish;
                            //}
                            if ( VDI > 85 ) {
                            lcd.print("Quarter");
                            goto DonePrinting;
                            }
                            if ( VDI > 80 ) {
                            lcd.print ("Dime");
                            goto DonePrinting;
                            }
                            if ( VDI > 71) {
                            lcd.print ("Penny");
                            goto DonePrinting;
                            }
                            if (VDI > 70) {

                            goto DonePrinting;
                            }
                            if (VDI > 65) {
                            goto DonePrinting;
                            }
                            if (VDI > 60) {

                            goto DonePrinting;
                            }
                            if (VDI > 47) {
                            goto DonePrinting;
                            }
                            if (VDI > 39) {
                            lcd.print ("Nickel");
                            goto DonePrinting;
                            }
                            if (VDI > 30) {

                            goto DonePrinting;
                            }
                            if (VDI > 0) {
                            lcd.setCursor (10,0);
                            lcd.print ("Foil");
                            goto DonePrinting;
                            }

                            DonePrinting:
                            lcd.setCursor(cursorClmn,1); // Positions the cursor on a particular column on row 1
                            lcd.print ("*"); // prints the "*" character in that partular column
                            finish:
                            delay (100); // display the VDI numbers for 100 mS before going to the beginning of the code again
                            numSamples = 0; // reset all numbers back to "0"
                            slopeTotals = 0;
                            slopeAve = 0;
                            slope = 0;

                            }

                            Comment


                            • #29
                              Latest Arduino code for VDI module

                              I actually finished my IDX + Arduino UNO project. Below is the link for what the code in the previous post actually does. Neat thing is, you can program it to ID anything you want if you know the VDI range.


                              http://youtu.be/5j_XM0L0BKg



                              Don
                              Attached Files

                              Comment


                              • #30
                                Good work!

                                How to install 128*64 graphics display in this VDI?

                                Comment

                                Working...
                                X