Omnidirectional Tilt and Vibration Sensor, Model SQ-SEN-200 (/390)

Manufacturer: SignalQuest

Report by Amit Pitaru

DATASHEET

PDF format, right click to download.

DESCRIPTION

The SQ-SEN-200 series sensor acts like a normally closed switch which chatters open and closed as it is tilted or vibrated. Unlike other ball-tube devices, the 200 is truly an omnidirectional motion sensor. The sensor will produce continuous on-off contact closures when in motion. When at rest, it normally settles in a closed state. It is sensitive to both tilt (static acceleration) and vibration (dynamic acceleration). This signal can be used to interrupt (wake up) a microcontroller or can be counted to estimate the amount and duration of activity. The sensor is fully passive, requires no signal conditioning, and can be used in a microcontroller interrupt circuit that draws as little as 0.25uA of continuous current. {From datasheet}

AVAILABILITY AND PRICINGS:

You may request samples by email, altough at the time of publication this model is not listed on the manufacturer's site. This surfance-mount sensor will soon replace thier current products: SQ-SEN-003 / 001.

Predicted pricings by manufacturer: 1 – 249: $4.53 1K: $1.76 10K: $0.86 50K: $0.72 100K: $0.65

THEORY OF OPERATION

The SQ-SEN-200 series sensor acts like a normally closed switch which chatters open and closed as it is tilted or vibrated. The SQ-SEN-200 is not guaranteed to be closed—even when the sensing mechanism is at rest. However, a good rule of thumb is that 75% - 95% of the time (depending on orientation) when the sensor is at rest it will be closed. The engineer should design his or her software to look for high-to-low and low-to-high edge transitions rather than an open of closed state of the switch. {From datasheet}

In other words: when working with this sensor, you can expect it to be closed unless its moving. But in reality it will sometimes remains open even when rested. Because of this, the fail-safe way to detect motion is to look for changes on the input-pin rather than a distinct state.

Signalquest has a twin model - the SQ-SEN-390. The two models are almost identical, except tht the 390 will sometimes remain open and sometimes closed when rested - depending on its orientation. This could be helpful if you wish to detect vibration and overal oreintation (think digital-cameras and how their LCD flips direction when the camera is tilted). Following are two schematics that show the difecence between the two sensors when at rest:

ELECTRICAL CHARACARISTICS :

-* Current consumption is determined by the resistance of the application circuit and the supply voltage.

The table above shows that this sensor can take between 2.7V and 12V, without affecting its sesing operation. When supplied higher voltages, it will consume more current when the circuit is closed (as it usually is withthe sen-200). This will affect power conservation when using a battery. For this reason it is recomended to use a resistor and limit supplied voltage to the minimum 2.7V. I found that the usual 10K does the trick when working with a 3V coin-cell battery as power source.

GENERAL APPLICATION CIRCUIT:

The sensor can be integrated into a circuit similarly to a an on/off switch. The circuit below uses the pic's internal ('weak') pull-up resistor on Pin-5. This means that the pic is providing 3V to Pin-5, keaping it normaly high. But when the sensor closes the circuit, Pin-5 will be pulled to ground and therefor go low. There are two main benefits to using an internal pullup as opposed to the usual swithc circuit:

1. We usually add a pulldown resistor to ground on input pins, to prevent the pin from 'floating' between hi/low. In this case, the internal resistor pulls the pin up permamently so we save one resistor.

2. The pic itself provides the voltage for the sensor. In return, we can conserve energy by putting the pic to sleep, and only checking for movements every .5 seconds by momentarily supplying voltage to the sensor. This is called an interrupt wake-up routine. It is explained in further detail below.

IMPLEMENTATION OF MOTION DETECTION:

The following instructions were given by the manufacturer, towards a motion-detection application that wakes up a MCU from Sleep mode (low-power consumption mode):

  • Interrupts: Connect the sensor to an interrupt line on the microcontroller or CPU.
  • One-shot: While remaining in a low power mode i.e. running on a 32 KHz watch crystal, look for an interrupt. After the first interrupt pulse, disable further interrupts for 0.5 seconds, thereby only allowing one pulse per ˝ second time-lice to be recognized. Do not wake up the processor at this time.
  • Leaky integrator: Every ˝ second time-slice, if the one-shot is tripped, increment a pulse counter variable by 5. If it isn’t tripped, decrement the pulse counter variable by 1. Do not switch to a high power mode yet.
  • Threshold: If the pulse counter value exceeds a threshold of 25 (5 seconds of motion) then the device is moving. Now, switch to a high power state.
  • Notes: Be sure to stop incrementing at some maximum pulse counter value (try 50), so it doesn’t continue to grow with continuous motion. Be sure to stop decrementing the pulse counter at zero so a numerical underflow doesn't’t occur.

The following PicBasicPro code demonstrates the simplest implementation of motion detection, using the sensor. This code will disregard the interrupt routines mentioned above . The program will light up an LED when motion is detected. Every 50ms, the input-pin will be checked. If its state has changed since the last check, a counter will increase by 5, otherwise it will decrease by 1. If the counter rises above 25, we will light up the LED. When it drops below 25, the led will be turned off.

*Click here to view a processing simulation of the algorythm (external link to http://pitaru.com).

ADAPT FOR THROUGH-HOLE

 'Place the sensor is on portB.2
 sensorPin  VAR portB.2  :  TrisIO.2=1

 'Place a LED on port B.4
 testLED VAR portB.4 : trisio.4 = 0 : testLED = 0     

 'this variable holds (buffers) the previous state of the sensor
 sensorPrev VAR BYTE
 sensorPrev = tilt

 'a counter- increases when the sensor moves
 sensorCount VAR WORD
 sensorCount = 0

 'a couter - increases on every loop iteration
 gapcount VAR WORD
 gapcount = 0

 'this variable determines how often we check for sensor changes.
 gap VAR WORD
 gap = 500

 'take a breather
 PAUSE 1000

 'beginning of main loop routine
 main:

 gapcount = gapcount + 1

 'we use this if statement to activate the sensor routine -
 '- once every {gap} cycles. In this code - once every 500 loops.

 IF gapcount > gap THEN

    'reset the counter
    gapcount = 0

     'if the sensor pin has changed since last checked
     IF sensorPin <> sensorPrev THEN
          'increment by 5 unless the counter is already very high
          IF sensorCount < 50 THEN
              sensorCount = sensorCount+5
          ENDIF
     'else if the sensor did not change states
     ELSE 
         'slowly decrease the sensor unless its already at 0
         IF sensorCount> 0 THEN
             sensorCount =  sensorCount-1
          ENDIF
     ENDIF

     'if the sensor moved repeatedly - we have real motion!  
     IF sensorCount> 25 THEN
      testLED = 1
     ELSE 
      testLED = 0
     ENDIF

     'set the sensor buffer to current sensorPit, toward next check
     sensorPrev = sensorPin
 ENDIF


 'loop again...
 GOSUB main