Shop OBEX P1 Docs P2 Docs Learn Events
Controlling a DC motor's position using a ping sensor. HELP!!! — Parallax Forums

Controlling a DC motor's position using a ping sensor. HELP!!!

MikeeMikee Posts: 1
edited 2008-05-05 20:31 in BASIC Stamp
HElp me please!
I have the sensor mounted on a servo which is mounted separately on the table. The sensor agitates back and forth, and when it notices something the DC motor spins the robot's body, to face the same direction the sensor is facing. Im having trouble with the DC motor, not facing the direction the sensor is facing.
I have coded the ping sensor and it works great. Its attached to breadboard where the DC motor is. I need to make the DC motor turn and face the same position the sensor is facing.
I have this coding for the DC motor but that doesnt make it face the same direction the sensor is facing. PLease Help me!

HIGH 14
PAUSE 380
LOW 13
PAUSE 1000
HIGH 13
PAUSE 380
LOW 13
PAUSE 2000
HIGH 14
PAUSE 380
LOW 14
HIGH 13
PAUSE 350
LOW 13

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-05 19:52
    You can't reliably reposition a DC motor to a particular direction. There are too many variables (friction, variable load, decreasing supply voltage, etc.) You need some kind of position feedback. A servo has a position encoder (usually a variable resistor). Even a stepper motor (which has excellent repositioning capability) needs some kind of absolute position calibration at least when first powered up (usually some kind of "end of travel" switch). If the DC motor is geared down enough, you can use on-time as a rough indicator of final position, but you'd need to recalibrate periodically.
  • LarryLarry Posts: 212
    edited 2008-05-05 20:31
    You can just "bump" the motor right or left a little and then test again. with enough "bumps" you can line up the robot with the object fairly quickly. I have a small six wheel robot with a CMUcam and differential motor drive I did this with and it's pretty successful at hitting a cone.
Sign In or Register to comment.