accOpen (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

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

Firmware version:

2.40 / 1.40.00


This function will open the accelerometer interface. Calling this function is required before the accelerometer interface can be used.

This interface and the Motion Sensor (MS) interface are mutually exclusive, thus only one of them can be used at a time. See also msOpen.

 

The device is unable to detect vibration (using pmVibration or pmWaitEvent) when the acceleration interface is open.

 

 

Modes

The mode parameter will determine how if acceleration event and readings are relative to motion or gravity of earth.

1:

RELATIVE.

The changes in g-forces are measured as yielding the acceleration relative to the actual motion. With a steady acceleration, all axes will read zero.



2:

ABSOLUTE.

All g-forces acting on the device are measured - therefore giving the absolute acceleration. This includes the force of earth gravity, which is to say that when it is not in motion and placed on at flat surface, the Z-axis will read -1000.



3:

MIXED.

All g-forces acting on the device are measured as in ABSOLUTE mode, while events are triggered relative to motion as in RELATIVE mode.

 

acc3d_acceleration_modes

Acceleration measured as it reaches a constant acceleration in both ABSOLUTE and RELATIVE mode.

 

Input:

Mode : SINT (1..3, Default 1)

Determine how accelerations and events are measured and triggered, for details see description of the modes above.

 

Returns: INT

0

- Success.

- 1

- General error.

- 2

- Interface already open.

- 3

- Invalid mode.

- 4

- Not enough memory.

-5

- Motion Sensor interface is open. Use msClose to close interface.

 

Declaration:

FUNCTION accOpen : INT;
VAR_INPUT
  Mode : SINT := 1;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
  accOpen();
  ...
  accClose();
END_PROGRAM;