Propeller 5DOF IMU and Sparkfun LCD
I am trying to make a simple routine to get the roll and pitch from the Sparkfun 5DOF IMU and display it on a Sparkfun serial LCD. The values that are displaying on the LCD are as follows:
roll: -10561XXXX
pitch: -106649XXXX
The values change when I tilt the board but nothing like what i'd expect.
Any help would be much appreciated.
Thanks,
Steven
roll: -10561XXXX
pitch: -106649XXXX
The values change when I tilt the board but nothing like what i'd expect.
Any help would be much appreciated.
Thanks,
Steven
Comments
1. Mainloop calling mainloop - you shouldnt do this, the calling stack will grow without ever getting smalling, use a repeat rather than calling mainloop within mainloop
2. the call to floatstring returns a pointer to a string, you are then printing it as a number so you are printing the address of the string rather than printing the string.
(I have set everything up according to the "IMU" object)
Am I correct about converting the floating point to a string before printing it?
Also, do I need to start the MCP3208 in the "ini" section or does the IMU object to that? And, what does the "mode" setting for the MCP3208 do?
I'm pretty new at this...
IMU calls MCP.start go that should be fine.
Thanks,
Steven
The Mode you pass into the MCP3208 is for setting the pins you will be listening to. The MCP3208 is an 8 port ADC. The Mode is an 8bit value, with each bit representing a port to enable.
Bill
Lets say I wanted to compare the string location "roll" in the following line:
roll := IMU.get_angle_Roll
if roll >= uplimit
rollservo := rollservo + 1
if roll <= lowlimit
rollservo := rollservo - 1
I know that there is an issue because roll is the string location. How do I make it a decimal so that I can use it in formulas?
Thanks,
Steven
if roll >= uplimit will not work.
You could either use float32.spin and FCmp to compare
or convert to integer to compare - say multiply by 10 then round to integer and compare using float32 (FMul and FRound)