Hello,
I'm doing a wire following robot with arduino, i made an EMF detector (this circuit: http://electronicsforu.com/electronicsforu/circuitarchives/view_article.asp?sno=1330&article_type=1&id=798) and i connected the output to an led and verified that it is working, but when i connected the output of this circuit to the arduino analog pin the reading got fluctuating i'm getting the correct value sometimes, but it is decreasing suddenly to a value less than 100 and then increasing to the original value, i added a 0.1uf capacitor in between the analog pin and the ground but the problem is not solved yet. What is the reason for this fluctuation? is there any solution for this
thank you
There is a part missing from that device that might prove crucial especially with a used or really old battery and that's 2 bypass capacitors, one ssould be about 100-220 uF 15V and the other should be a .1uF cap. The large capacitor is for batteries with high internal resistance, older or cheap 9V battteries. The higher internal resistance will allow a dc voltage equal to the current times the resistance of the battery which is made from 6 to (1.6V New Alkaline) to 7 (1.2V Ni-Cd) batteries. adding the large capacitor can increase the 'apparent' battery life by 25% or more. Adding the .1uF is automatic and used for lowering the supply impedance at higher frequencies for nearly the same reason as the higher value capacitor except in this case it has to do with the inductance of the battery wiring from PCB to cell (battery) and in-between cells or the inductive reactance of the battery which appears as a resistance that varies in value as the frequency varies. This effect, the inductive reactance can show in many ways, poor response, a continual 'background reading with no antenna or sniffer probe attached or just plain unstable reading.
There is a third issue here in that the ground or return for the 'EMF' detector is implied as your body.
It is my personal opinion that what you are trying to so with this EMF sensor might well be troublesome for the reasons I mentioned above especially the ground return.
Bob
When you connect the output of the circuit to the arduino you must also wire the -ve of the battery to the arduino ground. Are you doing that?
Yes, i have connected the negative to the arduino.
when i'm continually applying EMF to the circuit and reading the analog value from the value i got i fluctuating like this
value=39
value=37
value=45
value=50
value=37
value=49
value=75
value=50
value=49
value=99
value=153
value=182
value=218
value=227
value=1023
value=1023
value=1023
value=1023
value=1023
value=1023
value=1023
value=1023
value=1023
value=490
value=209
value=91
value=54
value=45
value=44
value=42
value=38
value=367
value=432
value=383
value=359
value=349
after showing that 1024 value it suddenly changes to a lower value and then increase again, y is it o??plz help
You shouldn't drive 9V into arduino analog input, use voltage divider.
Just looked at the circuit. It will do this because that is the signal being put into the LED in the first place. You don't see it because it is changing too fast for the eye.
Add a series diode and a 10K resistor to the input, then 10 k pull down with a 0.1uF cap across the input.
If you connect the anode of the LED to the arduino then that will be fine because it will never go over the forward volts drop. However your readings of 1023 suggest you are not doing this.
BTW, arduino has 100 Mega-ohms input impedance on DC, close to that on 50 Hz AC.
There is much simpler solution :
I had a go at using the Arduino ADC to detect emf sensed from a mains cable, but I didn't find it very satisfactory. The problem was that with such a high resistance to ground (I needed 10M or more to get good sensitivity), I found that the ADC reading hovered around 50 even with no signal. This happened when I read no other ADC input pins in the sketch, and also when I read a grounded ADC pin prior to reading the antenna pin. The sensitivity was not very good, for example if I set a threshold of 100 then the cable had to be very close to the antenna indeed.
I had much better results when I used the analog comparator for emf detection. This is the sketch I used. The hardware setup is described in the comments. I included the 470pF capacitor to reduce the sensitivity to radio signals.
// Mains detector sketch
// Hardware configuration:
//
// AIN0 (aka digital pin 6) to antenna, 4M7 resistor to ground, and 470pF capacitor to ground
// AIN1 (aka digital pin 7) to 10K resistor to ground and 1M resistor to +5V (giving 50mV on the pin)
// You can adjust the voltage on the pin to get the required sensitivity (lower voltage = more sensitive)
// LED and series resistor between digital pin 13 and ground (already on Uno)
const int ledPin = 13;
bool active = false;
unsigned long lastActiveTime = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
ACSR = 0;
DIDR1 = AIN1D | AIN0D;
}
void loop()
{
unsigned long now = micros();
if (ACSR & 0x20)
{
// Voltage detected
active = true;
lastActiveTime = now;
digitalWrite(ledPin, HIGH);
}
else if (active && now - lastActiveTime > 100000UL) // 100ms timeout
{
active = false;
digitalWrite(ledPin, LOW);
}
}
I have checked the sketch based on internal comparator,but i'm doing a wire following robot with this emf detector, so i need a value from two emf detectors placed on the right and left side of the robot and compare these value and move along the wire just like a line following robot, so i need a value from each sensor based on the amount of flux linked with each antenna.
in the circuit i told above i'm not using 9v, i connected the 5v from arduino , the screenshot of the value got when i read using analogRead is attached here.
it is fluctuating, it is not solved yet
It fluctuates because you are measuring AC. To get steady level you have to rectify + low pass filter signal. Is you board UNO? You may try this sketch, only remove LCD subfunctions:
http://coolarduino.wordpress.com/2013/01/09/audio-vu-meter/
Other things, if amplifier is necessary, why you set gain to 3? 100 or 300 looks preferable.
Here's the code I used to detect emf using one of the analog inputs directly, when I had 1M and 470pF between the analog input and ground:
const float chargingFactor = 2.0; // effective peak detection charging time constant
const float dischargeFactor = 100.0; // effective peak detection discharge time constant
const int delayTime = 1; // sample every 1ms
const int antennaPin = 0; // analog pin number for antenna
const int ledPin = 3; // digital PWM pin for LED
float outVal = 0.0;
int count = 0;
void setup()
{
pinMode(13, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop()
{
analogRead(groundPin);
float inVal = (float)analogRead(antennaPin);
if (inVal > outVal)
{
outVal += (inVal - outVal)/chargingFactor; // simulate charging capacitor through forward-biased diode
}
else
{
outVal -= outVal/dischargeFactor; // simulate discharge through load
}
analogWrite(ledPin, map(constrain((int)outVal, 4, 10), 4, 10, 0, 255));
delay(delayTime);
}
The code in loop() simulates a rectifier and capacitor. You could use similar code to smooth out the values you read.
Magician:
It fluctuates because you are measuring AC. To get steady level you have to rectify + low pass filter signal.
Which is what I said in reply #6
Quote from: Magician on Today at 01:31:40 AM
It fluctuates because you are measuring AC. To get steady level you have to rectify + low pass filter signal.
Which is what I said in reply #6
Correct, I only suggest to do this in software, leaving amplifier /hardware side intact.
Thank you Grumpy_Mike the problem got rectified with your replay #6, i made a small change, used a 1M pull down resistor instead of 10k, it worked.
Thank you all for your valuable replays