msAccEnable (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, LX2

Firmware version:

1.50.00


Configure and enable/disable the accelerometer for data acquisition using msDataSet with msRead or through the data logger (see msLoggerCreate).

The accelerometer data can reflect either absolute or relative mode. In absolute mode the 1g gravity pull on the device will show, otherwise not.

Mixed mode gives absolute data readings, but events are triggered by relative measurements.

 

Input:

Enable : BOOL (default TRUE)

Enable or disable the accelerometer.

 

Mode : SINT (1, 2, 3) (default 2)

Mode of operation. 1 = relative mode, 2 = absolute mode, 3 = mixed mode.

 

Resolution : INT (2, 4, 8, 16) (default 16)

The range of the measurements the device can measure in units of gravity g. F.ex. the value 2 represents the range: [-2g ; +2g].

 

Returns: INT

1

- Success.

0

- This function is not supported.

-1

- Interface is not open. Call msOpen first.

-2

- Generic error.

-3

- Invalid configuration, including if the sensor is already enabled/disabled.

-6

- The accelerometer is not present.

 

Declaration

FUNCTION msAccEnable : INT;
VAR_INPUT
  Enable     : BOOL := TRUE;
  Mode       : SINT := 2;
  Resolution : INT  := 16;
END_VAR;
 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
  rc : INT;
END_VAR;
// Open interface
rc := msOpen();
DebugFmt(Message:="msOpen (rc=\1)", v1:=rc);
// enable accelerometer
rc := msAccEnable(enable:=TRUE, mode:=2, resolution:=16);
DebugFmt(Message:="accEnable ON (rc=\1)", v1:=rc);
...
BEGIN
  ...
END;
END_PROGRAM;