accShockEvent (Functionblock)

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


accShockEvent retirnes the information of a shock event.

Note that the information is only valid after a "Shock" event is raised; the event will be removed when this function block is called.

A "Shock" event is raised when a shock is experienced that matches the parameters set when monitoring was enabled.

 

 

Input:

None.

 

Output:

X  : BOOL

Detected shock on x-axis.

 

Y  : BOOL

Detected shock on y-axis.

 

Z  : BOOL

Detected shock on z-axis.

 

Ready : BOOL

Is event removed and data updated.

 

Declaration:

FUNCTION_BLOCK accShockEvent;
VAR_OUTPUT
  X     : BOOL;
  Y     : BOOL;
  Z     : BOOL;
  Ready : BOOL;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  shock : accShockEvent;
END_VAR;
 
FUNCTION ReadShockEvent;
  shock();
  IF shock.ready THEN
    DebugMsg(message := "*** acceleration event received ***");
    DebugFmt(message := "-x=\1", v1 := INT(shock.x));
    DebugFmt(message := "-y=\1", v1 := INT(shock.y));
    DebugFmt(message := "-z=\1", v1 := INT(shock.z));
  END_IF;
END_FUNCTION;
 
THREAD_BLOCK accMonitor;
VAR
  event : INT := 0;
END_VAR;
 
WHILE event <> -1 DO
  event := accWaitEvent(timeout := -1);
  CASE event OF
     ...
    8: ReadShockEvent();
     ...
  END_CASE;
END_WHILE;
END_THREAD_BLOCK;