clockwise for a random value, then rotate counter-clockwise for the same amount autonomously?

How do I make a DC motor rotate clockwise for a random value, then rotate counter-clockwise for the same amount autonomously?

Ask QuestionAsked yesterdayActive todayViewed 65 times01

For my project I need to build a repeatable vehicle without using any programmable devices (eg: Arduino, microcontrollers etc) After activation, the vehicle needs to move straight towards a wall which is a random distance away, make contact with the wall, and come back as close as possible to the starting point. I have decided to use a DPDT to reverse the motor but I still can’t figure out how to make the vehicle stop at the starting point after returning from the wall.relaydc-motormechanicaldpdtgearShareEditFollowFlagasked yesterdayrainskits911 bronze badge New contributor

  • 1So you actually need a way to keep track of time from the beginning to the wall, and use the same time to let the motors running the opposite direction? – Christianidis Vasileios yesterday
  • 1How much Heath-Robinson mechanical engineering are you willing to do? What’s the maximum distance? – pjc50 23 hours ago
  • Ah, let me see. You need at least the following hardware: (1) A stop watch which consists of the following: (a) a 1Hz astable (eg 555) , (b) a binary counter (eg 74LV393). (c) A micro switch which can stop the binary counter. With this stop watch, you can count the number of seconds that the car has used to hit the wall. Please let me know if this part meets your assignment requirement. 🙂 – tlfong01 23 hours ago    
  • You can obviously use an encoder of some kind (there are many such.) You can also use sensorless approaches (measuring current.) I’d recommend doing a google search on “sensorless methods PWM motor resolution” etc. I haven’t read them, but a quick look finds “Review of Sensorless Methods for Brushless DC” and “A Position-and-Velocity Sensorless Control for Brushless DC Motors Using an Adaptive Sliding Mode Observer” as a couple of likely things to look at. I’m actually finding dozens of candidates that avoid the use of an encoder for this. Study up! – jonk 22 hours ago
  • My earlier suggestion is to use stop watch to time forward journey and use the same time for the return journey. Another approach is to measure the distance traveled. There are many ways to measure the distance traveled, including using cheap toy Hall effect and optical rotary sensors. It is easy to count the number revolutions of the motor shaft. An example is the following: / to continue, … – tlfong01 22 hours ago   
  • Optical (Transmit) Rotary Encoder Kit For Arduino (20 optical slots per motor shaft revolution)- US$1.29 nl.aliexpress.com/item/… – tlfong01 22 hours ago    

Add a comment

5 Answers


Build an odometer.

You’ll need the slotted disc and opto-sensor arrangement that’s used by old-style computer mice with rotating ball-and-roller sensors. This produces pulses as the wheel rotates.

That pulse train can be sent to a counter. Have the counter run “up” when going forwards and “down” when going backwards. You will need to chain them to get enough counts to measure enough distance accurately.

When going backwards, the point at which the counter flips over from 0000 to 1111 is the point at which it’s travelled the same distance as it did when going forwards. At this point, stop.ShareEditFollowFlaganswered 23 hours agopjc5042.6k44 gold badges5656 silver badges113113 bronze badgesAdd a comment1

you could use a reduction gear that trips a limit switch.

You could use a reversable counter to count shaft revolutions, or seconds.

You could time current into and out-of a capacitor.

You could store the measurement on a piece of string, or a microcasette that is spooled and unspooled.ShareEditFollowFlaganswered 23 hours agoJasen21.6k11 gold badge2424 silver badges4343 bronze badges

  • I really like the casette one: mechanically couple it to the drive shaft, and use the plastic lead-in to determine where the end is. – pjc50 21 hours ago

Add a comment1

Run two binary counters (eg CD4040) one for counting shaft rotations in the forwards direction and the other counting the reverse direction.

Connect the outputs together using 1K resistors.

measure the supply current to the pair of counters when it’s low (less than 1mA) they both have the same value so that’s when you stop the motor.ShareEditFollowFlaganswered 11 hours agoJasen21.6k11 gold badge2424 silver badges4343 bronze badgesAdd a comment1

That would be possible, using electromagnetic relays, with limit switches actuated at either end.

Here’s a similar application.

Reversing polarity automaticallyShareEditFollowFlaganswered 21 hours agovu2nan5,95211 gold badge55 silver badges2525 bronze badgesAdd a comment1

An electro-mechanical solution might be good. You could turn a screw one direction as you drive towards the wall and drive it the other direction as you drive in reverse. When it gets back to the initial position it can press a button.

If connecting up to the car’s drive is complicated then just use a separate motor to drive the timer.ShareEditFollowFlaganswered 20 hours agoTransistor133k1010 gold badges137137 silver badges305305 bronze badgesAdd a comment

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.