# Rotate shaft 4 times clock-wise and then 4 times anti-clock-wise

#### nimi79

Joined May 25, 2013
13
I will be using 300 rpm DC motor to drive a shaft at 60 rpm. For this I will use a pair of spur gears with ratio 1:5 i.e. smaller one will be attached to motor and larger one will be attached to shaft (for speed reduction).

The electro-mechanical arrangement I am looking for will have following requirements:
1. There will be a push button, when pressed will rotate shaft clock-wise (actually motor will rotate anti-clock-wise; pair of spur gears will change the direction of shaft).
2. After four clock-wise rotations of shaft, motor should reverse the direction and shaft should rotate anti-clock-wise.
3. After four anti-clock-wise rotations of shaft, motor should stop.

As per my understanding, for counting purpose, we can use IC 4017 decade counter. The input pulse to trigger the decade counter will come from slot-type opto-interrupter (opto-sensor). For reversing the direction, we can use H-bridge or relay.

An opaque disk will be attached to shaft and will have small hole at one place; during rotation when hole will come between opto-interrupter slot, the infra-red light sent from infrared LED will be sensed by phototransistor and we can use this signal to trigger decade counter (to increment it or to reset it). After four clock-wise rotations, we can reset the decade counter and can use it again for counting anti-clock-wise rotations, and will also reverse the direction of motor too.

I am not from electronics background and looking for circuit design to achieve above mentioned requirement. I will be really thankful to any help you experts can extend. Thanking you all in advance.

#### MrChips

Joined Oct 2, 2009
21,148
So you need to count 20 clock pulses and then toggle a flip flop.
I would use a decade counter whose output is fed to a 4-bit binary counter.
The first bit (LSB) of the binary counter counts 20 clock pulses. The second bit is your toggle (reversing) bit.

#### LDC3

Joined Apr 27, 2013
924
I thought he was going to put the sensor on the slower shaft, so he would only need to count the 4 revolutions. Actually, it might be 5 since the hole needs to pass the sensor before it reverses or stops.

#### THE_RB

Joined Feb 11, 2008
5,438
I think you might need to look at a different solution.

Counting 4 rotations before reversing opens you up to the problem of loss of sync, which would be a disaster! Any edge glitch that occurs would cause a miscount and trash the position, and possibly trash the machine.

If this is for a reversing mechanism it will be a lot more reliable if you use two sensors, one at each end of the final travel (whatever the final cog drives).

#### LDC3

Joined Apr 27, 2013
924
If he makes it a slot, instead of a hole, this will decrease the possibility that it does not get counted. Also, the motor would reverse or stop while the sensor is still active.

#### nimi79

Joined May 25, 2013
13
Thank you for your post. You got it right, the opto-sensor will be on slower shaft, and to count 4 rotations (either clock-wise or anti-clock-wise), the hole should pass 5 times under the slot of opto-sensor. First passing of hole under the slot of opto-sensor will register the start of first rotation, second passing of hole will register the finish of first rotation or start of second rotation, and so on, and fifth passing of hole will eventually register the end of fourth rotation.

The load on shaft and other mechanical arrangement is such that the shaft will come to halt within half-rotation and also within one second, if we cut-off the power supply. So, we can actually rely on that count 5 (for reversing or for stopping motor).

If shaft is moving clock-wise, then at the end of fourth rotation we will reverse the direction of DC motor. Instead of immediately reversing the direction of motor, which can actully heat it up, I can put a one second delay and wait for motor to halt, and then can signal the motor to reverse the direction.

Now, if the shaft is moving anti-clock-wise, then at the end of fourth rotation we will stop the motor.

With all these requirements, I am looking for rough circuit design as I am not from electronics background.

#### MrChips

Joined Oct 2, 2009
21,148
Can you use limit switches or sensors instead to detect the ends of the linear travel?
Or can you add another gear so that you don't have to count pulses?

#### nimi79

Joined May 25, 2013
13
Can you use limit switches or sensors instead to detect the ends of the linear travel?
Or can you add another gear so that you don't have to count pulses?
MrChips, thank you for your comment. Due to cost limitation I can not use limit switches and also there is no linear movement involved in mechanical arrangement I have.

I am not able to grasp how another gear can help me? Also, there is a space constraint due to which I can't add another mechanical component.

#### nimi79

Joined May 25, 2013
13
If he makes it a slot, instead of a hole, this will decrease the possibility that it does not get counted. Also, the motor would reverse or stop while the sensor is still active.
Thank you for your post. You got it right, the opto-sensor will be on slower shaft, and to count 4 rotations (either clock-wise or anti-clock-wise), the hole should pass 5 times under the slot of opto-sensor. First passing of hole under the slot of opto-sensor will register the start of first rotation, second passing of hole will register the finish of first rotation or start of second rotation, and so on, and fifth passing of hole will eventually register the end of fourth rotation.

The load on shaft and other mechanical arrangement is such that the shaft will come to halt within half-rotation and also within one second, if we cut-off the power supply. So, we can actually rely on that count 5 (for reversing or for stopping motor).

If shaft is moving clock-wise, then at the end of fourth rotation we will reverse the direction of DC motor. Instead of immediately reversing the direction of motor, which can actully heat it up, I can put a one second delay and wait for motor to halt, and then can signal the motor to reverse the direction.

Now, if the shaft is moving anti-clock-wise, then at the end of fourth rotation we will stop the motor.

With all these requirements, I am looking for rough circuit design as I am not from electronics background.

#### MrChips

Joined Oct 2, 2009
21,148
No need to repeat a post. That would be considered rude.

#### THE_RB

Joined Feb 11, 2008
5,438
It will still be a bad design. Any edge glitch that occurs for any reason will cause a mis-count, and the machine will be out of position permanently after that.

If it is something like a rock tumbler, that needs to rotate ROUGHLY 4 revs forward then 4 revs back, it will not matter if sometimes it turns 5 revs or 3.

But if this needs to ALWAYS rotate exactly 4 revs then counting switch events is a very poor way to do it.

What exactly is this machine doing? Why does it need 4 revs each direction?

#### nimi79

Joined May 25, 2013
13
It will still be a bad design. Any edge glitch that occurs for any reason will cause a mis-count, and the machine will be out of position permanently after that.

If it is something like a rock tumbler, that needs to rotate ROUGHLY 4 revs forward then 4 revs back, it will not matter if sometimes it turns 5 revs or 3.

But if this needs to ALWAYS rotate exactly 4 revs then counting switch events is a very poor way to do it.

What exactly is this machine doing? Why does it need 4 revs each direction?
I totally agree with you. There will always be a small probability for mis-count due to edge glitch. Will it be a good idea to have redundant counting mechanism (additional opto-sensor and additional decade-counter)? I can then use the OR logic to get the desired result. It will bring down the probability of mis-count drastically down, though not zero.

Actually I am converting this rotational motion to linear motion. Both ends of the linear motion range are quite fixed (with small linear buffer) and object attached to this linear motion must touch both ends.

I want to keep the cost very less, that is why I am relying on opto-sensor and decade-counter. If you can suggest me some other option that is not costly, I can definitely think on that.

#### LDC3

Joined Apr 27, 2013
924
Limit switches are not expensive, you could probably get 2 for under $5. The only problem is setting them to stop the motor in the correct place. You stated earlier that the shaft will continue to rotate after the power is disconnected. You will need to determine where the power needs to be disconnected in your linear motion so it stops at the end. Another advantage to the limit switch is that it prevents the motor from turning in one direction. Thread Starter #### nimi79 Joined May 25, 2013 13 Limit switches are not expensive, you could probably get 2 for under$5. The only problem is setting them to stop the motor in the correct place. You stated earlier that the shaft will continue to rotate after the power is disconnected. You will need to determine where the power needs to be disconnected in your linear motion so it stops at the end. Another advantage to the limit switch is that it prevents the motor from turning in one direction.
Dear LDC3, I google'd and found variety of limit switches with varying prices. In my case since moment of inertia attached with shaft is very low (0.01 N.m) and I know where I need to stop the motion, what kind of limit switch is suitable, can you suggest me? Probably give me few links that I can go thru for prices. In the mean time I will too look for limit switches options.

#### nimi79

Joined May 25, 2013
13
Thank you everyone for guiding me till this point. I have further consolidated my requirements as per your inputs.

For me, the main objective to have motor rotate 4 times clock-wise and then 4 times anti-clock-wise is that, the attached sledge via some mechanical arrangement needs to move back-and-forth within some fixed range (you can assume between point P1 and point P2). This is almost similar to how sliding automated door moves in malls or shops.

As suggested by many esteemed members, instead of relying on opto-sensors for count of rotations (due to issue of mis-count by any edge-glitch), I am going with a pair of miniature snap-action switches (SW1 and SW2; can they be SPST or they should be only SPDT?) and mount them at point P1 and point P2.

I have drawn the partial schematic diagram (5 stages) to sense one-way movement. I am using SR-latches to store the switch position (open/close) because of "contact bounce" (http://en.wikipedia.org/wiki/Switch). Once the switch is closed due to contact of sledge-bumper and actuating-lever, no matter how many times "contact bounce" happens, the value stored in the latch will not change.

Due to operational speed difference of mechanical motion (contact of sledge-bumper and actuating-lever(SW2)) and RS-latch (resetting of LTCH2(Q)), I have put one-second delay before feeding back OR1 output to reset pins of both LTCH1 and LTCH2 respectively, otherwise at stage 4, LTCH2 can have both R and S value as 1. Although I have assed that adding one-second delay will not add any value, because it will really not matter that what is the value of LTCH2(Q) at stage 5. Assume that there is NO one-second delay for feedback signal that is resetting LTCH1 and LTCH2. LTCH1 will reset without any issue. But both LTCH2(S) and LTCH2(R) will be 1, and due to race condition the final state of LTCH2(Q) can be either 0 or 1. At stage 5, if LTCH2(Q) is 0, then, when sledge will start moving in opposite direction, LTCH2(Q) will be set again as soon as SW2 is closed. And if at stage 5, LTCH2(Q) is 1, it will remain 1 anyway (because when sledge will start moving in opposite direction, it will anyway set again as soon as SW2 is closed). With reason explained in this paragraph, can we remove one-second delay?

I am working on remaining logic:
1. Motor will start using push-button.
2. Signal to stop motor should be sent at stage 4 while moving in one direction and when motor is stopped at stage 5, some signal(?) should also reverse the direction of motor rotation. By the way motor will stop rotating within 1 second (between stage 4 and stage 5).
3. Now, when sledge will move in other direction, it should signal motor to stop when reaching stage 2, so when state 1 is achieved, motor is completely stopped.

As this is a logic circuit only, it will be a great help if someone can convert this into real-electronic circuit (with power supply, ground, all the resistors, etc.).

#### Attachments

• 148 KB Views: 51

#### nimi79

Joined May 25, 2013
13
Friends, I think I have got the right pointer (http://www.robotroom.com/Back-And-Forth.html). Probably I can tweak this circuit for my requirement. I was thinking way complex ;-)

I am really thankful for all the generous inputs you all have offered me.

#### THE_RB

Joined Feb 11, 2008
5,438
That last circuit looks like a "reversing relay" but instead of a relay he has used a mosfet bridge IC.

You should have a google for "reversing relay with two switches" or something like that.

#### nimi79

Joined May 25, 2013
13
That last circuit looks like a "reversing relay" but instead of a relay he has used a mosfet bridge IC.

You should have a google for "reversing relay with two switches" or something like that.
Yes, the IC used in the project Back-and-Forth Robot is IXDI604. It is a dual inverting driver with following features:

• 4A Peak Source/Sink Drive Current
• Wide Operating Voltage Range: 4.5V to 35V
• -40°C to +125°C Extended Operating Temperature Range
• Logic Input Withstands Negative Swing of up to 5V
• Matched Rise and Fall Times
• Low Propagation Delay Time
• Low, 10μA Supply Current
• Low Output Impedance
and following applications:

• Efficient Power MOSFET and IGBT Switching
• Switch Mode Power Supplies
• Motor Controls
• DC to DC Converters
• Class-D Switching Amplifiers
• Pulse Transformer Driver

I think this IC can drive my motor, as current drawn at peak load will be much less than 4A.