PDA

View Full Version : IMU Upside Down



Jay Kickliter
12-31-2008, 10:13 PM
I've been using the IMU object paired with the Sparkfun 5 Degree of Freedom board to make a rudimentary artificial horizon. I can't get it to work upside down. Is this an inherent flaw?

What's happening is that whenever either pitch or roll passes +/- 90 degrees the other axis shoots from around 0 degrees to almost +/- 180 degrees. So I can never get the sphere to go upside down.

A video would be better, but I'm attaching a photo. What's happening in the photo is that the board is being held with a level roll but a pitch of about 90 degrees away from me, so I should be seeing all black, but since the board is saying that there is also about 180 degrees of roll, the sphere rotates around and I see the blue side.

Post Edited (Jay Kickliter) : 12/31/2008 3:21:05 PM GMT

kelvin james
01-01-2009, 03:34 AM
I would guess your sensor does not support that capability.


**

kelvin james
01-01-2009, 07:34 AM
Hmmm, I just checked my os5000 compass which has 360 degree support, and roll works fine because the compass heading is in the same direction. Since pitch is tied with the compass , once you cross the 90 degree mark for pitch, then the heading and roll will be inverted, because the compass is upside down in the opposite direction. Make sense? The more i think about it, the more confused i get.

Anyway, once you cross the magic mark, the whole thing goes out of whack.


**

shanghai_fool
01-01-2009, 11:09 PM
The 5DOF from Sparkfun works correctly in any direction. From level, it goes plus or minus from the center value 0f 2048. The IMU object demonstrates the correct functions. You have to add in the Z axis to get correct values from 90 to 180 degrees. The attached demo will illustrate this. I use PC_Interface but you can use display of your choice. The 5DOF is interfaces through an MCP3208 12 bit A/D. Full documentation is in OBEX
IMU_-_Archive__Date_20081.03.09__Time_21.22.zip



{{ IMU Demo }}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
#0, WHITE,CYAN,RED,PINK,BLUE,GREEN,YELLOW,GRAY 'Standard colors
OBJ
term : "PC_Interface"
imu : "IMU"
fp : "FloatString"
fm : "FloatMath"

PUB Main | b , r

'start the interface
term.start(31,30)
term.setcol(YELLOW)
term.str(string("IMU Demo..."))
term.setcol(CYAN)
term.out(0)
r := imu.start(25,26,27)
fp.SetPositiveChr(" ")
fp.SetPrecision(4)
waitcnt((clkfreq *3) + cnt)
repeat
b :=0
setpos (0,b++)
r := imu.get_angle_Pitch
term.str(string("get_angle_Pitch "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_q_bias_Pitch
term.str(string("get_q_bias_Pitch "))
term.str (fp.FloatToString(r))
term.str(string(" "))

setpos (0,b++)
r := imu.get_rate_Pitch
term.str(string("get_rate_Pitch "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_angle_Roll
term.str(string("get_angle_Roll "))
term.str (fp.FloatToString(r))
term.str(string(" "))

setpos (0,b++)
r := imu.get_q_bias_Roll
term.str(string("get_q_bias_Roll "))
term.str (fp.FloatToString(r))
term.str(string(" "))

setpos (0,b++)
r := imu.get_rate_Roll
term.str(string("get_rate_Roll "))
term.str (fp.FloatToString(r))
term.str(string(" "))

setpos (0,b++)
r := imu.get_y_rate
term.str(string("get_y_rate "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_x_rate
term.str(string("get_x_rate "))
term.str (fp.FloatToString(r))
term.str(string(" "))

setpos (0,b++)
r := imu.get_y_axis
term.str(string("get_y_axis "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_z_axis
term.str(string("get_z_axis "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_x_axis
term.str(string("get_x_axis "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_a2tan_angle_Pitch
term.str(string("a2tan_angle_Pitch "))
term.str (fp.FloatToString(r))
term.str(string(" "))
setpos (0,b++)
r := imu.get_a2tan_angle_Roll
term.str(string("a2tan_angle_Roll "))
term.str (fp.FloatToString(r))
term.str(string(" "))
waitcnt(clkfreq/10 + cnt)
PRI setpos(px, py)
term.out(10)
term.out(px)
term.out(11)
term.out(py)