Motion Sensor Prank PCB

by Mart Berghs in Circuits > Microcontrollers

441 Views, 1 Favorites, 0 Comments

Motion Sensor Prank PCB

1-1.jpg
2-1.jpg
medium-pic10f200-SOT-23-6.png

The motion detector / tilt sensor is constructed by integrating several techniques with each other. Including PCB layout, 3D printing, soldering, a bearing ball and gravity as the force for the motion detection. After motion / tilt detection a buzzer is activated. The rest of the time, the controller will go to sleep to save battery power. Only a wake up occurs when the value at the sensor pin change from the state it was before going to sleep.

 

The prank motion detector has two operating modes after a motion detection, selectieve by two soldering jumpers:

  • Alarm mode, generating noise for minimal a minute after the last motion detection;
  • Prank annoying mode. Buzzer does not stop until power is switch off.

 

I always wanted to do a project with a “NOT the biggest µC“ available! The PIC10F series µC from the manufacturer Microchip. This is the brain of the sensor. And for a long time I had an idea for a motion / tilt sensor that I wanted to try out. To protect the contents of my cookie jar!

 

For this project the µC PIC10F206T-I/OT was selected: 

  • Package SOT-23 6 pins (overall width and length max. 3,2*3,1mm );
  • 8-bit;
  • Flash Program Memory Size 0,75KB;
  • 4 IO pins.

 

The PIC10F206T-I/OT was the best available at the beginning of this project. But the whole series PIC10F2xx can be used. (The series PIC10F3xx can probably also be used with software adjustments, register settings etc. I have not checked this.)

Supplies

supplies1.jpeg
3.jpeg
4.jpeg
5.jpeg

Tools:

  • soldering tools;
  • soldering wire and/or paste;
  • flux-off or a combo of alcohol and acetone;
  • tweezers;
  • 3D printer or a friend with a 3D printer;
  • wire cutters;
  • small (needle nose) plier;
  • PIC µC programmer (i used the PICkit 4);
  • jumper wires 5x, pins male to male.


Components PCB:

  • bare PCB "Motion Alarm PCB B10";
  • components PCB, see below "Motion Alarm B10, part list";
  • phosphor bronze wire dia. 0,9mm (preference);
  • 3D print molding / helping hand for soldering the sensor leads.


Sensor Parts:

  • 3D print outer casing;
  • 7x phosphor bronze wires or for example leads from a DO-41 diodes;
  • metal bearing ball dia. 3mm;
  • metal disk dia. 8mm or a washer M2.5 for on top.


Documentation:

  • part list;
  • circuit schematic;
  • PCB components layout;
  • 3D file step file PCBA.

Assembly Order PCB Components

Motion Alarm B10 (1).png
Motion Alarm B10 (3).png
Motion Alarm B10 (4).png

assembly order:

  • do first the SMD components;
  • next the sensor, see next chapter for assembly tips and construction;
  • at last the through-hole components, battery clips.


(below a 3D pdf of the PCBA, not all browser PDF viewers support displaying 3D pdf's. Else use adobe acrobat reader instead)

Motion / Tilt Sensor

2-1.jpg
10.jpeg
11.jpeg
12.jpeg
IMG_20221006_180652.jpg
IMG_20221006_180727.jpg
IMG_20221006_180747.jpg
IMG_20221006_180816.jpg
IMG_20221006_180827.jpg
IMG_20221006_180955.jpg
IMG_20221006_181041.jpg
IMG_20221006_181048.jpg
IMG_20221006_181110.jpg
IMG_20221006_181134.jpg
IMG_20221006_181154.jpg
IMG_20221006_181248.jpg

Sensor way of working:

Operation of the sensor consists of a ball bearing which can roll in all directions in a 3D printed housing. The ball makes always a electrical contact with a pad in the middle sensor on the PCB. Or when flip over, contact is made with the metal disk / washer on the top of the sensor. During movement of the PCB or vibrations, the rolling ball may or may not make contact with the wires on the side. The input of the µC see a toggling on a input pin, when moved. A change on this pin from one to zero or zero to one, will trigger the alarm. By waking up the controller from sleep mode, energy saving mode.


Assembly sensor:

  • push one wire from the bottom PCB to the top. Into the 3D printed assembly help. This 3D model ensures the correct lead contact lengths and keeps the wire straight;
  • solder the previous pin. And cut the wire at the bottom;
  • repeat the above for the next 5 pins in the circle;
  • after soldering all pins. Clean the 6 pins on top with flux-off or a combo of alcohol and acetone. For good working, a clean contact surface;
  • place the 3D printed casing over the wires;
  • solder a wire on the metal disk or washer. Then bend the wires on both sides;
  • place a bearing ball inside de casing;
  • place the metal disk on top of the casing and the wire into the PCB pads;
  • solder the two disk wires.

Software

33.jpeg
Prank PCB

operation software:

  • after switching on, the circuit wil not react to any movements during 60 seconds. Enough time to place the device;
  • after this time periode de µC goes to sleep, power saving mode;
  • when the sensor detects movement, the µC will wake up;
  • the µC reads the solder jumpers IO's, to determent the which mode;
  • then the buzzer will be activated;


The two operating modes are:

  • Alarm mode, generating noise for minimal a minute after the last motion detection. After this minute and no motion detection, the µC goes to back to sleep mode;


  • Prank, the most annoying mode. Buzzer does not stop until power is switch off.


In the movie is the same software is used, but the timing is adjusted to keep the movie short!


The program:


#include <xc.h>
#include <stdbool.h>
// CONFIG
#pragma config WDTE = OFF    // Watchdog Timer (WDT disabled)
#pragma config CP = OFF     // Code Protect (Code protection off)
#pragma config MCLRE = OFF   // Master Clear Enable (GP3/MCLR pin function is MCLR)
                // for wake-up MCLRE must be off for minimum power consumption
#define _XTAL_FREQ 4000000   // clock frequency in Hz (preproccessor marcro))
#define Buzzer GPIObits.GP2
#define Sensor GPIObits.GP0   // "0" continuous sound after motion detected
#define Mode  GPIObits.GP1   // "1" sound when motion detected, a minuut, and stops after no motion
#define ActDelay 60       // activation delay after power on, seconds

void main(void)
{
  //init begin
  OPTION = 0b10011111;  // default 1111 1111 11xxxxxx
              // bit 6 weak pull-ups on, 1=disable
  CMCON0 = 0b11110011;  // default 1111 1111 x1xx0xx1
  OSCCALbits.FOSC4 = 0;  // default already 0
  CMCON0bits.CMPON = 0;
   GPIO = 0b00000000;   // outputs off
  TRIS = 0b11111011;   // GP0 & GP1 input, GP2 output
  // init end
  
  //SLEEP instruction, before sleep intruction read inputs
  uint8_t Inputs;
  Inputs = GPIO;     // store settings IO's before sleep
     
  OPTION = 0b00011111;  //bit7=GPWU=0: Enable Wake-up on Pin Change bit (GP0, GP1, GP3)
    
  if (STATUSbits.GPWUF && STATUSbits.nTO) // pin change
  {
    // determine mode
    if (Mode=1)
      {
        // jumper J1 "1" sound when motion detected, a minute, and stops after no motion
        int i;
        for(i=0;i<200;++i)
        {
          Buzzer = 1;       
          __delay_ms(100);
          Buzzer = 0;
          __delay_ms(200);
        }
        Inputs = GPIO;
        SLEEP();
      } 
      else
      {
        // jumper J2 "0" continuous sound and stops until power off
        while(1)
        {
          Buzzer = 1;
        }
      }
  }
  else
  {
    //activation delay after power on, seconds * x
    int i; 
    for(i=0;i<ActDelay;++i) { __delay_ms(1000);};
    Inputs = GPIO;
    SLEEP();
  }
  return;
}

What Would I Do Differently If I Knew All This?

PIC10F320-ENX-Regular.jpg
CR2032.png

In hindsight, i would choose a µC from the PIC10F3xx series, next generation of the PIC10F family. They have the same package and pin outs. Also a smaller current, during sleep mode. A low Power Internal 16MHz / 31 kHz oscillator. Easier to program and set up the sleep and wake-up mode.

Also available as a extreme Low Power (XLP) ‘LF’ Variant (1.8V – 3.6V). Could run on 2 AAA batteries, disadvantage how do I make a lot of noise?

Smaller PCB, a version with coin cells

Sensor design is better then I expected. It is very sensitive in addition to movements and also for strong vibrations. To make the sensor a little less sensitive, a filter can be included in the software if necessary.


----------------------------------------------------------- THE END -------------------------------------------------------