Shop OBEX P1 Docs P2 Docs Learn Events
Propeller 5DOF IMU and Sparkfun LCD — Parallax Forums

Propeller 5DOF IMU and Sparkfun LCD

grayeyephotograyeyephoto Posts: 5
edited 2010-09-05 21:29 in Propeller 1
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

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2010-09-04 16:24
    There are a couple of issues
    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.
  • grayeyephotograyeyephoto Posts: 5
    edited 2010-09-04 16:35
    Ok. The repeat thing I can do easily but the FloatString I have no idea.

    (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...
  • TimmooreTimmoore Posts: 1,031
    edited 2010-09-04 16:55
    use LCD.str to print a string.
    IMU calls MCP.start go that should be fine.
  • grayeyephotograyeyephoto Posts: 5
    edited 2010-09-04 16:57
    I have the VDD and the 3.3V lines tied together. Is there a problem with that?

    Thanks,
    Steven
  • wjsteelewjsteele Posts: 697
    edited 2010-09-04 19:02
    There was an object in the OBEX for hooking the Sparkfun 5DOF up to the MCP3208. It had the schematic in it. Tying everything to 3.3v should be fine.

    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
  • grayeyephotograyeyephoto Posts: 5
    edited 2010-09-05 09:52
    Awesome. Everything works perfectly. I now have a very similar problem that should be very simple. I haven't been able to find a solution on the forums....

    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?
  • grayeyephotograyeyephoto Posts: 5
    edited 2010-09-05 20:40
    Ok. I have attached the code I have been playing with. Basically my end goal is to have a simple program that move a servo one direction if the IMU reads above .5 deg and the other way if it is below -.5 deg. The only problem is that I can't seem to use the numbers returned from the IMU program as regular variables. Are they string locations? If so, how do I use the numbers in those locations?

    Thanks,
    Steven
  • TimmooreTimmoore Posts: 1,031
    edited 2010-09-05 21:29
    roll and uplimit are floats, spin can't compare floats so the
    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)
Sign In or Register to comment.