PIR Module motion detection firing randomly!

I tried to recreate your test by placing the Spider into a regular cardboard box and placing the modules in the same sockets that you had listed and I cannot get the same results that you are reporting. With the Lid closed, none of the sensors fired unless I disturbed the box a great deal. Upon opening the box, a few of them fired when they detected the lid opening. After the lid was opened, none of the sensors fired unless I waved my hand in front of them. I reclosed the lid and still none of them fired unless the box was disturbed. I attempted this test with both external power and power only from the USB port on the PC itself.

All of the tests were negative for the behavior that you are reporting.

All that can be done now, if you can, would be to send us your modules and we can test them here.

Here is the code output from the USB only test:
Motion Detected - 1!@ 06/01/2011 00:01:45
Motion Detected - 0!@ 06/01/2011 00:01:45
Motion Detected - 2!@ 06/01/2011 00:01:45
Motion Detected - 3!@ 06/01/2011 00:01:46
Motion Detected - 2!@ 06/01/2011 00:01:50
Motion Detected - 0!@ 06/01/2011 00:01:50
Motion Detected - 1!@ 06/01/2011 00:01:51
Motion Detected - 1!@ 06/01/2011 00:04:53
Motion Detected - 2!@ 06/01/2011 00:04:53
Motion Detected - 0!@ 06/01/2011 00:04:59
Motion Detected - 1!@ 06/01/2011 00:05:00
Motion Detected - 2!@ 06/01/2011 00:05:00
Motion Detected - 1!@ 06/01/2011 00:09:41
Motion Detected - 2!@ 06/01/2011 00:09:44
Motion Detected - 0!@ 06/01/2011 00:09:44

The first few was when the box was open. The large gap was when the lid was closed. I reopened the lid and until I moved in front of them, nothing was detected.

Hello,

I have the same behaviour as keith2ei.

  1. Which mainbaord? (spider)
  2. setup? (spider, USB DP, PIR)
  3. Power? (USB)
  4. have you tried a different cable and different socket? (no)
  5. can you tell how often it is happening? (typically every 6 seconds when PIR is added to camera module)
  6. did you try to adjust the small POTs? (yes, problem not resolved)

I’m also able to get a stable application to work with a spider and one motion sensor and no other modules connected.

In Program.generated.cs:



        private void InitializeModules() {
            this.motion_Sensor = new GTM.GHIElectronics.Motion_Sensor(10);
            this.serCam = new GTM.GHIElectronics.SerCam(8);
        }



In Program.cs:



        void ProgramStarted()
        {
            Debug.Print("Program Started");
            motion_Sensor.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed);
        }

        void motion_Sensor_Motion_Sensed(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("trigger\n");
        }

Thant’s mean “trigger” message is displayed only when I pass my hand front of sensor.

Second test, I add camera to spider using U socket:

In Program.generated.cs:



        private void InitializeModules() {
            this.motion_Sensor = new GTM.GHIElectronics.Motion_Sensor(10);
            this.serCam = new GTM.GHIElectronics.SerCam(8);
        }


In Program.cs:



        void ProgramStarted()
        {
            Debug.Print("Program Started");
            motion_Sensor.Motion_Sensed += new GTM.GHIElectronics.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed);
        }

        byte[] dataimage;
        int PictureNumber = 0;

        void motion_Sensor_Motion_Sensed(GTM.GHIElectronics.Motion_Sensor sender, GTM.GHIElectronics.Motion_Sensor.Motion_SensorState state)
        {
            Debug.Print("trigger\n");
            serCam.StartStreaming();
            Thread.Sleep(100);
            if (serCam.isNewImageReady)
            {
                dataimage = serCam.GetImageData();
                Debug.Print(dataimage.ToString());
                PictureNumber++;
                if (PictureNumber % 10 == 0)
                {
                    serCam.StopStreaming();
                    serCam.StartStreaming();
                }
            }
        }

“trigger” message is displayed each 6 second without I pass my hand front of the sensor !
And serCam.isNewImageReady is never equal to true so Debug.Print(dataimage.ToString()); is never displayed.

This is what I observe…

I think that there is a hardware issue.
1- I connected PIR (socket 4) and camera (socket 8 ) to SPIDER.
2- In prgram.gadgeteer interface I added only PIR module so SW don’t recognize any camera.
=> I receive every 6 seconds the message "trigger !!

Using extender module I did two buttons. One on Pin 5 and second on Pin 8 of socket 9.
So aim of this test is to confirm that the seen problem is dealing with PIR module or spider.
=> Result: I have the same behaviour. I mean when I press button on Pin 5, event is triggered for Pin 5 and Pin 8 !!! same thing when pressing button on Pin 8 !! :open_mouth:

Software:


        void ProgramStarted()
        {
            GT.Socket socketPir = GT.Socket.GetSocket(9, true, null, null);
            _pirPin5 = new InterruptPort(socketPir.CpuPins[5], true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
            _pirPin5.OnInterrupt += new NativeEventHandler(pirPin_OnInterrupt5);

            _pirPin8 = new InterruptPort(socketPir.CpuPins[8], true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh);
            _pirPin8.OnInterrupt += new NativeEventHandler(pirPin_OnInterrupt8);     
        }


        void pirPin_OnInterrupt5(uint data1, uint data2, DateTime time)
        {
            _pirPin5.DisableInterrupt();
            Debug.Print("Button on Pin 5 at: " + DateTime.Now.ToString());

            _pirPin5.EnableInterrupt();
        }


        void pirPin_OnInterrupt8(uint data1, uint data2, DateTime time)
        {
            _pirPin8.DisableInterrupt();
            Debug.Print("Button on Pin 8 at: " + DateTime.Now.ToString());

            _pirPin8.EnableInterrupt();
        }

Interesting result to say the least, and might explain a few PIR issues where it works for some people but not others.

pin 3 is the only guaranteed interrupt pin on a socket but i assume it would throw an exception not multiple events if not supported.

will be interesting to see what the issue is…

@ Mo7a On the Spider, you wired a button to pins 5 and 8 on socket 9. When you pressed the pin 5 button, you got an interrupt on both pins and when you pressed the pin 8 button you still got an interrupt on both pins?

Hello @ John. Yes you have well summarized what I observe.
But I think found the source of this problem. In fact I didn’t add a capacitance to delete noises when button is pressed. As I haven’t one, I add some wait in source code to be sure that signal read is still equal to 1:



        void pirPin_OnInterrupt5(uint data1, uint data2, DateTime time)
        {
            _pirPin5.DisableInterrupt();

            Thread.Sleep(500);
            if (_pirPin5.Read())
            {
                Debug.Print("Button on Pin 5 at: " + DateTime.Now.ToString());
            }
            _pirPin5.EnableInterrupt();
        }

Same think I did for Pin8.

And It work ;D

I thought that it’s the case for PIR module so I added this “SW filter” on Pin3 BUT THE SIGNAL IS STILL HIGH AND I RECEIVE DEBUG MESSAGE EVERY 6 SECONDS :wall:

I will make some hardware test in PIR module and come back to you if I find something…

We were able to reproduce the issue with the SerCam being connected, but we do not have a solution for it at this time. We will let you know when we do.

1 Like