accSetShockEvent (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

CX1, SX1, MX2 turbo/encore/warp, NX-200, NX-900, LX2, LX5

Firmware version:

2.40 / 1.40.00


This function will enable or disable monitoring of shocks.

A shock is defined as the measured acceleration exceeding a threshold and returning below the threshold before the duration limit expires.

A double shock is defined as two shocks detected after each other where the second shock must start within a time window after the first has ended.

 

If a shock (or double shock) is detected, a "Shock" event is raised. See also accWaitEvent for event # 8.

 

acc3d_shock_pattern

Above is illustrated a shock event (a) and a double shock event (b).

 

 

Input:

Enable : BOOL (default FALSE)

Is event generation enabled. If disabled, all other parameters are ignored.

 

Once  : BOOL (default FALSE)

Event must be enabled again after event has been detected

 

Threshold : DINT (0..16000, default 0)

The acceleration which each axis is compared against to detect the start and end of a shock (in mg).

 

Duration : DINT (1..5120)

The time in milliseconds before which the end of a shock must occur.

 

Latency : DINT (0..10240, default 0)

Number of milliseconds where shocks are ignored.

 

Window : DINT (0..10240, default 0)

Number of milliseconds before the second shock must occur.

   0  : single shock detection

 >0  : double shock detection

 

X  : BOOL (default TRUE)

Detects shocks on x-axis

 

Y  : BOOL (default TRUE)

Detects shocks on y-axis

 

Z  : BOOL (default TRUE)

Detects shocks on z-axis

 

Returns: INT

0

- OK

-1

- General error.

-2

- Interface not open (see accOpen).

-3

- Invalid argument.

 

Declaration:

FUNCTION accSetShockEvent : INT;
VAR_INPUT
  Threshold : DINT;
  Duration  : DINT;
  Latency   : DINT;
  Window    : DINT;
  Once      : BOOL;
  X         : BOOL;
  Y         : BOOL;
  Z         : BOOL;
  Enable    : BOOL;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  e : INT;
END_VAR;
accOpen();
accSetShockEvent(Threshold := 500, Duration := 10, Z := TRUE, Enable := TRUE);
BEGIN
e := accWaitEvent(timeout := 60);  
 ...
END;
END_PROGRAM;