Shop OBEX P1 Docs P2 Docs Learn Events
Tilt Sensor Project — Parallax Forums

Tilt Sensor Project

cva6633cva6633 Posts: 2
edited 2007-02-22 19:32 in BASIC Stamp
I know that the bs2 can control servos and can read input from a tilt sensor but is it fast enough to do both.

I saw these flight simulator gauges and after reading about them i found out they are just a servo(s). Do you think the bs2 would be fast enough to read the input and move 2 servos without being to choppy?

www.simkits.com/product.php?prodid=207

Thanks

Comments

  • fzrobotfzrobot Posts: 7
    edited 2007-02-21 18:47
    What type of tilt sensor you plan on using. I have used the H48C 3-axis accelerometer (available at PARALLAX's website) for balancing a two-wheeled robot (i.e., two servos).

    Although, the project is still unstable (work in progress) I can manage to write a fair amount of code and get execution time to be just slightly above 20 ms. If you are using Parallax's servos, you need the program to execute (the downtime of the pulse) around this frequency (20 ms = 50 Hz) for the servos to behave accordingly.

    Please note, that these 20 ms account for the program being executed (and thus, the servos receive a low pulse), but do not include the time when the PULSOUT commands are being executed (when the servos are receiving the high pulse, whose width control their rotation).

    In other words:

    Main:
    Program code (roughly 20 ms)

    PULSOUT servo1_pin, 750
    PULSOUT servo2_pin, 750
    GOTO Main

    These instructions of course will let you control two servos (in this particular code they would be "centered").

    Hope this helps,

    -Cisco
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2007-02-21 22:10
    You might be interested in·the Boe-Bot robot and Memsic Dual-Axis Accelerometer project posted in the thread below.· It includes a video clip and fully-explained sample code for inspiration:

    http://forums.parallax.com/showthread.php?p=522967

    There is a Stamps in Class text by the same author that has lots of accelerometer applications and coding techniques as well:

    http://www.parallax.com/detail.asp?product_id=28029

    -Stephanie Lindsay

    Editor, Parallax Inc.
  • cva6633cva6633 Posts: 2
    edited 2007-02-21 23:42
    Thanks for the advice.

    I was planning on using the 2 axis accelerometer because the gauge only displays 2 axis. I guess i would have to include a delay or the gauge will bounce around with every bump, not just a change of tilt.

    Are there any sensors that wont measure g forces but just the angle of tilt, or at least be less affected by bumps and vibrations?

    Thanks
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2007-02-22 19:32
    You might be able to filter out both bumps and vibrations with programming.·

    For vibrations that result in very small but constant changes in readings, applying hysteresis in your program would prevent your output from constantly adjusting while the input values hover around a target value.·(There is an accelerometer hysteresis example in Smart Sensors Chapter 6, Activity #7)

    Alternatively, simply by scaling the input to a smaller range of values before using them to control the output can remove some of the jiggle. Take a look at·Smart Sensors Figure 3-11.··Here the accelerometer has an input range of 1250 units, but it is being scaled down to a range of 256 units.· You can set up scaling to the range of units that is practical for your·servo.

    For dealing with accidental bumps and jolts, I think you could capitalize on the fact that such events cause a change in g-force of·a very short duration.· If your output action is based on not just one input value, but from taking a series of values and averaging them, perhaps·discarding the outliers first, you can filter out those quick bumps.· Smart Sensors does have an example with averaging measurements (with the Compass module) but it doesn't discard outliers.· Sorry I can't point you to an example of such code off the top of my head, but·it is ringing a bell and I'm hoping someone else here can provide one.· I don't write much code myself, mostly I read, format and spell-check it. smile.gif

    -Stephanie Lindsay

    Editor, Parallax Inc.
Sign In or Register to comment.