Shop OBEX P1 Docs P2 Docs Learn Events
Help With Accelerometer Servo Control — Parallax Forums

Help With Accelerometer Servo Control

RubrChickenRubrChicken Posts: 39
edited 2009-06-26 13:14 in Propeller 1
I'm working on getting my Memsic2125 accelerometer to control servos. I have it all soldered onto a proto board, and I'm wondering if it will work with 3.3V because this says it is for 5V.

Now onto my problem (which may be solved by changing the voltage!):

I'm using the MXD2125 Simple object contained in the memsic demo from the OBEX:
obex.parallax.com/objects/235/
I can control my servos fine(IE its not a problem with the servos or connections), but when I start attempting to use the accelerometer, the servo goes "limp". I'm using this:

SERVO.Set(1,(((accel.x)/2)+1.5)*1000)



to control the servo, but it doesn't work. It doesn't help that I can't get any data back from the prop because : 1)BST's serial terminal doesn't work for me (and I have no idea why) 2) it's on a protoboard (so no VGA or TV) 3) I don't want/don't have time to desolder the accelerometer to use in a demo board.
I assumed accel.x was in gs, from 1 to -1. Dividing by 2 (-.5 to .5) then adding 1.5 (1 to 2) then multiplying by 1000 (1000 to 2000) should give me values that the servo will take, but it goes limp anyways.

Thanks for the help!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-26 04:26
    The division by 2 is integer division, not floating point. The addition of 1.5 doesn't do what you expect because it's integer addition of the integer representing the floating point value, not floating point addition. Try:

    SERVO.Set(1,accel.x*500+1500)

    I don't think the above will work because the accel.x value is likely something other than -1 to +1. You'll need to run the demo and look at the values produced or go through the datasheet or both, then change the factors in the above statement to match.

    Post Edited (Mike Green) : 6/26/2009 4:35:37 AM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-06-26 12:06
    Hello RubrChicken,

    how about using the PST instead of the BST ?

    If you alreday mean the PST: without debugging by ANY display at all you will have a hard and really long job until your project is finished
    I guess without debugging a problem will take 5 days to solve it
    getting debugging to work by
    - soldering some resistors on your protoboard to get a TV-signal and a cynch-connector will take half an hour

    - soldering 8 resistors on your protoboard to get a VGA-signal and a VGA-plug will take one hour

    - describing your problem IN DETAIL what you have tried with PST and what the result is until you get an answer wil take one day

    after debug works half a day and your program is running

    so get any kind of kind of debugging to work !

    best regards

    Stefan
  • sylvie369sylvie369 Posts: 1,622
    edited 2009-06-26 13:14
    Why not just attach a serial LCD to one of the servo headers and use that for debugging? Use Full_Duplex_Serial to send the data from the accelerometer demo program to LCD instead of TV, and check your assumptions about what the object outputs for X and Y acceleration.

    I agree that adding a way of debugging - of displaying what's really happening - will make your task a lot easier. Assuming that you already have a serial LCD, this is a way that doesn't require adding any hardware (well, also assuming you have your servo headers wired up properly: you know that you need to connect their I/O pins to Prop I/O pins through a resistor, right?).
Sign In or Register to comment.