X-Band Motion Detector + Arduino

Hi everyone

I wanted to create an instalation that requires the detection of people passing in front of it. The thing is, the detector, as well as the whole of the instalation have to be placed behind glass.

I've looked around a few sites and forums (as well as here), and I'm coming to the conclusion that my best option shall be the Parallax X-Band Motion Detector:

The thing is, I'm not sure if the Arduino will work with this, by 'listening' to it's OUT pin...

I was wondering if anyone could shine a light on this matter, as I would really like to avoid buying this online and then realizing that it doesn't work for some reason...

Thank you in advance to any and all responses... :smiley:

A picture is worth a thousand words, but a link to a data sheet is worth even more.

The OUT pin oscillates whenever motion is detected, and in general, the more motion, the
faster the oscillations.

Datasheet: http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/32213-X-BandMotionDetector-v1.1.pdf

Greetings

I wanted to create an instalation that requires the detection of people passing in front of it

You may have picked the wrong sensor.
This is a Doppler device, most sensitive to movement towards or away from the device, not across it.

This is a Doppler device, most sensitive to movement towards or away from the device, not across it.

I think it will work; worst case, you might need to use two of the devices set at an angle to each other.

As far as it working with the Arduino, that shouldn't be a problem; its HIGH and LOW values it outputs are within the TTL signal level range the ATMega expects, so it should work OK connected to a digital pin.

I think it would be worth trying out for $30.00...

:slight_smile:

@Richard Crowley:

The transmitting and receiving sections are both self-contained in the unit.

Well, yes, we know that.

I think cr0sh was trying to point out that two units angled across the "installation" might introduce suffficient Doppler shift to trigger.
Think about how Doppler frequencies are produced.

Uau, thanks everyone, for your replys and help :slight_smile: and thanks Richard, for your more in depth response. I think I will try this one for size, and I'll report back with my findings/project...

Should be good to have at least one Arduino project that uses this sensor

hi DPontes11,

i was wondering if you managed to get it working, because i'm in the process of building a similar installation.

i'd really like to know if and how you did it.

thanks in advance!

cheers
pez

No you don't need two of them. The transmitting and receiving sections are both self-contained in the unit.

I suspect that trying to use two of them would result in total sensor chaos. Both would be transmitting asynchronously at similar but not identical frequency and just result in massive interference with each other.

PS: I don't really see that this sensor give much better performance or features over their IR motion detector at a third the price, except that maybe it's ability to 'see' through non conductive material.
http://www.parallax.com/Store/Sensors/ObjectDetection/tabid/176/CategoryID/51/List/0/SortField/0/Level/a/ProductID/83/Default.aspx

Lefty

That's exactly the thing, Lefty. I will need to 'see' through (quite thick) glass.. It seems to me that the only type of sensor that won't be jammed or its signal deflected by glass is a Doppler sensor...

I have one of these on my breadboard right now. It is trivial to connect to the Arduino. 5V, GND and connect OUT directly to an analog input. I'm using a smoothing function on my readings from the pin whereby I set a minimum trigger threshold, minimum time above the trigger threshold and a maximum time below the threshold to disregard.

It is very sensitive and has a very wide field of view - the datasheet is accurate with its description of the FOV. Any motion in any direction will trigger it. You definitely do not have to be moving towards/away from it.

Because I'm interested only in a narrow field of view I am mounting mine inside a 2" square aluminium pipe - it just fits inside. There is an ebay seller that will include plastic end caps that make for great mounting points.

Glass will present no problem for this sensor - it will go straight through it. In an interior environment it may also go straight through thin walls and detect movement in the next room.

It's a fun sensor, you'll enjoy playing with it.

Thanks Andy. I still haven't been able to order it, as I've been busy with other stuff.

What type of output can I expect from the sensor? Does it return the value of the detected frequency at a given moment?

Is it ok to read this signal as a discrete digital read, or do I have to read it as analog?

It's designed for a discrete digital read, I connected it to an analog pin because it was more convenient for me. You will simply get triggered = HIGH, not triggered = LOW in realtime as motion occurs within the sensor's field of view.

Basically Parallax have taken the raw radar sensor that you can get on ebay for about $10 and added the amplification and digitization circuitry that make it possible to plug it straight into a microcontroller.

Awesome! thanks for the reply. I'll try to order it as soon as I have the time... then I'll post some code and probaly a video of ir working :slight_smile:

The X-Band Motion detector is here! :smiley:

Hey there! I've been playing around with the sensor, and was able to understand a little bit of how it works...

I was never able to find any code that used the Parallax X-Band with the Arduino, so here's a small software for anyone who wants to start using this.

This returns the "speed" of the object(s) being detected by the sensor. It's not a typical speed, as this returns the number of state changes per second..

const int PinEN = 9;
const int PinOUT = 7;
int enabled = 0;  //sensor detection flag
int current_state = 0;
int state = 0;    //momentary state value
int count = 0;    //state change count
long currentMilli = 0;


void setup()
{
  Serial.begin(9600);
  enable();
  currentMilli = millis();
}

void loop()
{
  
  if(digitalRead(PinOUT) != current_state)
  {
    count++;
    delay(1);
    current_state = -(current_state - 1);  //changes current_state from 0 to 1, and vice-versa
  }

  if(millis()-currentMilli > 500)          //prints the "speed" every half a second
  {
    print_speed();
  }

}

void enable()
{
  
  //To start the sensor reading, enable pin EN (pin 9) with HIGH signal
  //To make sure it's a clean HIGH signal, give small LOW signal before
  
  pinMode(PinOUT, INPUT);
  pinMode(PinEN, OUTPUT);
  digitalWrite(PinEN,LOW);
  delayMicroseconds(5);
  digitalWrite(PinEN, HIGH);
  wait();
}

void disable()                        //function not used in this program
{
  pinMode(PinEN, OUTPUT);
  digitalWrite(PinEN, LOW);
}

void wait()                            //waits for the sensor to return a state = 1
{
  while(digitalRead(PinOUT) != 1)
  {
    digitalRead(PinOUT);
  }
  current_state = 1;
  Serial.println("Sensor enabled!");
}

void print_speed()
{
  Serial.print("Speed: ");
  Serial.print(count*2);
  Serial.println(" Changes/s");
  currentMilli = millis();
  count = 0;
}

I hope the code explains it self, but if you have any doubts, ask here :wink:

Cheers