Shop OBEX P1 Docs P2 Docs Learn Events
bs2 code help for Ping actuated servo — Parallax Forums

bs2 code help for Ping actuated servo

revrev Posts: 27
edited 2011-05-10 14:06 in BASIC Stamp
Hello all-

I am looking for some pointers for how to program a BS2 for the following application:
I would like to give the appearance of a screw going into a wall based on how close the viewer is to it using a continuous rotation servo and a ping sensor. I have the mechanics figured out, as well as the basic theory behind how both the servo and the sensor work with the basic stamp. I have run various basic programs independently for each, calibrated the servo, and made a basic 'theremin' using ping output to control pitch. I need to turn the output of the ping sensor into something the servo can understand, ie. when the object (viewer) is 10 feet away from the screw, the screw would stick out from the wall a nominal distance. As the viewer gets closer to the screw, it appears to turn itself into the wall, once the viewer is a foot away the screw is flush to the wall, as the viewer backs away the screw dials back out.

In this scenario I imagine there would be a linear relationship between the rate of change of output of the ping sensor and the rate of change of the velocity of the servo.

Perhaps a simpler way to do it would be to assign distances to certain radial positions, though it seems to me the motion would not be as smooth.

Any and all suggestions / example code / pointers are very much appreciated. Thanks!

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-05-10 14:06
    Continuous rotation servos have 3 rotation states not including rotational speed; idle, clockwise, and counter clockwise. You need an encoder to relate PING))) distance to the continuous servo's angular position and number of turns.

    Otherwise consider a standard servo and gearing.
Sign In or Register to comment.