PIR Module motion detection firing randomly!

The issue of the Gadgeteer PIR Motion sensor improperly firing needs to be resolved. When I connect a single PIR Sensor to say socket 10 or socket 11 on my Spider, the sensor behaves normally. But when I add more modules it starts consistently firing every 6 seconds. I have replaced the sensor with a Parallax PIR Sensor connected as a Potentiometer in socket 10 and test for motion via readvoltage() in a timer function - it works flawlessly. I just have to fashion a connection that takes time, adds a little cost and doesnā€™t look good. And for what its worth, the Gadgeteer motion sensor appears to be very over engineered in comparison to the Parallax sensor. I would appreciate some guidance from GHI on this issue. Thanks!

I have the same issue with it.

For those that have a problem with repeated firing, and only repeated firing, please test the PIR sensor itself with a mainboard, no other modules. Use powered hub or power pack to power your board. Use simple code, only Debug.Print(ā€œfireā€) inside the PIR event handler.

When done, answer these question please: (I added and example of fake answers)

  1. Which mainbaord? (spider)
  2. setup? (spider, USB DP, PIR)
  3. Power? (USB and 12V 800mA power pack)
  4. have you tried a different cable and different socket? (yes)
  5. can you tell how often it is happening? (seem like it is firing too fast to tell)
  6. did you try to adjust the small POTs? (yes, no difference)

Gus,

  1. Which mainbaord? (spider)
  2. setup? (spider, USB DP, PIR)
  3. Power? (USB and 12V 1A and a 12V 5A supply)
  4. have you tried a different cable and different socket? (yes)
  5. can you tell how often it is happening? (typically every 2-10 seconds - average about every 6 seconds)
  6. did you try to adjust the small POTs? (yes, no difference and the pots are a bit of a nuisance for us because they would add complexity since they would have to be adjusted before we deploy a device)

Iā€™m able to get a stable application to work with a spider and one motion sensor and no other modules connected. Once I start adding modules the motion sensor begins to continuously fire. For example, I added a light sensor and a multicolor LED and everything worked. Then I added an accelerometer and it started to continually fire. Removed the accelerometer and it worked normally. Then added an xbee module and the sensor started continually firing, same result when I removed the xbee and added a cell radio module. As i noted earlier Iā€™ve also been using the Parallax motion sensor connected as a potentiometer and it works fine under all circumstances. The Parallax has similar pin out configuration, maybe GHI can adapt their PIR Motion sensor interface card to the Parallax? Gus, iā€™d be glad to contact you directly and share more detail if you think that would help? Thanks!

@ keith2ei

How are you testing if there is motion? Can you describe your test? Do you have any test code that we can use to reproduce on our end? Can you send a picture of each of the potā€™s positions so we can place in the same position?

@ Gus -

  1. Which mainbaord? (spider)
  2. setup? (spider, USB DP, PIR, PIR1, PIR2, PowerSupply) (three similar motion-detectors just taken out of the bags!) (the 3 sensors are under a metal box on a table with only the cables making a millimeter of space between table and box)
  3. Power? (USB and 12V 1A)
  4. have you tried a different cable and different socket? (no)
  5. can you tell how often it is happening? (typically every 2-10 seconds)
  6. did you try to adjust the small POTs? (yes)

With my previous test I tested several cables and sockets - same result. This time I have tried with 3 sensors on same board. Now comes the interesting part: They all fire once on startup (acceptable), but then complete silence. If I lift the box, making some motion, they all fire fine, but then keeps firing with the annoying interval.

Is there some clean-up that we are missing?

This is really getting a problem to me, as I am having a project that is really depending on stable motion-sensing.

@ Aron - Just to clarify that there is no problem with the sensors nor the code. I have today tried the same sensors on the FEX Cerberus mainboard, where it all works like a charm.

ping?

We are happy to hear that your sensors are working. What do you mean by ping?

@ Aron - Ah ok, they are only working on the Cerberus mainboard, and it was a while since there was any feedback, so I was getting nervous that the thread was getting old and unseenā€¦

Still I really want the motion detectors to work on the Spider.

Just flashed to new firmware, still not good.

@ njbuch

We have not forgotten this issue and we are investigating as to why there is a constant firing of the PIR module.

Can you take a picture of the pots positions that we may try to reproduce here at our end?
Can you also create a specific test and simple code that recreates the problem and post it here so we can reproduce the problem?
Donā€™t forget to let us know which modules and which sockets you have connected.

I think he included a pictures in his original post. I had the same issue some time ago and assumed it was an issue with the firmware on the spider. i just tried again w/ latest firmware and see that it is still easily reproducible. I donā€™t think the issue is a ā€˜constant firingā€™, but rather a very delayed firing if motion is continuous in front of the sensorā€¦such that the delay is approx. every 6 seconds.

in my case i connect to socket 4 on the spider.
my pots are turned all the way to the left.
run the app and constantly wave your hand in front of the sensor
ā€¦the fastest you see the events being fired is around 6 seconds.

if you load the actual Motion_Sensor_42.cs class file and put a debug.print in _input_Interrupt(ā€¦), youā€™ll likely see it being invoked ever 4 seconds or so. in OnMotion_SensorEvent(ā€¦), it looks like the Program.CheckAndInvoke() check or the SensorState value will add another 2 to 3 seconds since the bubbling of the event is conditional based on those two checks.

I tried different settings with the pots. Cranking them all the way to the left for no timeouts, and minimum sensitivity makes no difference.

Any progress?

No.

Coming back to this postā€¦Aron, have you found anything regarding this issue? Wondering where the problem is here (the sensor or the board)ā€¦i would like to use this with spider, but donā€™t feel like pulling my hair out trying to get it to work.

Alright, we are going into serious debugging now.

Here is the code:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            motion_Sensor.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed);
            motion_Sensor1.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed1);
            motion_Sensor2.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed2);
            motion_Sensor3.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed3);
            
            Debug.Print("Program Started");
        }

        void motion_Sensor_Motion_Sensed(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("Motion Detected - 0!@ " + DateTime.Now.ToString());
        }
        void motion_Sensor_Motion_Sensed1(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("Motion Detected - 1!@ " + DateTime.Now.ToString());
        }
        void motion_Sensor_Motion_Sensed2(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("Motion Detected - 2!@ " + DateTime.Now.ToString());
        }
        void motion_Sensor_Motion_Sensed3(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("Motion Detected - 3!@ " + DateTime.Now.ToString());
        }
    }
}

And here is the output, coming from inside a closed box containing a Spider 1.0 and 4 pir sensors 1.0. I am considering returning the PIRS to GHIā€¦

Found debugger!

Create TS.

 Loading start at a0e00000, end a0e1383c

   Assembly: mscorlib (4.2.0.0)     Assembly: Microsoft.SPOT.Native (4.2.0.0)     Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0)     Assembly: System.Security (4.2.0.0)  Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: Microsoft.SPOT.IO (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0)  Attaching deployed file.

   Assembly: Gadgeteer (2.42.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Graphics (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware (4.2.0.0)  Attaching deployed file.

   Assembly: PirSensorTest2Spider (1.0.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Touch (4.2.0.0)  Attaching deployed file.

   Assembly: System.Http (4.2.0.0)  Attaching deployed file.

   Assembly: System (4.2.0.0)  Attaching deployed file.

   Assembly: System.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.TinyCore (4.2.0.0)  Attaching deployed file.

   Assembly: System.IO (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.System (4.2.10.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Motion_Sensor (1.1.2.0)  Attaching deployed file.

   Assembly: GHI.Premium.IO (4.2.10.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net (4.2.0.0)  Attaching deployed file.

   Assembly: GHI.Premium.Hardware (4.2.10.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1)  Attaching deployed file.

   Assembly: GHIElectronics.Gadgeteer.FEZSpider (1.1.2.0)  Resolving.

GC: 1msec 35484 bytes used, 7304184 bytes available

Type 0F (STRING              ):     24 bytes

Type 15 (FREEBLOCK           ): 7304184 bytes

Type 17 (ASSEMBLY            ):  31344 bytes

Type 1E (BINARY_BLOB_HEAD    ):   4044 bytes

Type 34 (APPDOMAIN_HEAD      ):     72 bytes

GC: performing heap compaction...

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Motion_Sensor\NETMF 4.2\le\GTM.GHIElectronics.Motion_Sensor.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.System.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZSpider\NETMF 4.2\le\GHIElectronics.Gadgeteer.FEZSpider.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Users\njb\documents\visual studio 2010\Projects\PirSensorTest2Spider\PirSensorTest2Spider\bin\Debug\le\PirSensorTest2Spider.exe', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Http.dll', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZSpider version 1.0
Program Started
Motion Detected - 3!@ 06/01/2011 00:05:18
Motion Detected - 0!@ 06/01/2011 00:05:18
The thread '<No Name>' (0x3) has exited with code 0 (0x0).
Motion Detected - 3!@ 06/01/2011 00:05:36
Motion Detected - 1!@ 06/01/2011 00:05:36
Motion Detected - 0!@ 06/01/2011 00:05:36
Motion Detected - 2!@ 06/01/2011 00:05:36
Motion Detected - 3!@ 06/01/2011 00:06:34
Motion Detected - 1!@ 06/01/2011 00:06:34
Motion Detected - 0!@ 06/01/2011 00:06:34
Motion Detected - 2!@ 06/01/2011 00:06:35
Motion Detected - 3!@ 06/01/2011 00:06:41
Motion Detected - 2!@ 06/01/2011 00:06:41
Motion Detected - 1!@ 06/01/2011 00:06:42
Motion Detected - 0!@ 06/01/2011 00:06:42
Motion Detected - 3!@ 06/01/2011 00:07:31
Motion Detected - 1!@ 06/01/2011 00:07:31
Motion Detected - 0!@ 06/01/2011 00:07:31
Motion Detected - 2!@ 06/01/2011 00:07:31
Motion Detected - 3!@ 06/01/2011 00:07:38
Motion Detected - 1!@ 06/01/2011 00:07:38
Motion Detected - 0!@ 06/01/2011 00:07:38
Motion Detected - 2!@ 06/01/2011 00:07:38
Motion Detected - 3!@ 06/01/2011 00:07:46
Motion Detected - 1!@ 06/01/2011 00:07:46
Motion Detected - 0!@ 06/01/2011 00:07:46
Motion Detected - 2!@ 06/01/2011 00:07:46
Motion Detected - 3!@ 06/01/2011 00:08:16
Motion Detected - 1!@ 06/01/2011 00:08:16
Motion Detected - 0!@ 06/01/2011 00:08:16
Motion Detected - 2!@ 06/01/2011 00:08:16

I start in the closed box and they fire a few times when booting. Then silence. I lift the lid at 6:34, and they all fire fine. Close the lid again, and they start firing 6-10 seconds constantly.

Do you need more details?

@ njbuch, dizzy

We have tried regular tests and have not found any issues with the modules. However, the test that njbuch just posted may be the test we need. We will test the modules with the test he described and we will report our findings as soon as possible.

@ njbuch
What sockets did you put the 4 modules in? Please list the socket number to the motion_Sensor number.

Thanks for looking at this Aron!

Completely new project in Vs2010, with auto-connected modules, here is the snippet from program.generated.cs:


        private void InitializeModules() {
            this.motion_Sensor3 = new GTM.GHIElectronics.Motion_Sensor(10);
            this.motion_Sensor2 = new GTM.GHIElectronics.Motion_Sensor(11);
            this.motion_Sensor1 = new GTM.GHIElectronics.Motion_Sensor(12);
            this.motion_Sensor = new GTM.GHIElectronics.Motion_Sensor(14);
        }

I dont think its the potmeters, but can take a picture of the setting if needed.

Thanks Aron. iā€™ve been able to easily reproduce this issue as described in post #30.

Any progress on this, pleaseā€¦?

Hi

I am a complete beginner with Gadgeteer but I had a similar problem with the PIR firing, I needed my PIR to fire a motor for a set period of time, then turn the motor off and reset. I used the built in PIR sensor, then started the motor, then put in a thread.sleep for the period of time the motor was to run. I then turned the motor off and put in a Thread.Sleep(3000) to reset the PIR. This has seemed to have worked for me. (Sorry I cant link the code, itā€™s on another PC!). What I have noticed though is that from me moving in front of the PIR it takes about 2.5 seconds for the board (Fez Hydra) to process and fire the motor. Thatā€™s why I put the sleep 3000 in to ensure it had a refresh time.

I doubt it helps but it is my experience of the PIR!