Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Help needed in explaining Metal detector code for Arduino. on: November 14, 2013, 09:39:12 am
Hello!
In this homepage http://dzlsevilgeniuslair.blogspot.dk/2013/07/diy-arduino-based-metal-detector.html is project for BFO metal detector for Arduino. I actually build this project already and it works.  smiley That was very educational. Now I really want to understand fully how code works. Can anybody help me with this. Down in code {i put my questions}.
As I understand in this projec small circuit generate oscillations for coil and with this code we read these oscillations and make arduino chip to do same oscillations accordingly to internal timer by pushing Null Switch. When coil is close to metal, oscillations from coil is changing and we catch difference and make clicks and detect metal. Correct me if I am wrong...

Code:
// Arduino based metal detector
// (C)Dzl july 2013
// http://dzlsevilgeniuslair.blogspot.dk/
// Connect search coil oscillator (20-200kHz) to pin 5
// Connect piezo between pin 13 and GND
// Connect NULL button between pin 12 anf GND
// REMEMBER TO PRESS NULL BUTTON AFTER POWER UP!!
#define SET(x,y) (x |=(1<<y))         //-Bit set/clear macros
#define CLR(x,y) (x &= (~(1<<y)))        // |
#define CHK(x,y) (x & (1<<y))            // |
#define TOG(x,y) (x^=(1<<y))            //-+
unsigned long t0=0;         //-Last time
int t=0;                    //-time between ints
unsigned char tflag=0;      //-Measurement ready flag

float SENSITIVITY= 1000.0;  //-Guess what

//-Generate interrupt every 1000 oscillations of the search coil {What does interrupt do in this case?}
SIGNAL(TIMER1_COMPA_vect)
{
  OCR1A+=1000;// {What is OCR1A and how it works, how values are changing?}
  t=micros()-t0;
  t0+=t;
  tflag=1;
}

void setup()
{
  pinMode(13,OUTPUT);    //-piezo pin
  digitalWrite(12,HIGH); //-NULL SW. pull up
  //-Set up counter1 to count at pin 5 {Where we declare 5 pin}
  TCCR1A=0; //{As I understand TCCR1A and TCCR1B are timers, but how we use them and what values do they give? Same question about TIMSK1,OCF1A}
  TCCR1B=0x07;
  SET(TIMSK1,OCF1A);// {What does this do?}
}

//-Float ABS
float absf(float f)
{
  if(f<0.0)
    return -f;
  else
    return f;
}

int   v0=0;  //-NULL value
float f=0;   //-Measurement value
unsigned int FTW=0;    //-Click generator rate
unsigned int PCW=0;    //-Click generator phase
unsigned long timer=0; //-Click timer

void loop()
{
  if(tflag)
  {
    if(digitalRead(12)==LOW)  //-Check NULL SW.
      v0=t;                   //-Sample new null value
    f=f*0.9+absf(t-v0)*0.1;   //-Running average over 10 samples
    tflag=0;                  //-Reset flag

    float clf=f*SENSITIVITY;  //-Convert measurement to click frequency
    if(clf>10000)           
      clf=10000;
    FTW=clf;
  }
 
  //-Click generator
  if(millis()>timer)
  {
    timer+=10;
    PCW+=FTW;
    if(PCW&0x8000)
    {
      digitalWrite(13,HIGH);
      PCW&=0x7fff;
    }
    else
      digitalWrite(13,LOW);
  }
}
2  Using Arduino / Project Guidance / Re: Arduino metal detector? on: August 08, 2013, 03:00:44 pm
Thanks! smiley
3  Using Arduino / Project Guidance / Re: Arduino metal detector? on: August 08, 2013, 11:01:07 am
I then tried an induction balance detector. I used timer 1 to generate a 62.5kHz signal, and fed this to timer 2 to generate a 7.8125kHz square wave. I tuned the Tx coil to this frequency using a parallel capacitor, and fed the square wave to the coil/capacitor via a 2.2K resistor, to get a nice 7.8kHz sine wave across the coil. I tuned the receive coil using a another parallel capacitor, and amplified it using an LM358 configured as a bandpass amplifier. Originally I used 2 stages of amplification, but 1 turned out to be sufficient (gain = 50). The output goes into the Arduino ADC, which is set to start a conversion on each cycle of the 62.5kHz signal (I ran the ADC clock at 1MHz and accepted 8-bit accuracy). So the ADC takes 8 readings per cycle, which the code accumulates into 4 bins over around 8000 samples. A little bit of processing improves the sensitivity and cancels the 3rd harmonic, calculates the amplitude measured at 4 points in the cycle, and the phase between the received and transmitted signals.

Sounds really awesome  smiley-eek. I am also interested to build metal detector using arduino but my understanding about microcontroller timing is not so good. Can You share schematic and code?
4  Using Arduino / Sensors / Re: Temperature sensor in up to 800 C degrees aplication on: January 05, 2013, 07:06:02 pm
You can also get a couple as a Sample from Maxim when I did it I got 3 of them for free. https://shop.maximintegrated.com/storefront/searchsample.do?event=Sample&menuitem=Sample&Partnumber=MAX31855KASA%2B

Yes, that's an option!  smiley-grin
5  Using Arduino / Sensors / Re: Temperature sensor in up to 800 C degrees aplication on: January 05, 2013, 06:32:10 pm
Thanks for activity.

FYI, MAX6675 has been replaced by MAX31855, which has wider temperature sensing range, better resolution, and is available in versions for several different thermocouple types. Still has an SPI interface, but the data format is changed from the MAX6675, so libraries for the earlier part will not work for the MAX31855.
I can't find MAX31855 for convenient price - around 3$.
IMHO buying
https://tindie.com/shops/TAUTIC/max31855-thermocouple-to-digital-converter/ 15$+ or
https://www.adafruit.com/products/269 17$+
is kind of wasting money...
In my case temperature range will not be higer than 800C and MAX6675 should do fine with in 1024C.

I made a break out board for the MAX31855 chip because I wanted to play with that chip too.
I have the bare board up on lish.com with the caps inductors and protector. https://dcande.lish.com/
This is almost same situation - financially disadvantageous for me:
8$ Your product + MAX31855 + shipping and I need at least 6 or 8 sets of these.

Come on guys! Do You would buy 6-8 thermometer for 120$+ ?  smiley-eek
6  Using Arduino / Sensors / Re: Temperature sensor in up to 800 C degrees aplication on: January 05, 2013, 11:03:52 am
Why not MAX6675 + analog multiplexer?

Yes, I will do so. smiley
And it will look probably something like this: http://code.google.com/p/multidisplay/wiki/TypKThermocouples
7  Using Arduino / Sensors / Re: Temperature sensor in up to 800 C degrees aplication on: January 05, 2013, 10:35:39 am
Thanks all!  smiley-kiss

For now my research end up with MAX6675 setup.
There is also simple tutorial: http://mbed.org/cookbook/MAX6675-Thermocouple.
It costs about 3.23$ per peace so this is cheaper than relay + transistor for each thermometer. smiley-cool

8  Using Arduino / Sensors / Temperature sensor in up to 800 C degrees aplication on: January 01, 2013, 05:20:58 pm
Hi all!

I have project where I need to log temperature around 600 Celsius degrees in few spots and control 220v "oven". I'm looking forward to use arduino and K type thermocouple probe's like this: http://www.ebay.com/itm/180937152179
As I understand for arduino I also need thermocouple amplifier probably like this: https://www.adafruit.com/products/269 (digital quite expensive 17.5$ per peace)

Questions:
1. Is there cheaper/alternative way to go? I need 6 - 8 spots to log so it's go around 150$ for thermometers  smiley-eek-blue
2. There is IC AD595 10$ per peace (analog). Still ~ 100$. For this IC do I really need ice point reference?
3. What would be cheapest "industrial" solution for logging stuff up to 1000C degrees?

May be You have some experiences with these or similar products and can share about reliability & accuracy & "What to do or not to do"...

Many thanks.
9  Using Arduino / General Electronics / How to power Arduino with super capacitor. on: April 02, 2012, 05:37:12 am
Hello!
What is best way to power any device with super capacitor without blowing device?
Pages: [1]