We’re rewarding the question askers & reputations are being recalculated! Read more.
8

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 mathematically. Velocity is the integral of acceleration with respect to time: Similarly, position is the integral of velocity with respect to time: Here is an ...


8

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" pending (a signal from the ADXL345 that something has happened) the corresponding INT pin is held LOW. It remains LOW until the interrupt has been handled by ...


7

Is there any other way to send more than 100 values in one message? Yes. Don't use String. Don't use concat(). Just print each bit as a separate Serial.print() function call.


6

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 calculate velocity instantaneaously. In order to do so follow these instruction. Pleas note that this is only 1 axis reading in actual case you will have to perform ...


6

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 equivalent to multiplying by 256. If you are using a 32-bit microcontroller (e.g. an Arduino Due), this is safe. However, most Arduinos are based on an 8-bit ...


5

The Accelerometer measures total acceleration on the vehicle, including the static acceleration from gravity it would experience even when its not moving. The magnetometer measures the magnetic field around the robot, including the static magnetic field pointing approximately north caused by the earth. Being placed in/around a metal frame or any large ...


5

You need 2 typecasts. So atan(-ax/sqrt((float)ay*ay+(float)az*az)); Otherwise it will use int16_t for the right side of the addition and overflow. Though for speed you might want to typecast them as long (int32_t), as floats calculations on the arduino are really slow. The sqrt function will covert this double into a float for you.


5

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 than a rough "It's moving quick" or "it's moving slower now" accuracy.


5

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 direction when acceleration changes. You would want some code which gives you a variable hovering around "338", with random acceleration spikes injected in ...


5

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 can be read as fast as main memory this is a reasonable approach. But what if you really want the code to be "interrupt-fast" without writing code that might ...


4

Might be a little late, but you can string more than two of these on one I2C bus, with a little ingenuity. You connect the AD0 pin of each MPU to a different I/O pin of the processor, then take low the address of the one MPU you want to talk to. Then that MPU has one address, all the others have the other address, and being slaves will not respond. ...


4

Sitting an accelerometer flatly on a bench will produce a value of 1G in one of the 3 axes. Free fall of an accelerometer (assuming you haven't reached terminal velocity) should read near zero on all 3 axes. I am not aware of a mode you can set for this, but if you check the values of the 3 axes and all are close to zero, you are probably in a free fall ...


4

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 other sensors (i.e. a GPS) to your project, it might be worth looking into Extended Kalman Filters (https://github.com/simondlevy/TinyEKF), which are usually able ...


4

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. C.f. the first statement in the method, which is a call to micros(). The pauses between your 20-sample buffers are then interpreted like long times during ...


4

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. It can be done, but requires some engineering time to code it and processor time to run. It wasn't clear to me at a quick read whether your chosen IMU can do ...


4

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 upwards, your index finger away from you, and your middle finger to the left. You now have a righthanded coordinate system: your thumb is the x axis, your index ...


3

The main difference is the way they operate and what they sense. In other words, they are all very very different things. Yet they can all measure motion in some way. An accelerometer senses both the gravitational pull of the earth and the inertia / momentum of the motion of the device A magnetometer senses the earth's magnetic field to get a compass ...


3

for each accelerometer: sample the accelerometer; low-pass filter its values (current and recent history) to remove noise; multiply by the sample interval to get the velocity increment; add the increment to a running sum to get velocity; sample the velocity (the running sum you just updated); maybe low-pass filter, as above; multiply by ...


3

I played around more with it, and this code works: void MMA8452::initMMA8452(unsigned char fsr, unsigned char dr, unsigned char sr, unsigned char sc, unsigned char mt, unsigned char mdc) { MMA8452Standby(); //Set up the full scale range to 2, 4, or 8g. if ((fsr==2)||(fsr==4)||(fsr==8)) writeRegister(XYZ_DATA_CFG, fsr >> 2); else ...


3

where should I put the pins for SDA and SCL? Same as on a Uno: SDA is on pin A4 SCL is on pin A5 Can you suggest me some links that can help me learn more about SPI? I have an SPI page and also one about I2C. There is also a page about SPI on this site: How do you use SPI on an Arduino? If you want to use 5 devices, it sounds like Majenko's ...


3

I have had a very similar problem and the Arduino core team has accepted a change from me to facilitate this functionality. It is a complex story so you may have to reread a couple of times. 1) Serial.print returns before the data is send over serial. The first thing to realize is that when you do serial.print() the data is not actually send over serial. ...


3

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 values, say (in hex) 0x37 and 0x42, and you OR them together you get: 0x37 = 00110111 0x42 = 01000010 --------------- | 0x77 = 01110111 In each column where ...


3

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 thus not really stable, but only marginally stable. Any parasite DC component in the input will make the output drift without bounds. It seems to me that your ...


3

Processing code is intended to be run on a computer. You would use the Processing IDE to run this code. The Arduino IDE is used to write, compile, and upload code to a microcontroller that you might have on an Arduino board. This is the cause of the error.


3

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. For simple arrangements where the accelerometer is near the MCU that makes no difference. However the analog one is more susceptible to noise. With longer wires / ...


2

In 'FULL_RES' mode the number you get is amount of 4mg units. So 1 is 4mg, 2 is 8mg, -4 = -32mg. Also note that your current code doesn't interpret the first bit (so the 13th from the right) as the sign bit, so you'll never get negative values. (Question related to this) PS I think it is actually more like 3.9mg.


2

Since it won't convert to two's complement if the sign bit is the 14 bit instead of the 16th, it would be easier to just shift the value left by 2. So int bresult= result<<2; Since <<2 is the same as *4 the result will be 4 times as high. So you need to divide the result by 4. Since you already have to multiply by 0.025 (or divide by 40), you ...


2

I searched quite some time for everything regarding the MPU6050, but there is just rumors and jokes about the dmp funcionality. One project encorporates the hard reverse-engeneering some wise people did, which is: http://www.i2cdevlib.com/docs/html/class_m_p_u6050.html This also uses the interrupt, which I suppose you can't really avoid. Why exaclty this ...


2

Page 23 of the manual you linked: The MPU-9250 always acts as a slave when communicating to the system processor. The LSB of the of the I2C slave address is set by pin 9 (AD0). It seems you can only choose between two addresses as listed in the table on page 12.


2

If I understand your question, the main issues are that the axis don't match up, and z from the accel is not accurate? with respect to the axis: just swap the values. Rotation math is self-consistent and "correct" in many different permutations. What makes it correct is the set of equations, not any single equation; So, copying equations from one reference ...


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