ms: Motion Sensor

Top  Previous  Next

The latest generation of automotive NX32L devices offers a powerful set of inertial sensors that can be used for applications, such as driving behavior analysis, activity monitoring, indoor positioning, virtual ignition, and crash detection.

By combining the inertial sensors with the GNSS sensor enhanced navigation and dead reckoning applications can be implemented.

 

The full 3-axis accelerometer, gyroscope, and magnetometer are tightly integrated into the RTCU M2M Platform with a uniform motion sensor interface and full support for power management for the most demanding applications.

 

The motion sensor interface gives the basic tools needed to use the embedded sensors and can thus be used to develop sensor fusion applications.

 

Sensors

With this interface comes access to simultaneous sets of accelerometer, gyroscope and magnetometer measurements.

 

Accelerometer:

The accelerometer measures accelerations. This is useful to measure changes in velocity and changes in position (by integrating the signal).

The interface delivers accelerometer data in units of gravity G (SI standard: 1.0 m/s2 [meters per second squared]), with a maximum range of [-16.0G : +16.0G]. The accelerometer measurements represents the resulting forces acting on the device. Static forces as the gravity pull can be observed, but it is also possible to get the relative measurements, thus representing the actual changes in velocity of the device in any given direction.

 

Gyroscope:

The gyroscope measures changes in the orientation.

The interface delivers gyroscope data in units of degrees per second (dps), with a maximum range of [-2000.0dps : +2000.0dps]. The gyroscope data represents the rotational changes of the device in any given direction. With no movement of the device, the gyroscope ideally measures zero on all axis. With calibration from knowing the direction of gravity with the accelerometer, it is thus possible to know the orientation of the device in 3-dimensional space (yaw, pitch and roll) with high precision.

 

Magnetometer:

The magnetometer measures magnetic fields. Because the earth has a significant magnetic field, the magnetometer can be used as a compass. The interface delivers magnetometer data in units of gauss (SI standard: 1/10000 Tesla), with a maximum range of [-50.0gauss : +50.0gauss]. The magnetometer data represents the magnetic impact on the device from the surrounding environment. It is thus possible to measure the magnetic north in an area with low magnetic disturbances. Radar pulses with a time frame greater than the sampling frequency will also be detectable.

 

 

Architecture of the Motion Sensor Interface

The Motion Sensor interface is based on an asynchronous event-based model, where solicited as well as unsolicited events from the sensors are automatically queued and delivered to the user application. The function msWaitEvent is used to return information about the various events arriving from the sensors. This model eliminates the requirement for the application to continuously poll for messages, and it also encourages use of multithreading with the added benefits that comes with this.

Events that are triggered by the application requesting various information from the sensors are therefore called solicited events, or alternatively they can be triggered by the sensors, and are therefore instead called unsolicited events. A solicited event is for example, when the application calls msLoggerStop and then msWaitEvent returns with event# 4. An unsolicited event works exactly the same way as a solicited event, except for the fact that msLoggerStop is no longer called by the application.

Please consult msWaitEvent for detailed information about the various events and how they are handled.

 

 

The following functions and structures are used to access the Motion Sensor interface:

 

Interface and setup

The following functions are used to access the interface and set global motion sensor settings.

 


msOpen

Opens the interface for use and sets operation to default mode.


msClose

Closes the interface and clears its wake-up sources.


msConfig

Set data acquisition rate.

 

 

Data acquisition

The following functions and structures are used to start various sensors and get data.

 


msAccEnable

Enable the accelerometer.


msGyrEnable

Enable the gyroscope.


msMagEnable

Enable the magnetometer.


msDataSet

Structure to read sensor data with.


msRead

Read a set of sensor data.

 

 

Data logger

The following functions and structures are used to log sensor data to buffers and read the data.

 


msLoggerCreate

Create a logger.


msLoggerDestroy

Remove a logger.


msLoggerAddAcc

Add accelerometer data acquisition ability to a logger.


msLoggerAddGyr

Add gyroscope data acquisition ability to a logger.


msLoggerAddMag

Add magnetometer data acquisiotion ability to a logger.


msLoggerStart

Start specified logger.


msLoggerStop

Stop specified logger.


msLoggerNext

Request which type of sensor data record is the next to read.


msLoggerRead

Read a sensor data record from the logger buffer. A record from the oldest set is given.


msLoggerLevel

Tells how full a given logger buffer is in promille.


msTimestamp

Structure to read a time stamp data record with.


msAccData

Structure to read an accelerometer data record with.


msGyrData

Structure to read a gyroscope data record with.


msMagData

Structure to read a magnetometer data record with.

 

 

Event handling

The following functions and structures and used to manage and read sensor and logging related events.

 


msEventRegister

Register an event handler, consisting of an event configuration and a possible action.


msEventUnregister

Unregister an event handler.


msWaitEvent

Wait for the next event or a timeout.


msReadEvent

Read event data according to last event.


msEventLogWatermark

Structure to configure a logger watermark event.


msEventLogFull

Structure to configure a logger full event.


msEventShock

Structure to configure shock detection events.


msEventAcceleration

Structure to configure acceleration detection events.


msActionStopLogger

Structure to stop a logger on an event.


msActionStartLogger

Structure to start a logger on an event.


msActionSwitchLogger

Structure to switch active logger to another logger on an event.


msReadWatermark

Structure to read returned watermark event data.


msReadShockEvent

Structure to read returned shock event data.


msReadAccelEvent

Structure to read returned acceleration event data.

 

 

Power management

The following functions are used to add wake-up sources to power management.

 


msVibrationSetWakeup

Enable or disable the ability to wake from low power modes with device vibration. See pmSuspend.

 

 

Calculation functions

The following functions are used to perform calculations on the sensor data.

 


msCompassHeading

Calculates a measure for magnetic north.


msVectorToAngles

Calculates axis angles relative to acceleration.


msVectorToForce

Calculates the total force of acceleration.

 

 

Limitations:

For the acceleration and shock events to be detected, the accelerometer must be enabled with logger functionality running. See example under msEventRegister.

 

Only one acceleration event handler configuration and one shock event handler configuration can be active at a time.

Only 8 loggers can be in the system at a time.