Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes
Accepted

Detecting distance moved by accelerometer?

This is normally referred to as Dead Reckoning. The processes of determining position using known values, such as acceleration. First we have to relate acceleration, velocity and position ...
st2000's user avatar
  • 7,338
9 votes
Accepted

What is the right way to query an I2C device from an interrupt service routine?

Just because a pin is called "interrupt" doesn't mean that you have to read it using an interrupt input. The INTx pins of the ADXL345 are simple "level" outputs. All the time there is an "interrupt" ...
Majenko's user avatar
  • 105k
6 votes
Accepted

Can I measure velocity from an accelerometer? How accurately?

The sensor in itself can't provide you the velocity. I have used it accelerometers in a couple of projects the easiest way to get the velocity is to constantly monitor acceleration changes and ...
usamazf's user avatar
  • 196
5 votes
Accepted

Is it possible to measure the velocity of a Unmanned Aerial Vehicle using only accelerometer?

Not with any measure of accuracy, no. You're basically asking about Dead Reckoning which is problematical at best - and when doing it with just a low-grade accelerometer it can't be anything more ...
Majenko's user avatar
  • 105k
5 votes

What does this notation stands for? Wire.read() <<8 | Wire.read()

Just adding a couple of points to Michel Keijzers's answer. The expression Wire.read() << 8 takes the value returned by Wire.read(), which is an int, and shifts it 8 bits to the left, which is ...
Edgar Bonet's user avatar
  • 43.2k
5 votes
Accepted

How can I simulate an accelerometer?

Your sensor supplies an analog signal, ranging from 0V for -3g to 3.3V for +3g. This means you have a signal averaging at "338" when read using Arduino's analogRead() function, with spikes in either ...
towe's user avatar
  • 865
5 votes

What is the right way to query an I2C device from an interrupt service routine?

Majenko's answer is useful — you can simply forego the use of interrupts for this and poll the pin directly in your main loop. Especially on AVR where the external pins are exposed as registers which ...
hobbs's user avatar
  • 234
5 votes
Accepted

A proper way to get the roll, pitch and yaw values

In some sources there is something going on as the importance of order of the application of roll,pitch and yaw. But I cannot understand why this is related. Take your right hand: point your thumb ...
tttapa's user avatar
  • 1,320
5 votes

Help with reading data from ADXL373 Accelerometer (I2C)

According to the datasheet, the 12 bits of the X acceleration are stored into the registers XDATA_H and XDATA_L as follows: XDATA_H: b₁₁b₁₀b₉ b₈ b₇ b₆ b₅ b₄ XDATA_L: b₃ b₂ b₁ b₀ x x x x where ...
Edgar Bonet's user avatar
  • 43.2k
4 votes

Can I measure velocity from an accelerometer? How accurately?

I work with Arduino-based autopilot modules, which usually use similar sensors in addition to GPS data to maintain a reasonable estimate of its position/velocity/acceleration. If you were to add ...
naiello's user avatar
  • 91
4 votes
Accepted

Does the position in which you mount an IMU matter?

If the axes of measurement don't line up with the axes of motion, then comparing the IMU outputs to vehicle-relative (VR) coordinates will require some vector arithmetic to convert one to the other. ...
JRobert's user avatar
  • 15.3k
4 votes
Accepted

Stabilize data from four gyros/accelerometer

Looking at your code, I see the only place where gyro_1_angle_x is updated is here: gyro_1_angle_x = gyro_1_angle_x + (gyro_1.gyro.x - mpu_1_gyro_err_x) * elapsedTime; This is adding to ...
Edgar Bonet's user avatar
  • 43.2k
3 votes

Accelerometer sample code

To understand this you have to start thinking in binary. The | operator is "Perform a binary OR on these two values". The <<8 is "Shift this value 8 bits to the left". If you have two 8-bit ...
Majenko's user avatar
  • 105k
3 votes
Accepted

Help with MPU-6050

I finally got this working after one sleepless night #include<Wire.h> const int MPU = 0x68; int t = 0,dt = 1; int AcX,AcY,AcZ,GyX,GyY,GyZ,tmp; int AcXo,AcYo,AcZo,GyXo,GyYo,GyZo; float roll = 0,...
Teja Allani's user avatar
3 votes

High pass filtering accelerometer data on Arduino

This filter library is sensitive to the timing of you calling FilterOnePole::input(). It assumes that the delays between consecutive calls are the same as the delays between the samples being measured....
Edgar Bonet's user avatar
  • 43.2k
3 votes
Accepted

Analog vs Digital Accelerometers - pro's and con's?

The biggest difference is where the measurement (the conversion to digital) is done. On the digital accelerometer, it is done in the accelerometer itself. On the analog one it is done at the MCU. ...
Majenko's user avatar
  • 105k
3 votes

Adafruit_LSM303 tilt compensated compass

The sin() and cos() functions expect their arguments to be in radians. If you feed them with anything else, be it degrees, percent slope, or whatever, expect the result to be just crap. Edit: The OP ...
Edgar Bonet's user avatar
  • 43.2k
3 votes

Does anyone have code that successfully calculates velocity from an accelerometer

Calculating velocity from acceleration is not easy. Simply put, velocity is derived by calculating the integral of acceleration with respect to time. In practice, however, this leads to accumulated ...
st2000's user avatar
  • 7,338
3 votes

Do I connect multiple I2C units to the microcontroler in series or parallel?

Use the Wikipedia page on the protocol as an introduction to your learning curve on I2C. I may cite: At the physical layer, both SCL and SDA lines are [a ...] bus design, [...] This means that all ...
the busybee's user avatar
  • 2,078
2 votes
Accepted

Accelerometer Interrupt Meaning - Wakeup Function

The INT_GEN_CFG_XL 6-Direction detection interrupt apparently is aimed at detecting change of direction of travel, rather than an axis-combined acceleration level. See the LSM303 discussion at Polulu....
James Waldby - jwpat7's user avatar
2 votes

MPU6050 acceleration values not 16-bit?

The ADC for the accelerometer is 16 bit, yes. Also the data being sent out is in 16 bit format. But what you are confusing is resolution and range. The accelerometer can be programmed to have a ...
Majenko's user avatar
  • 105k
2 votes

PID control arduino

Ensure that your period for the PID execution routine is reasonable for your system. I generally like to execute my PID loops at 5 to 20 times the system impulse response. For instance, with a motor,...
slightlynybbled's user avatar
2 votes

Arduino SPI Communication with H3LIS100DL accelerometer

The basic SPI operations looks like this. First read single register: uint8_t readRegister(int index) { digitalWrite(CS, LOW); SPI.beginTransaction(SPI_SETTING); SPI.transfer(READ | index); ...
Mikael Patel's user avatar
  • 7,969
2 votes

Using MMA8451 accelerometer to count steps

Change your if statement - remove ; (semicolon) from the end. Use this: if (event.acceleration.x >= 5) accum = accum + 1; Notice there is no semicolon after if statement
r-sniper's user avatar
  • 158
2 votes

Best way to detect tilt using MPU 6050

Well suppose you have a starting position, let's say 0 degrees, then once you detect and angle change, let's say 10 degrees, you know that there is a tilt of 10 degrees on one of the 3 axies. The ...
Dat Ha's user avatar
  • 2,913
2 votes
Accepted

Arduino rc plane logger

It is not an Arduino answer but a Raspberry Pi with a Sense hat will record most of what you need with little coding. Add a Pi camera and you have all this for about $100. The Sense Hat temperature ...
GBG's user avatar
  • 178
2 votes
Accepted

How to get and interpret digital accelerometer data?

The sensor allows for data values of 10 bits but for simplicity I am getting only the 8 bit data you are using it in 2g mode, so you have only 8bit of data. The data received when the sensor is on a ...
Lesto's user avatar
  • 771
2 votes

What does this notation stands for? Wire.read() <<8 | Wire.read()

1 << 3 means the value 1 shifted 3 times to the left. So 1 in binary is 0000001, shifted left 3 places is 00001000. And 0001101 << 3 will be 1101000. The | command is a logic or (where ...
Michel Keijzers's user avatar
2 votes
Accepted

How can I2C be made to work through a level shifter?

For I2C you need a special kind of logic translator. This one isn't suitable. This device can only translate push-pull CMOS logic outputs. If for open-drain signal translation, please refer to TI ...
Majenko's user avatar
  • 105k
2 votes

Why is this IIR Filter unstable on the Arduino Due?

The precision of a float is about 7 significant digits. The constant term of B in your transfer function (0.00000376) has only 3 significant digits. Your transfer function has a pole at z = 1. It is ...
Edgar Bonet's user avatar
  • 43.2k

Only top scored, non community-wiki answers of a minimum length are eligible