Author Topic: Simple Arduino + Parallax PIR Motion sensor issue - electrical noise?!  (Read 2692 times)

0 Members and 1 Guest are viewing this topic.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Hi folks!

Having a strange issue with my PIR motion sensor that I could use some suggestions on.

Note: I always give the sensor at least 30 seconds to calibrate, but now i'm up to 45. Also, I have the sensor inside of a cardboard tube (paper towel tube) to narrow and isolate the FOV from interference (works great).

The problem is the sensor, when hooked up to the arduino, seems to be experiencing something causing the sensor to return false triggers after the first true trigger. Confusing, so let me explain another way...

When I hook up the PIR sensor on the breadboard, feed a steady 4.5v (sensor needs anything between 3.3-5v), let the sensor calibrate, the output works correctly changing to HIGH upon motion, returning to low after a couple seconds of no motion. When there is no motion, the sensor is pretty good about being calm and not false triggering.  So this suggests the sensor is in good working order.


When i hook the sensor up to the arduino though (5v, PIR output --> Digital Pin 6) a problem surfaces; it will boot fine, initialize the sensor fine, and return no false readings UNTIL i trigger the sensor once with motion. The sensor will go HIGH (as it should), return LOW (as it should), then continue to oscillate between the two states every few (randomized) seconds as if there is some kind of weird loop or noise in the line.

Here's the code:
Code: [Select]
int IRpin = 6;
int LEDpin = 13;
int initialBoot = 1;
int IRstateCur = 0;
int IRstateLast = 0;



void setup() {               
  pinMode(LEDpin, OUTPUT);
  pinMode(IRpin, INPUT);
  digitalWrite(IRpin, LOW);
  digitalWrite(LEDpin, LOW); 
  Serial.begin(115200);
}

void loop() {
  if(initialBoot == 1){
    Serial.println("Initializing IR Motion Sensor, 45 seconds...");
    delay(25000);             
    Serial.println("20 seconds...");
    delay(10000);
    Serial.println("10 seconds...");
    delay(5000);
    Serial.println("5 seconds...");
    delay(5000);
    Serial.println("...initialized!");
    initialBoot = 0;
  }

  IRstateCur = digitalRead(IRpin);
  //Serial.println(IRstateCur);                   //use for debug, shows idle time between states
  //manage LED according to IRsensor
  if(IRstateCur == 0){
    digitalWrite(LEDpin, LOW);
    }else if(IRstateCur == 1){
      digitalWrite(LEDpin, HIGH);
    }
   
if(IRstateCur != IRstateLast && IRstateCur == 1){
  Serial.println("Motion detected");
  IRstateLast = 1;
  }else if(IRstateCur != IRstateLast && IRstateCur == 0){
    IRstateLast = 0;
  }
  delay(200);              // wait 200ms
}



If I enable that one line for debugging, it shows that the time between false triggers in NOT always equal, but seems kinda random. What I can say, is that it is NOT due to outside interference. I have successfully isolated the sensor in the tube, and cannot get it to 'falsely' trigger when on the bread board (very accurate).

Here's the output with the debug enabled:

(Sorry its so long, but it needs to be to show how the sequence is unfolding. at the beginning after initialization notice how there is no false output until the first motion event which was my hand in front of the sensor, after that, ALL other 'motions' detected are actually false and the oscillating problem I am describing.)


Code: [Select]
Initializing IR Motion Sensor, 45 seconds...
20 seconds...
10 seconds...
5 seconds...
...initialized!
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Motion detected
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1


I've experimented with various 100-10K resistors on the IR sensor output to ground to try and remove any 'noise' while the output is LOW, but nay. Problem will not go away!!


What am I missing?!  ???  Thank you!
The difference between the student and the master, is that the master knows what he does not know.

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
The Parallax PIR sensor has a jumper on it that, when in a certain position, causes it to output an alternating high/low pulse train instead of a constant high.  Have you checked and made sure it's in the correct position?  It sounds like you've got the mode set incorrectly (check the datasheet).

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
The Parallax PIR sensor has a jumper on it that, when in a certain position, causes it to output an alternating high/low pulse train instead of a constant high.  Have you checked and made sure it's in the correct position?  It sounds like you've got the mode set incorrectly (check the datasheet).

I've checked. It's on HIGH, which is the desired mode. But I've also tried it on LOW, same result; oscillating output, not triggered by any motion.
The difference between the student and the master, is that the master knows what he does not know.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Hi,

What am I missing?!
A stable and noise-free supply would be my guess. How is the decoupling made and with what components?

Please post a datasheet on your particular PIR unit.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Using this PIR from Parallax:

http://www.parallax.com/dl/docs/prod/audiovis/pirsensor-v1.2.pdf

And this 'Freeduino' board from SolarRobotics:

http://www.solarbotics.com/products/28920/

And feeding the Freeduino with 6v from one of these (via 2.1mm DC plug):

http://www.altex.com/Philmore-Multi-Voltage-Regulated-DC-Power-Supply-MW122A-P143093.aspx
The difference between the student and the master, is that the master knows what he does not know.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
That said, using the same DC power supply via my breadboard at 4.5v, the sensor works fine.

The difference between the student and the master, is that the master knows what he does not know.

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
I believe the Freeduino uses a standard (not LDO) regulator - it'll need more than ~7v to properly regulate.  Try feeding it 7.5v or 9v from your power supply and see if it helps.

Offline GrooveHolmesTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
That was it. I put the input voltage to the Freeduino to 7.5V and its now working like it should. Odd, but it makes sense as the patterns did seem like the sensor was 'resetting/recalibrating'.

A few questions out of this now then...

1) Is this just a feature with this particular freeduino board, or is this an 'Arduino' thing (this is my first and only '*duino' product)? For $5 more i could buy an official board.
2) would a capacitor on the PIR power line help this (if the problem is due to a voltage drop)?
The difference between the student and the master, is that the master knows what he does not know.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,920
  • Helpful? 97
This is a feature of the linear regulator used on that board. The regulator has a minimum voltage drop of about 2.5V and can not provide a regulated output if its input voltage drops too low (5V out + 2.5V = 7.5V in). So if you supplied 6V in then the output would be about 6 -2.5 = 3.5V which is too low for the processor and PIR to work.

There are other linear regulators that are LDO (Low Drop Out) which as the description states has a lower drop up voltage. Some of these only need a 100 mV more on the input.

 


Get Your Ad Here