msVibrationSetWakeup (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, LX2

Firmware version:

1.36.00


Configure the system to wake from suspend on detection of vibration. See pmSuspend.

 

Note:

The Motion Sensor interface must be opened with msOpen before calling this function.

To wake on vibration without calling msOpen, see accVibrationSetWakeup.

All of the motion sensors must be disabled to be able to wake on vibration, see msAccEnable, msAccEnable and msMagEnable.

 

pmSuspend return codes for this wake-up source:

Error

Type

Value

Description

False

4

1

Vibration has woken up the system.

True

4

-10

Sensitivity is 0.

True

4

-11

Accelerometer is open, preventing vibration from working.

Call accClose to close it.

True

4

-12

MS is open and accelerometer, gyroscope or magnetometer is active.

 

Input:

Enable : BOOL

Controls if enabling or disabling wake-up on vibration.

 

Sensitivity : SINT (-1..100, default -1)

The sensitivity level of the vibration detection.

0 is no vibration detection, 100 is most sensitive.


-1 is to use the sensitivity used in normal operation. See pmSetVibrationSensivity

 

To use vibration as a wake-up source, the sensitivity must not be 0.

 

Returns: INT

1

- Success.

0

- This function is not supported.

-1

- Interface is not open. Call msOpen first.

-2

- Generic error.

-3

- Invalid input configuration.

-9

- Logger is active.

-14

- Accelerometer, gyroscope or magnetometer is active.

 

Declaration

FUNCTION msVibrationSetWakeup : INT;
VAR_INPUT
  Enable      : BOOL;
  Sensitivity : SINT := -1;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
// These are the local variables of the program block
VAR
  wk    : DINT;
END_VAR;
// The next code will only be executed once after the program starts
  ...
  // Open Motion Sensor interface
  msOpen();
  ...
  // Enable wake on vibration with high sensitivity
  msVibrationSetWakeup(sensitivity := 80, enable := ON);
  ...

  // Sleep 600 seconds or wake on vibration detection
  wk := pmSuspend(time:=600, mode := 0);
  ...
  // Close Motion Sensor interface
  msClose();
  ...
BEGIN
// Code from this point until END will be executed repeatedly
END;
END_PROGRAM;