| Arduino Forum ::  Members :: wilywampa
 Show Posts Pages: [1]
 1 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: July 09, 2014, 02:42:16 pm I gave the solution in the fourth post of this thread. If that code doesn't work, the problem is the inputs.
 2 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: April 21, 2014, 12:28:35 pm Quote from: michinyon on April 20, 2014, 02:47:34 pmThat is a bad initialisation choice for a quaternion.    The x,y,z components represent a scaled unit vector ( multiplied by the sine of the rotation ),   but 0,0,0    cannot be scaled to a unit vector by any means.This is wrong, and the reason why it's wrong is right in front of you: "multiplied by the sine of the rotation." When the rotation is zero, the sine is zero, and you get 1,0,0,0. Plug in zero roll, pitch, and yaw into any Euler angle to quaternion calculator and see what you get.wilhem: That data doesn't look right. Try printing out the inputs to the filter instead of the outputs, and make sure the inputs are continuous and otherwise look as expected.
 3 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: April 20, 2014, 02:43:09 pm b_z and b_x represent the filter's estimate of the direction of Earth's magnetic flux. I initialize b_x to zero and b_z to 1 and the quaternion to 1,0,0,0.
 4 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: April 19, 2014, 11:23:00 am It sounds like you have the right idea. The filter doesn't need the accelerations or magnetometer measurements in any specific units because it uses them to compute a unit vector's direction. As long as the three components have the same scale factor, the actual value of that scale factor doesn't matter. Depending on the quality of your sensors and what you're trying to achieve, you may not need to remove an offset from the accels/mags, but you'll get the best results if you calibrate them to find where zero is for each axis.
 5 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: October 27, 2013, 06:39:28 pm I found the problem! It actually seems to be a mistake in the paper. twom_x, twom_y, and twom_z need to be computed after normalizing the magnetometer reading. In the paper, they are computed before the normalization. Here's the corrected function: http://pastebin.com/KiwcEgXSand the new results:That took a long time.
 6 Using Arduino / Programming Questions / Re: Trouble implementing Madgwick AHRS (with MATLAB sample) on: October 27, 2013, 05:05:59 pm I'm trying to get this to work on an Arduino. I moved it into MATLAB to make it easier to debug.I didn't really want to post the Arduino code because I gave links to it, and it's already all over the internet, but here it is for each filter:Common version: http://pastebin.com/XUF7bpWuWhite paper version: http://pastebin.com/jmGVs4Ri
 7 Using Arduino / Programming Questions / Trouble implementing Madgwick AHRS (with MATLAB sample) on: October 27, 2013, 03:46:40 pm I'm trying to implement the MARG AHRS filter given at the end of Madgwick's paper: http://www.x-io.co.uk/res/doc/madgwick_internal_report.pdfI have already successfully implemented the more common filter also by Madgwick here: http://www.x-io.co.uk/res/sw/madgwick_algorithm_c.zipFor some reason the version in the paper diverges when I use it. I want to use the paper version because it should be more accurate and it estimates gyro biases. Below are the results from the common version and the white paper version:I attached a zip file with the MATLAB data/scripts to reproduce those results. I have tried changing which axes are which and varying the tuning parameters, but it always seems to diverge. Has anyone successfully used both versions of the filter?The sensors are an ADIS16355 for accel/gyro and LSM303 for mag.
 8 Using Arduino / Networking, Protocols, and Devices / Re: Trouble communicating with Analog Devices ADIS16355 IMU over SPI with Teensy 3.0 on: November 10, 2012, 10:56:26 pm I'm totally having a conversation with myself here, but there is a tDATASTALL called on in the datasheet which is exactly what I need. It says 9 microseconds minimum. Does that already include some kind of safety factor, or should I add my own, say by using a 15 microsecond stall time?
 9 Using Arduino / Networking, Protocols, and Devices / Re: Trouble communicating with Analog Devices ADIS16355 IMU over SPI with Teensy 3.0 on: November 10, 2012, 10:51:51 pm The code is working exactly as intended after I put 1 millisecond delays between data frames, and the link I provided in the OP has the corrected code. I do need to find out how small to make that delay, but other than that, I have to say I'm rather proud of doing this in one day without using SPI before.
 10 Using Arduino / Networking, Protocols, and Devices / Re: Trouble communicating with Analog Devices ADIS16355 IMU over SPI with Teensy 3.0 on: November 10, 2012, 10:36:21 pm Now I put a delay(1) between the two data frames in the readAddress function, and it's giving me the correct data. I assume that delay doesn't need to be nearly so long, but I can't find a minimum value for it in the datasheet. How do I know how long that delay needs to be?
 11 Using Arduino / Networking, Protocols, and Devices / Re: Trouble communicating with Analog Devices ADIS16355 IMU over SPI with Teensy 3.0 on: November 10, 2012, 10:20:54 pm Made some progress, I think... I moved SPI.begin() to before the SPI.setBitOrder(), SPI.setClockDivider(), and SPI.setDataMode() commands. Now the LED does light up and I get different output, though still not correct:Code:Z Accel (g): 0.64Z Accel (g): 0.64Z Accel (g): 0.48Z Accel (g): 0.48It seems to only give one of those two values at a time depending on how I tilt the IMU. Better than nothing...