Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set iPhone accelerometer to ±8g mode

Is it possible to set iPhone accelerometer to receive data in the ±8g range? (as far as I know ST LIS331DLH accelerometer installed on iPhone supports this mode)

We are looking not only into standard API, but also

  • undocumented functions
  • possible iOS hacks
  • hardware tinkering

Anyway to extend accelerometer range beyond standard ±2g

like image 561
Evgeny Vinnik Avatar asked May 28 '12 18:05

Evgeny Vinnik


People also ask

What type of accelerometer is in an iPhone?

An accelerometer measures changes in velocity along one axis. All iOS devices have a three-axis accelerometer, which delivers acceleration values in each of the three axes shown in Figure 1.

Is iPhone accelerometer sensitive?

It is rated to consume 3.4 mA in the six-axis mode, 3.2 mA in the gyroscope mode and 450 µA in the accelerometer normal mode.

How accurate is iPhone accelerometer?

The coefficient of variation was less than 3% at velocities from 30°/s to 120°/s and less than 7% at 150°/s. Conclusions: The app was highly accurate and precise.

Where is the accelerometer on iPhone?

I recorded the distance of the bottom of the phone to the center with a radius of 0.09 meters. This means that the accelerometer is 5.1 centimeters above the bottom of the phone.

What type of accelerometer does the iPhone use?

The original iPhone, and first generation iPod touch, use the LIS302DL 3-axis MEMS based accelerometer produced by STMicroelectronics. Later iPhone and iPod touch models use a similar LIS331DL chip, also manufactured by STMicroelectronics. Both of these accelerometers can operate in two modes, allowing the chip to measure either ±2g and ±8g.

Is it possible to change the operating mode of the accelerometer?

While it should in theory be possible to change the operating mode of the accelerometer, there is currently no published API that allows you to do so within the SDK. The iPhone’s accelerometer measures the linear acceleration of the device so it can report the device’s roll and pitch, but not its yaw.

What is the difference between the ±2G and ±8G modes?

In both modes the chip can sample at either 100 Mhz or 400 Mhz. Apple operates the accelerometer in the ±2g mode (presumably at 100 Mhz) with a nominal resolution of 0.018g. In the ±8g mode the resolution would be four times coarser, and the presumption must be that Apple decided better resolution would be more useful than a wider range.

How does the accelerometer know if the phone is facing up?

The accelerometer measures this spring compression and uses that to determine the acceleration of the phone. With that, it will know if it is facing up or down. It also can estimate how far you move and use this along with the camera to find out where real world objects are, using ARKit.


1 Answers

My "answer" doesn't contain direct answer to Evgeny's question. However I found a bunch of undocumented functions which probably can help.

I have searched whithin iOS SDK for functions related to accelerometer. It seems like everything boils down to one of two frameworks (other frameworks rely on one of these): SpringBoardServices (Private) and CoreMotion.

SpingBoardServices API is relatively simple: See also: SBSAccelerometer description

objective-C API:

@interface SBSAccelerometer : XXUnknownSuperclass {     id<SBSAccelerometerDelegate> _delegate;     CFRunLoopSourceRef _accelerometerEventsSource;     CFRunLoopRef _accelerometerEventsRunLoop;     double _interval;     NSLock* _lock;     BOOL _orientationEventsEnabled;     int _orientationEventsToken;     NSThread* _orientationEventsThread;     float _xThreshold;     float _yThreshold;     float _zThreshold; } @property(assign, nonatomic) id<SBSAccelerometerDelegate> delegate; @property(assign, nonatomic) BOOL orientationEventsEnabled; @property(assign, nonatomic) float zThreshold; @property(assign, nonatomic) float yThreshold; @property(assign, nonatomic) float xThreshold; @property(assign, nonatomic) double updateInterval; @property(assign, nonatomic) BOOL accelerometerEventsEnabled; -(id)init; -(void)dealloc; -(void)_checkIn; -(void)_checkOut; -(void)_serverWasRestarted; -(int)currentDeviceOrientation; -(id)_orientationEventsThread; -(void)_orientationDidChange; @end  

C-API (methods' signatures are unknown):

int SBAccelerometer_server(struct unknown *in, struct unknown *out); //returns 1 on success, 0 otherwise int SBAccelerometer_server_routine(struct unknown *in); // retuns 0 on error; (?) SBSetAccelerometerClientEventsEnabled(...); (?) SBSetAccelerometerDeviceOrientationChangedEventsEnabled(...); (?) SBSetAccelerometerRawEventsInterval(...); (?) SBXXDeliverAccelerometerEvent(...); (NSString* or char*) _SBXXSBAccelerometer_subsystem; 

CoreMotion framework low-level API is C++ API. I won't publish all the API (it's much bigger than SpingBoardServices'), but there are most promising parts:

CLSensorFusionAccelerometerOnly::reset(float) CLSensorNetworkProtocol::isAccelerometerPacket(__CFData const*) CLSensorNetworkProtocol::serializeAccelerometerPacket(CLAccelerometer::Sample const&) CLSensorNetworkProtocol::deserializeAccelerometerPacket(__CFData const*) CLSensorInterface::setAccelerometerCallbackAndInfo(void (*)(void*, CLMotionTypeVector3 const&, double const&), void*) 
like image 130
Oleg Trakhman Avatar answered Sep 21 '22 08:09

Oleg Trakhman