accVibrationSetWakeup (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-900, LX2, LX5

Firmware version:

2.20.00


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

 

pmSuspend return codes for this wake-up source (shared with msVibrationSetWakeup ):

Error

Type

Value

Description

False

4

1

Vibration has woken up the system.

True

4

-11

Accelerometer is open, preventing vibration from working.

 

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 will use the sensitivity used under normal operation. See pmSetVibrationSensivity

 

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

 

Returns: INT

0

- Success or this function is not supported.

-1

- Sensitivity is outside the valid range.

 

Declaration

FUNCTION accVibrationSetWakeup : 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
  ...
  // Enable wake on vibration with high sensitivity
  accVibrationSetWakeup(sensitivity := 80, enable := ON);
  ...

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