Author Topic: Simple circuit for spinning a motor, pausing, then spinning the other way  (Read 4588 times)

0 Members and 1 Guest are viewing this topic.

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Hi everyone,

I'm an electronics hobbyist (beginner level) who likes to dabble with building different simple circuits (mostly solar).

Since I do not have the expertise to design my own circuit, and google did not help, I'd pose the question to the highly knowledgeable members of this forum:

I'm looking to build a very simple analog circuit (made of vanilla components, so no specialized chips) that spins a small (3-4V) geared motor one direction, stops for about 15 minutes then spins the other way, stops for 15 minutes and so on. The motor needs to stop in a certain position therefore a limit switch could be used. Preferably, the circuit would be run off a Li-Ion battery or directly from a 5V batter bank. I looked into a H-bridge to control the direction of the motor. The circuit doesn't need to be very accurate in terms of time, and ideally I'd be able to adjust the time with a potentiometer.

This circuit would be used to periodically rotate a small 10 cm tall decorative hourglass once the sand has run out.

Thanks!
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
An H-bridge needs at least 4 "power" transistors and two smaller transistors to drive them. What's wrong with using something like an A4950? They can be bought cheap on breakout boards.

You can put the end switches directly in series with the motor. That way the motor stops when one of the switches is hit.
But the motor has to be able to run back, even when it's leaning against a switch, so bridge each of the switches with a diode. The diode has to be able to pass the full motor current.

For a 15 minute delay something like a NE555 will be difficult (maybe you can go that far with the CMOS version, but it would require high value resistors, and low leakage electrolytic capacitors. 15 minutes = 900 seconds, so 1Mega Ohm and 1000uF may get you there.

Something like a CD4060 is much better for longer times. It can easily reach a day or two.

But there is a potential problem here. You may damage your motor driver transistors if you put switches between the transistors and the motor. Putting a TVS over the motor may help here




 

Offline SmallCog

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: au
Good excuse to play with a 555 timer for the interval timing. There’s a bunch of other options but if you’ve not experimented with a 555 before then now’s as good a time as any.

If you’ve not played with 74 series logic then chuck some of that in there to toggle between directions with the clock pulses from the 555

OR a few lines of code in an arduino

 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
Instead of an H-bridge you can also use a DPDT relay.

So a motor, two end switches, two diodes, a relay, and that just leaves the power supply and timing.
Having a relay on for 50% of the time will drain the battery though. Maybe using two relays or a latching relay is a better option.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Any long-period discrete analog time-keeping function should be avoided at nearly any cost.   Your 15 minute period implies either the baroque complexity of a digital divider chain built out of discrete components i.e. Eccles Jordan bistable (flip-flop) circuits with steering diodes, to get the oscillator frequency up to a more reasonable range, or a RC time constant of approx. 1000 (exact value depends on voltage thresholds.   The math says a 1 Meg resistor and a 1000 uF capacitor would do the job, but the math doesn't allow for leakage currents.   With a 5v supply, on average the resistor is only going to be passing a couple of uA, but an electrolytic capacitor of that value is likely to be specified to have a max. leakage current of a few tens of uA, so unless you are very lucky and pick a capacitor that's at the extreme low leakage end of the bell-curve, the leakage current will dominate, leading to grossly incorrect timing, or even total failure to reach the end of the timing period.

Also analog timing circuits aren't known for their low power consumption.  The quiescent current drawn from the battery by the timing circuit is likely to be greater than the average motor current as it has such a low duty cycle.

Nowadays, even with the supply chain issues, any sane engineer would say "Use a MCU."   Even the lowliest 8 pin PIC or AVR, or one of  Padauk's sub $0.04 MCUs can do the job with code space and pins to spare.  It comes down to availability and cost of development tools.  If you don't already have any sort of MCU experience and tools, €5.49 will get you a Digispark Rev 3 clone with an ATtiny85 MCU on it, self-programmable over USB  using the Arduino IDE. 

Back in the day, before cheap easily reprogrammable MCUs, this would have been a job for 4000 series CMOS logic.  The chip of choice would be the CD4060 (or one of its many second source equivalents) which has an on-chip oscillator suitable for RC timing, crystals and resonators + a 14 stage binary divider chain.  To toggle the final output with a 30 minute period, (so it can directly be used to control the H-bridge for a motor wired with diode across its limit switches so it stops at each limit till the drive voltage to it is reversed), would require its oscillator to run at fractionally over 9 Hz, entirely practical for a RC timing circuit with reasonable resistor and capacitor values.   Nowadays one might choose the 74HC4060, which is better for 5V and lower supply voltages.

Go back 50 years or so before RCA added the CD4060 to their new 4000 series CMOS product range (launched in 1968), and there was a short window of probably less than a decade when a fairly large board full of transistor flip-flops and logic would have been the preferred solution.  Before that, a chain of Decatron counters dividing down the mains line frequency would have been the preferred electronic implementation, but in nearly all cases an electromechanical solution of a high reduction ratio synchronous gearmotor driving a cam operated switch would have been preferred, because it was far far smaller, cheaper, lower power and more reliable than a chassis full of 30 Decatrons!
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
I've looked at CD4060 and might be the chip i need for timing: https://www.build-electronic-circuits.com/4000-series-integrated-circuits/ic-4060/
However, I do not know how to integrate the chip into the H-bridge circuit with diodes.
Would you be able to draw a quick and dirty schematic?

EDIT: I have found CD4040 in my parts bin, which apparently is a CMOS 12-Stage Ripple-Carry Binary Counter/Divider, very similar to the CD4060 which is a CMOS 14-Stage Ripple-Carry Binary Counter/Divider and Oscillator
« Last Edit: May 30, 2022, 12:11:19 pm by vranghel »
 

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 2584
  • Country: gb
The CD4040 requires a clock to make it work,the cd4060 has a built in "clock" so only needs a couple of resistors and a capacitor added to get it running.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
The CD4040 requires a clock to make it work,the cd4060 has a built in "clock" so only needs a couple of resistors and a capacitor added to get it running.

Oh, I see now;
I have CD4017, which, according to the datasheet https://www.ti.com/lit/ds/symlink/cd4017b.pdf?ts=1653912905120&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FCD4017B%253FkeyMatch%253DCD4017, I think also has a clock?
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3039
  • Country: us
Use the CD4060 to provide the 15 minute clock signal to the 4017.

This page describes how to get long timing periods out of the 4060:

https://www.gadgetronicx.com/how-to-build-24-hours-timer-circuit-cd4060/
« Last Edit: May 30, 2022, 12:34:08 pm by ledtester »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Like the CD4040, the CD4017 requires an external clock.  It also only divides by 10, useless for the timing part of your application.  However if clocked once every three minutes, it could be useful to drive a discrete complimentary MOSFET H-bridge from its '0' and '5' decoded outputs, without risk of shoot-through;)

How to drive an H-bridge from a CD4060 depends on what control inputs the H-bridge has, and for your application, depends on how you implement the limit switches.    If you use logic level limit switches its considerably more complex than if they are beefy enough to carry the motor current.
 Read https://www.eevblog.com/forum/beginners/my-12v-dc-motor-is-not-turning/ starting at reply #18 noting my comments to get an idea of how simply reversing the motor supply can make it run till it stops at the limit switch.  If you've only got ONE limit switch and want the mechanism to do a (nearly) complete rotation, it must be DPST-NC (or DPDT) so electrically it can be wired as-if it was two separate switches.

Tell us about your H-bridge or ask us to help you pick or design one.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3039
  • Country: us
I can imagine that the CD4017 would be useful for implementing the state of the application. It is a flexible way of programming a cycle of up to 10 states.

The OP's application only requires 4 states:

state 0: drive the motor forward
state 1: turn off the motor
state 2: drive the motor backwards
state 3: turn off the motor

Once an H-bridge has been selected we can figure out how to use the outputs of the 4017 to drive the inputs of the H-bridge.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Like the CD4040, the CD4017 requires an external clock.  It also only divides by 10, useless for the timing part of your application.  However if clocked once every three minutes, it could be useful to drive a discrete complimentary MOSFET H-bridge from its '0' and '5' decoded outputs, without risk of shoot-through;)

How to drive an H-bridge from a CD4060 depends on what control inputs the H-bridge has, and for your application, depends on how you implement the limit switches.    If you use logic level limit switches its considerably more complex than if they are beefy enough to carry the motor current.
 Read https://www.eevblog.com/forum/beginners/my-12v-dc-motor-is-not-turning/ starting at reply #18 noting my comments to get an idea of how simply reversing the motor supply can make it run till it stops at the limit switch.  If you've only got ONE limit switch and want the mechanism to do a (nearly) complete rotation, it must be DPST-NC (or DPDT) so electrically it can be wired as-if it was two separate switches.

Tell us about your H-bridge or ask us to help you pick or design one.

Thanks Ian. Seems I have to order a CD4040. I read your comment in the other thread and I think I get the general idea: Wire the NC switch with a diode, so even when the switch is open, the diode allows it to conduct the other way, so it can reverse until it opens the other NC switch.

As for the H bridge, I do not have one in mind, so I'm definitely open to ideas/suggestions, and how to combine the 2 circuits and the switches. The motor running will require low current, most likely under 100mA
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
*NO* order a '4060', not a '4040' e.g CD4060, MC14060, HEF4060, NTE4060 etc. or a 5V logic version of it, e.g. any brand of 74HC4060 or 74HCT4060, because you *WANT* that built in oscillator to keep the circuit simple.

If a running brushed DC motor draws 100mA, odds are its stall current, which it will transiently draw if starting from standstill or reversing will be of the order of 1A.

What junk bin power transistors do you have capable of handling >1A?  N.B. you need 2x PNP + 2x NPN, or 2x PMOS and 2x NMOS.  If using MOSFETs, they must have a min. Vgs threshold voltage <2.5V to ensure you can turn them fully on from only 5V level logic signals.
If the answer is none or not enough, you'll probably be best off buying a H-bridge chip or module.
« Last Edit: May 30, 2022, 01:10:39 pm by Ian.M »
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
*NO* order a '4060', not a '4040' e.g CD4060, MC14060, HEF4060, NTE4060 etc. or a 5V logic version of it, e.g. any brand of 74HC4060 or 74HCT4060, because you *WANT* that built in oscillator to keep the circuit simple.

If a running brushed DC motor draws 100mA, odds are its stall current, which it will transiently draw if starting from standstill or reversing will be of the order of 1A.

Ah sorry, I meant 4060, but wrote it wrong, since I was looking at both datasheets side by side.

I am wondering is there is a way to create an H bridge out of only 2 switches and diodes as seen here: https://en.wikipedia.org/wiki/H-bridge#/media/File:H_bridge_operating.svg
Using the adjustable timer section circuit of the page: https://www.build-electronic-circuits.com/4000-series-integrated-circuits/ic-4060/ might work, but I need the timer to reset itself after each run, so when the motor trips the switch


 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
No.  A H-bridge needs min. four switching elements.  It may also need four diodes to handle the back-EMF from the motor.

You don't need the counter/timer to reset after each run.  Use a MOSFET H-bridge which draws negligible current when ON in either direction, with the motor disconnected, use limit switches that disconnect the motor till its drive is reversed, and let the counter/timer free-run, simply reversing the H-bridge direction once every 15 minutes.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Would 74HC4060 (https://www.ti.com/lit/ds/symlink/sn74hc4060.pdf) work as a drop in replacement for CD4060?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Sure, up to abs. max. 6V supply.   Above that voltage, odds are it would let the magic smoke out!
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Any suggestion of an H bridge circuit to use with 4060?
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de

What junk bin power transistors do you have capable of handling >1A?  N.B. you need 2x PNP + 2x NPN, or 2x PMOS and 2x NMOS.  If using MOSFETs, they must have a min. Vgs threshold voltage <2.5V to ensure you can turn them fully on from only 5V level logic signals.
If the answer is none or not enough, you'll probably be best off buying a H-bridge chip or module.

Since it might be easier, I will order L293D: https://www.ti.com/lit/ds/symlink/l293d.pdf?ts=1653919565123&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FL293D
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
*DON'T* buy a L293D.  Its a bipolar H-bridge and has excessive voltage drop for low voltage use.  See its datasheet section 6.5 Electrical Characteristics.  Voh is typ. 1.4V below Vcc and Vol typ. 1.2V above ground, and you'll loose a bit more in the diodes to permit reversing out of the limit  across your limit switches, leaving you with 2V or less at the motor with 5V Vcc.  Also note its Icc1 and Icc2 supply currents, which IMHO make it unsuitable for a long-duration low power battery powered application.

Discrete complimentary BJTs can be driven hard enough to get the total voltage drop under 1V, so suitable for a 5V motor, but the drive circuit quiescent current will be excessive for a battery application

You need either a CMOS fully integrated H-bridge IC (beware of H-bridge controllers that need you to add external MOSFETs) or four low Vgs threshold MOSFETs, two each N channel, and P channel.
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6213
  • Country: ro
This circuit would be used to periodically rotate a small 10 cm tall decorative hourglass once the sand has run out.

To turn an hourglass it would be enough only one direction, so no need for a H-bridge.

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Possibly, but that depends on the hourglass mechanism permitting continuous rotation.  It would certainly be simpler - drive the motor with a low-side transistor,  controlled by a 4060 output.  The limit switch would be capacitively coupled to the 4060 RST pin, to reset the 4060, turning off the motor and restarting the timer when the limit position is reached.
 

Online Terry Bites

  • Super Contributor
  • ***
  • Posts: 2399
  • Country: gb
  • Recovering Electrical Engineer
Here's a simple bridge. https://thecodeprogram.com/h-bridge-circuit-and-control-a-dc-motor The diodes are essential or back emf will kill the transistors- 1N4148s will do. What current do you expect/ measure does your motor need? A little gear motor would work well here. It redcues the current requirment for a given torque and reduces shock on your motor and glassware.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
I'd just use a DPDT relay, as it's a low current motor.

VDD can be connected to +V and 0V to VSS. The circuit is drawn with them separate, so the motor can be isolated from the control circuit if necessary.

D1 and D2 need to be rated to the motor's current.

D3 can be smaller, but it might as well be the same as D1 & D2 to simplify the parts list.

The input goes to the 4060's output. The 4060 should be set for a period of 30 minutes. SW1 and SW2 are limit switches, which again need to be able to pass the motor's full current. Check pushing the appropriate switch prevents the motor from rotating in the direction which would cause it to stall when limit it reached. It's probably easier to swap the motor connections if it's wrong.

K1 is a DPDT (Double Pole Double Throw) relay with the appropriate coil voltage for the control circuit and contact rating for the motor current.

It's possible to do this with transistors, but it's more complicated.

« Last Edit: May 30, 2022, 03:13:13 pm by Zero999 »
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
*DON'T* buy a L293D.  Its a bipolar H-bridge and has excessive voltage drop for low voltage use.  See its datasheet section 6.5 Electrical Characteristics.  Voh is typ. 1.4V below Vcc and Vol typ. 1.2V above ground, and you'll loose a bit more in the diodes to permit reversing out of the limit  across your limit switches, leaving you with 2V or less at the motor with 5V Vcc.  Also note its Icc1 and Icc2 supply currents, which IMHO make it unsuitable for a long-duration low power battery powered application.

Discrete complimentary BJTs can be driven hard enough to get the total voltage drop under 1V, so suitable for a 5V motor, but the drive circuit quiescent current will be excessive for a battery application

You need either a CMOS fully integrated H-bridge IC (beware of H-bridge controllers that need you to add external MOSFETs) or four low Vgs threshold MOSFETs, two each N channel, and P channel.

I have cancelled the order  ;D

This circuit would be used to periodically rotate a small 10 cm tall decorative hourglass once the sand has run out.

To turn an hourglass it would be enough only one direction, so no need for a H-bridge.

You're totally right, it only needs to spin in one direction, trip the switch so it stops, wait 15 minutes, do half a turn and stop when it trips the switch.

Possibly, but that depends on the hourglass mechanism permitting continuous rotation.  It would certainly be simpler - drive the motor with a low-side transistor,  controlled by a 4060 output.  The limit switch would be capacitively coupled to the 4060 RST pin, to reset the 4060, turning off the motor and restarting the timer when the limit position is reached.
This sounds like the most elegant and simplest solution. What do you mean when you say 'The limit switch would be capacitively coupled to the 4060 RST pin', what does 'capacitively coupled' mean?
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
This sounds like the most elegant and simplest solution. What do you mean when you say 'The limit switch would be capacitively coupled to the 4060 RST pin', what does 'capacitively coupled' mean?
Connect it via a small capacitor, so it just gives a short pulse, when the switch is made. The reset pin will still need a pull-down resistor and so will the switch.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Its got to be capable of driving out of the limit, and shouldn't consume any power at the limit position.  Therefore use a NC limit switch to ground with a pullup resistor.    When it reaches either half-turn position, a peg on the mechanism operates the switch, so its output goes high and it no longer draws current.  Use a pulldown resistor on RST at least 20x the switch pullup value + a Schotty clamping diode, anode to Gnd to stop RST going negative when the switch recloses.  It will probably also need a small capacitor across the switch to prevent contact bounce when the switch recloses resetting the timer and stopping the motor for another 15 minutes, and 47 ohms directly in series with the switch to limit the capacitor transient discharge current to under 100mA! 
« Last Edit: May 30, 2022, 04:07:36 pm by Ian.M »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Another approach that may be easier to implement is to use a SPST limit switch to connect either a delayed Qn, or a pulldown to RST.   The delay (which could be as simple as series R, C to ground) provides time for the motor to drive out of the limit position before the limit reset circuit is reactivated, so contact bounce on opening doesn't re-reset it.
 

Offline BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1202
  • Country: us
Well if I were to do it I would use the programmable controller which I have available to me. But I do understand such an approach is quite expensive if you have to buy the components. I am thinking of using a thru beam photoelectric sensor which looks thru the hour glass. The sand would block the sensor and the motor doesn't run. When the it's empty the motor will rung and turn the hour glass around until the full part block the sensor again then the motor stop. That way I use the hour glass itself as the timing device.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
I like the stepper motor approach.  There is no need for limit switches, just count steps.  Whether the forward-reverse approach or forward-forward wouldn't matter.

Since the stepper approach, with no limit switch, requires counting, a uC is just about required.

Have we settled on a torque requirement?

https://www.pololu.com/category/120/stepper-motor-drivers
« Last Edit: May 30, 2022, 09:03:24 pm by rstofer »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
I've put together a quick LTspice sim of my reply #27 suggestion, using a behavioral model of the 4060's RST and Qn pin timings, showing its immune to vicious switch bounce.

Its got  a few extra parts - a BAT54S dual series Schottky diode, a 10K resistor and a 1nF capacitor for RST input ESD protection, and also to terminate the RST pulse cleanly when Qn goes low.  I've also shown how junkbox BJTs could be used to drive the O.P's motor, though it would be much simpler to drive a low Vgs threshold MOSFET direct from the 4060, with only a 1K series gate resistor to limit the transient 4060 output current.
 
The following users thanked this post: vranghel

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
I've put together a quick LTspice sim of my reply #27 suggestion, using a behavioral model of the 4060's RST and Qn pin timings, showing its immune to vicious switch bounce.

Its got  a few extra parts - a BAT54S dual series Schottky diode, a 10K resistor and a 1nF capacitor for RST input ESD protection, and also to terminate the RST pulse cleanly when Qn goes low.  I've also shown how junkbox BJTs could be used to drive the O.P's motor, though it would be much simpler to drive a low Vgs threshold MOSFET direct from the 4060, with only a 1K series gate resistor to limit the transient 4060 output current.

Woow, this is great Ian! I opened the sim but honestly the details are above my understanding.

I understand the schematic in general, and I think i could build it since I have most of the parts:
-BAT54S dual series Schottky diode: in only have zenner diodes, 1N4001, 1N4148, 1N914 and Germanium diodes
-found an appropriate NC/NO switch (can operate as both) (https://kagi.com/proxy/12-Pieces-Red-Button-Metal-Long-Lever-Arm-Micro-Limit-Switch-Home-LOT.jpg?c=D7u0yXs99oGy9xkm-57YOw_yiy23Lp8lOir26GxuiRppPXbbcSMFyMxCHS_RT3nDYW4553c2Q7MyVHuV0-2bAIakCIPW-Xc8XLcQblY92hD_f0dmwI47OvHF0ZzW3w5g1iTl2cd8gLXtWr0XNNA6TDuW1M5MtaWnH20xutvHjm2P3A4bUwWCJnEyGMExgyD7

Can I use only half of the SPDT switch from the schematic, and use a NC switch connected to Gnd?

Would the circuit be simplified if i'd replace the transistors with 1 MOSFET? I have IRFZ44N (N-channel, Vgs threshold 2-4 (min-max)) and IRF540N (N-channel, Vgs threshold 2-4 (min-max))
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
As you don't have Schottky diodes for the input clamping, use 2x 1N4148, but add an extra 10K resistor between the junction of the two diodes and the RST input pin.

Although the switch was drawn in the sim as two individual NO and NC halves (because LTspice doesn't come with a SPDT switch component), in real life it *MUST* be a single break-before-make SPDT switch (or one pole of a DPDT switch), so there is absolutely no possibility of both sides being on at the same time, even momentarily.   If it did it would short the charged capacitor, damaging the switch and loosing the RST pulse.  You've found a suitable SPDT switch, so just use it, COM towards the RST pin.
 
If you are unlucky, 4V is too high a threshold voltage, as there isn't much margin between that and the lower limit of your nom. 5V supply voltage, so the MOSFET channel may not enhance enough to pass the motor current.  However, odds are its quite a bit lower, so its worth trying the IRFZ44N at 4.5V, source to ground, gate strapped to +4.5V, your motor between its drain and +4.5V, and check the voltage drop drain to source across the MOSFET.  It should be under 0.1V with the motor running normally, which means you can use that MOSFET.  If its higher, switch off immediately, before the MOSFET overheats.
 
The following users thanked this post: vranghel

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
I like the stepper motor approach.  There is no need for limit switches, just count steps.  Whether the forward-reverse approach or forward-forward wouldn't matter.

Since the stepper approach, with no limit switch, requires counting, a uC is just about required.

Have we settled on a torque requirement?

https://www.pololu.com/category/120/stepper-motor-drivers
How do you know the motor's position when it's powered on? There are no limits so it's not as though it can be driven to a stop.

I agree about using a microcontroller. I'd use the old PIC12F509, purely because I have a load in stock.

I've put together a quick LTspice sim of my reply #27 suggestion, using a behavioral model of the 4060's RST and Qn pin timings, showing its immune to vicious switch bounce.

Its got  a few extra parts - a BAT54S dual series Schottky diode, a 10K resistor and a 1nF capacitor for RST input ESD protection, and also to terminate the RST pulse cleanly when Qn goes low.  I've also shown how junkbox BJTs could be used to drive the O.P's motor, though it would be much simpler to drive a low Vgs threshold MOSFET direct from the 4060, with only a 1K series gate resistor to limit the transient 4060 output current.
Very good, but the wait time is off by a factor of 60. Run the oscillator at 9.1Hz and use the Q14 output to for a half period of 15 minutes.

If there's ambiguity, add a line to the NC switch to make it's clear it's normally closed.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
As you don't have Schottky diodes for the input clamping, use 2x 1N4148, but add an extra 10K resistor between the junction of the two diodes and the RST input pin.

Although the switch was drawn in the sim as two individual NO and NC halves (because LTspice doesn't come with a SPDT switch component), in real life it *MUST* be a single break-before-make SPDT switch (or one pole of a DPDT switch), so there is absolutely no possibility of both sides being on at the same time, even momentarily.   If it did it would short the charged capacitor, damaging the switch and loosing the RST pulse.  You've found a suitable SPDT switch, so just use it, COM towards the RST pin.
 
If you are unlucky, 4V is too high a threshold voltage, as there isn't much margin between that and the lower limit of your nom. 5V supply voltage, so the MOSFET channel may not enhance enough to pass the motor current.  However, odds are its quite a bit lower, so its worth trying the IRFZ44N at 4.5V, source to ground, gate strapped to +4.5V, your motor between its drain and +4.5V, and check the voltage drop drain to source across the MOSFET.  It should be under 0.1V with the motor running normally, which means you can use that MOSFET.  If its higher, switch off immediately, before the MOSFET overheats.

Ian, I have followed your advice and modified the circuit. I created a model for the CD4060 with all the pins as they are laid out, but there are a few pins which I dont know where to connect.
See attached my very unprofessional LTSpice schematic.  Please correct it and modify it accordingly to make a complete circuit. Thanks!
« Last Edit: May 31, 2022, 11:28:36 am by vranghel »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
@Zero999,

Agreed on using a MCU - if you've got the toolchain ready to go a PIC12F509 makes as much sense as any.  The XC8 compiler does a reasonable job of hiding the horrors of the Baseline PIC architecture, so you don't even have to suffer wrangling MPASM assembly code like we had to back in the 90's!  :horse:

Yes, the wait time was off deliberately.  If I'd done the sim with the real ratio between the wait time and the other timings, (and the real 4060 oscillator frequency and division ratio) the run-time would have gone through the roof due to LTspice calculating at least two timesteps per clock edge, and as I disabled waveform compression to permit zooming in on the switch bounce transients and the 'runt' RST pulse, the already ridiculous >21 MB .raw (results) file size would have bloated even further, possibly to the point of crashing the waveform viewer.  |O

I *SHOULD* have drawn a SPDT switch symbol and created hierarchical schematics for  the switch + associated control sources and the behavioral 4060 'lite', but that's starting to turn into a full project rather than a quick 'freebie' proof of concept.  The switch bounce part of the simulation is something I've previously posted here and it literally took me under five minutes to grab it, delete the bits I didn't want and add a NC switch model.  8)
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
@vranghel,

You *MUST* use a SPST SPDT changeover switch to trigger the RST circuit at the desired stopping point(s).   A simple switch to Gnd as you have shown will *NOT* work at all - the motor wonts stop till the timer output pin goes low again after another 15 minutes! 

Take the output from Q14 (pin 3) not pin 4.  You'll also need two resistors and a capacitor, values chosen according to the formulae in the '4060 datasheet for aa frequency of 9.1Hz, connected to pins /CLK, Rext and Cext as per the RC oscillator circuit in the datasheet.  That should give you the required 15 minute delay.

I would also recommend a 100nF decoupling capacitor across '4060 acroos pins 16 (Vdd) and 8 (Gnd), and a 1K resistor in series with the MOSFET gate.
« Last Edit: May 31, 2022, 01:18:42 pm by Ian.M »
 
The following users thanked this post: vranghel

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
@vranghel,

You *MUST* use a SPST changeover switch to trigger the RST circuit at the desired stopping point(s).   A simple switch to Gnd as you have shown will *NOT* work at all - the motor wonts stop till the timer output pin goes low again after another 15 minutes! 

Take the output from Q14 (pin 3) not pin 4.  You'll also need two resistors and a capacitor, values chosen according to the formulae in the '4060 datasheet for aa frequency of 9.1Hz, connected to pins /CLK, Rext and Cext as per the RC oscillator circuit in the datasheet.  That should give you the required 15 minute delay.

I would also recommend a 100nF decoupling capacitor across '4060 acroos pins 16 (Vdd) and 8 (Gnd), and a 1K resistor in series with the MOSFET gate.

@Ian
I have made the changes to the circuit you suggested.
I have used the resistors and capacitor values from here https://www.gadgetronicx.com/how-to-build-24-hours-timer-circuit-cd4060/  and a variable resistor, and with output Q14, i should be able to adjust the timer from 8 min to 20 min.

However, I do not understand what do you mean about the switch: 'SPST changeover switch '
Are you saying that how the switch is wired in is incorrect, or that the type of switch i'm planning to use (https://kagi.com/proxy/12-Pieces-Red-Button-Metal-Long-Lever-Arm-Micro-Limit-Switch-Home-LOT.jpg?c=D7u0yXs99oGy9xkm-57YOw_yiy23Lp8lOir26GxuiRppPXbbcSMFyMxCHS_RT3nDYW4553c2Q7MyVHuV0-2bAIakCIPW-Xc8XLcQblY92hD_f0dmwI47OvHF0ZzW3w5g1iTl2cd8gLXtWr0XNNA6TDuW1M5MtaWnH20xutvHjm2P3A4bUwWCJnEyGMExgyD7) is the wrong one, or both??

I'm sorry for all these questions, i'm a beginner.
I have attached the adjusted circuit.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9954
  • Country: nz
+1 for relays to control the motor.
Probably one that flip polarity and one that is just simple on/off. (It's safer than the alternative way to do it, which could end up shorting the input by mistake)
Setup a 555 timer configured to toggle its output state every 15min.
If 555 output is low the direction relay is one way, if high it's the other way.

Then you just need to handle the limit switch cut-offs.
Use a 3rd relay to combine both limit switches into one pseudo switch that changes depending on 555 output / direction.
Now use that pseudo switch to control the motor on/off control relay.
When the 555 output changes it will change which limit switch is controlling the motor on/off relay and flip the motor direction at the same time.
The newly selected limit switch wont be tripped so it will start moving in that direction until it reaches it. etc..

In my head that sound like it should work.
3x relays and 1x 555 timer.
« Last Edit: May 31, 2022, 01:33:25 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
@vranghel,

You *MUST* use a SPST changeover switch to trigger the RST circuit at the desired stopping point(s).   A simple switch to Gnd as you have shown will *NOT* work at all - the motor wonts stop till the timer output pin goes low again after another 15 minutes! 

Take the output from Q14 (pin 3) not pin 4.  You'll also need two resistors and a capacitor, values chosen according to the formulae in the '4060 datasheet for aa frequency of 9.1Hz, connected to pins /CLK, Rext and Cext as per the RC oscillator circuit in the datasheet.  That should give you the required 15 minute delay.

I would also recommend a 100nF decoupling capacitor across '4060 acroos pins 16 (Vdd) and 8 (Gnd), and a 1K resistor in series with the MOSFET gate.

@Ian
I have made the changes to the circuit you suggested.
I have used the resistors and capacitor values from here https://www.gadgetronicx.com/how-to-build-24-hours-timer-circuit-cd4060/  and a variable resistor, and with output Q14, i should be able to adjust the timer from 8 min to 20 min.

However, I do not understand what do you mean about the switch: 'SPST changeover switch '
Are you saying that how the switch is wired in is incorrect, or that the type of switch i'm planning to use (https://kagi.com/proxy/12-Pieces-Red-Button-Metal-Long-Lever-Arm-Micro-Limit-Switch-Home-LOT.jpg?c=D7u0yXs99oGy9xkm-57YOw_yiy23Lp8lOir26GxuiRppPXbbcSMFyMxCHS_RT3nDYW4553c2Q7MyVHuV0-2bAIakCIPW-Xc8XLcQblY92hD_f0dmwI47OvHF0ZzW3w5g1iTl2cd8gLXtWr0XNNA6TDuW1M5MtaWnH20xutvHjm2P3A4bUwWCJnEyGMExgyD7) is the wrong one, or both??

I'm sorry for all these questions, i'm a beginner.
I have attached the adjusted circuit.
Just use a SPST switch: normally closed to 0V and normally open to +V.

I'd just use 620k for both timing resistors and 100nF for the capacitor. The capacitor needs to be non-polarised and 10µF is quite a big value for such a capacitor.

Here's a more detailed explanation of how the type of oscillator used in the 4060 works and how to calculate the component values. When the two resistor values are the same F = 0.559/(RC). If you really need to add a trimpot, reduce the value of the resistor going to pin 10 of the 4060 to 390k and put your 470k trimmer in series.
https://www.onsemi.com/pub/Collateral/AND9983-D.PDF

Presumably this doesn't need to be accurate. If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock. An RC oscillator won't be stable enough, even with a trimmer.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Sorry for the confusion: 'SPST changeover switch' was a typo, which should have been 'SPDT changeover switch'.

To use your preferred switch, connect its NC pin to Gnd,  NO pin to junction of R1+C1 in your "hourglass circuit.asc", and its C (com) pin to the left end of R2.  Arrange two pegs on the mechanism to trip the switch, one for each hourglass orientation, that approach the switch from the hinge end of the lever actuator so they slide over it without catching on it.

R1+C1 provide a delay to allow the motor enough time to drive the peg off the switch actuator when the motor starts, before re-enabling the limit switch to RST circuit.  Unless the speed is high enough that it coasts off the actuator, past the switch when it stops, Zero999's suggestion of simply switching Vcc to RST will *NOT* work.  I looked at capacitively coupling it to allow the motor to restart, but it was difficult to avoid any switch bounce on opening resetting the 4060, and stopping the motor for an additional 15 minutes just after the switch open.

@PSI: Build your 50% duty cycle 15 minute 555 timer, then report back to us what type of capacitor you used, and how much off the ideal design RC values you had to go to compensate for leakage current!  :popcorn:  Then  see how temperature sensitive it is . . .  :scared:
« Last Edit: May 31, 2022, 01:41:45 pm by Ian.M »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
Sorry for the confusion: 'SPST changeover switch' was a typo, which should have been 'SPDT changeover switch'.

To use your preferred switch, connect its NC pin to Gnd,  NO pin to junction of R1+C1 in your "hourglass circuit.asc", and its C (com) pin to the left end of R2.  Arrange two pegs on the mechanism to trip the switch, one for each hourglass orientation, that approach the switch from the hinge end of the lever actuator so they slide over it without catching on it.
And silly me just copied it, without thinking.  :palm:

Quote
@PSI: Build your 50% duty cycle 15 minute 555 timer, then report back to us what type of capacitor you used, and how much off the ideal design RC values you had to go to compensate for leakage current!  :popcorn:  Then  see how temperature sensitive it is . . .  :scared:
It's possible, but won't be anywhere near accurate. Use it in Schmitt trigger mode, with pin 5 tweaked to give several RC time constants.
 

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 2584
  • Country: gb
Quote
If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock
The 4060 has the option to use a  crystal if you want accuracy.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
Quote
If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock
The 4060 has the option to use a  crystal if you want accuracy.
But there's a limit to the range of crystal frequencies available and you'll need a butt load of ICs to get the desired delay. The 4521 is a better choice, having 24 stages, which would give a period of 512 seconds, with a 32768Hz crystal, but another IC would be required to get 15 minutes. A microcontroller is a more sensible approach.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Yes, we can't get there in one 4000 series chip as the 214 max division ratio isn't enough to get a 32768 HZ crystal down to the required 30 minute period (15 minutes on).    The best it can do is 2 Hz on Q13.   Even if you cascade it with another 4060 or 4020 you'll need to add logic to the first one to reset it early to 'bump' the 8 Hz Q11 output clocking the second counter up to the required 9.1 Hz.  Unfortunately Q10 isn't available so the required terminal count of binary 1110 0001 0000 cant easily be implemented. If it was, it could be done by diode logic.   The easiest workaround is to go to a 100Hz crystal, take the output from Q13 with a terminal count of 10 1010 1110 1000, for a clock that is 212 pm fast. Ideally it would be 10 1010 1110 1010, but again Q1 isn't available so we cant get it down to only 30 ppm fast. Seven diodes and a pullup resistor later, the first 4060 will be outputting very close to the correct frequency.

Of course a MCU is the sane choice as it facilitates the use of arbitrary integer division counts, allowing the final accuracy to be as good as the crystal.
« Last Edit: May 31, 2022, 04:30:15 pm by Ian.M »
 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6213
  • Country: ro
Alternatively, go to an auto scrapyard and harvest a few windshield motors.   :)

Add limiter switches in series with the motor, to turn it off after each half turn, then add a 15 minutes timer to override the limiters for a short while, just enough to start a new spin.  Give it a steampunk look so it won't need a case to hide its internals.

Online themadhippy

  • Super Contributor
  • ***
  • Posts: 2584
  • Country: gb
Quote
But there's a limit to the range of crystal frequencies available
How times have changed,don't seem that long ago that for a reasonable amount of cash,you could get a crystal "grown" to whatever exotic frequency you required
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
Quote
But there's a limit to the range of crystal frequencies available
How times have changed,don't seem that long ago that for a reasonable amount of cash,you could get a crystal "grown" to whatever exotic frequency you required
I didn't know that. What was the lowest frequency you could get? For a period of 30 minutes and a 24 stage counter. F = 224/(60*30) ≅ 9320.676Hz, but I've not seen a crystal below 10kHz before and 20kHz is currently the lowest frequency I could find.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9954
  • Country: nz
Quote
@PSI: Build your 50% duty cycle 15 minute 555 timer, then report back to us what type of capacitor you used, and how much off the ideal design RC values you had to go to compensate for leakage current!  :popcorn:  Then  see how temperature sensitive it is . . .  :scared:
It's possible, but won't be anywhere near accurate. Use it in Schmitt trigger mode, with pin 5 tweaked to give several RC time constants.

True, but does it really need to be that accurate, given the application?
I guess only the OP can decide.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Just use a SPST switch: normally closed to 0V and normally open to +V.

I'd just use 620k for both timing resistors and 100nF for the capacitor. The capacitor needs to be non-polarised and 10µF is quite a big value for such a capacitor.

Here's a more detailed explanation of how the type of oscillator used in the 4060 works and how to calculate the component values. When the two resistor values are the same F = 0.559/(RC). If you really need to add a trimpot, reduce the value of the resistor going to pin 10 of the 4060 to 390k and put your 470k trimmer in series.
https://www.onsemi.com/pub/Collateral/AND9983-D.PDF

Presumably this doesn't need to be accurate. If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock. An RC oscillator won't be stable enough, even with a trimmer.

@Zero999

For the RC oscillator, using same timing resistors, 620k and 100 nF for the cap, i'd get a delay of 17 minutes (from pin 15 (Q10))
It doesnt need to be accurate at all. I have added the resistor and trimmer values you suggested in the schematic.

Sorry for the confusion: 'SPST changeover switch' was a typo, which should have been 'SPDT changeover switch'.

To use your preferred switch, connect its NC pin to Gnd,  NO pin to junction of R1+C1 in your "hourglass circuit.asc", and its C (com) pin to the left end of R2.  Arrange two pegs on the mechanism to trip the switch, one for each hourglass orientation, that approach the switch from the hinge end of the lever actuator so they slide over it without catching on it.

@Ian
Disregarding what the actual symbol looks like in the schematic, is the switch wired in correctly, if I will use the previously shown switch in NC mode? Since i will only be using 2 pins of the switch to achieve the NC operation, does it matter which way are those 2 poles placed in the circuit? I'd say no.

Does the overall circuit look ok?

Thanks!

Attached the circuit LTSpice and a pic of the circuit
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
No. that wont work.  As I explained back in reply #36, it *NEEDS* the changeover switching action, so three wires to the switch, wired as I specified in #40.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Yes, we can't get there in one 4000 series chip as the 214 max division ratio isn't enough to get a 32768 HZ crystal down to the required 30 minute period (15 minutes on).    The best it can do is 2 Hz on Q13.   Even if you cascade it with another 4060 or 4020 you'll need to add logic to the first one to reset it early to 'bump' the 8 Hz Q11 output clocking the second counter up to the required 9.1 Hz.  Unfortunately Q10 isn't available so the required terminal count of binary 1110 0001 0000 cant easily be implemented. If it was, it could be done by diode logic.   The easiest workaround is to go to a 100Hz crystal, take the output from Q13 with a terminal count of 10 1010 1110 1000, for a clock that is 212 pm fast. Ideally it would be 10 1010 1110 1010, but again Q1 isn't available so we cant get it down to only 30 ppm fast. Seven diodes and a pullup resistor later, the first 4060 will be outputting very close to the correct frequency.

Of course a MCU is the sane choice as it facilitates the use of arbitrary integer division counts, allowing the final accuracy to be as good as the crystal.

I just saw your post Ian, and while most of it flies right above my head, the conclusion seems to be that the 4060 is not suitable for such a long time period.
In the calculation from my previous post, i incorrectly used pin Q10, even tho it's not available.

What is still unclear to me, is how the circuit outputs? Does it work by being 15 minutes on, 15 minutes off? In that case, for the calculation, do i need to consider 15 minutes, or 30 minutes?

I revised my calculation using the values provided by Zero999 and realized that i did a mistake:
If i use Q11, using the C and R values suggested by Zero999, i MISTAKENLY thought I'd get a delay of 34 minutes (R= 620000, C= 1E-07; The formula i used is Freq = 0.559/(RC)= 9.02 Hz; Q11 results in 2048 clock pulses, therefore the i did 2^11 TIMES 9.02 Hz to get the seconds. BUT i should have done 2^11 DIVIDED BY 9.02 Hz , which results in 25 SECONDS.

However, the R and C values suggested in this article: https://www.build-electronic-circuits.com/4000-series-integrated-circuits/ic-4060/
shows that it is possible to get both 17 and 34 minutes using Q11 and Q 12 respectively
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
No. that wont work.  As I explained back in reply #36, it *NEEDS* the changeover switching action, so three wires to the switch, wired as I specified in #40.

Ok, i think i understood this time  |O

I attached a crudely drawn schematic to show what i believe you meant how to connect the switch poles.  :)
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4040
  • Country: nz
I like the stepper motor approach.  There is no need for limit switches, just count steps.  Whether the forward-reverse approach or forward-forward wouldn't matter.

I'm late to this thread.

If it was my project I would absolutely use the cheapest microcontroller I could find (or just one of my stock of $1 ATTiny85's which are vast overkill for this, program size-wise) and a cheap stepper motor (which I also have a stock of).

Here is 5 stepper motors and 5 drivers for $14.

https://www.amazon.com/ELEGOO-28BYJ-48-ULN2003-Stepper-Arduino/dp/B01CP18J4A

This is the kind of stepper that is universally used for things such as the louvers on air conditioners. They don't bother with limit switches -- at power-on they just drive the thing all the way in one direction and I think let the drive mechanism slip at the mechanical limit. They have a built in geartrain and rotate slowly and with plenty of torque.

Here's a video from when I first played with one in 2013:

youtube.com/watch?v=-c3MxdvORSA

They have 5 wires. You're supposed to connect the common to ground and pulse each of the other 4 wires in turn, with the direction of rotation determined by which order you pulse them in. But here I was leaving the common wire unconnected and using an H-bridge motor driver (I think) and it works fine.  This was the maximum rotation speed, You can go much more slowly.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
I like the stepper motor approach.  There is no need for limit switches, just count steps.  Whether the forward-reverse approach or forward-forward wouldn't matter.

I'm late to this thread.

If it was my project I would absolutely use the cheapest microcontroller I could find (or just one of my stock of $1 ATTiny85's which are vast overkill for this, program size-wise) and a cheap stepper motor (which I also have a stock of).

Here is 5 stepper motors and 5 drivers for $14.

https://www.amazon.com/ELEGOO-28BYJ-48-ULN2003-Stepper-Arduino/dp/B01CP18J4A

This is the kind of stepper that is universally used for things such as the louvers on air conditioners. They don't bother with limit switches -- at power-on they just drive the thing all the way in one direction and I think let the drive mechanism slip at the mechanical limit. They have a built in geartrain and rotate slowly and with plenty of torque.

Here's a video from when I first played with one in 2013:

youtube.com/watch?v=-c3MxdvORSA

They have 5 wires. You're supposed to connect the common to ground and pulse each of the other 4 wires in turn, with the direction of rotation determined by which order you pulse them in. But here I was leaving the common wire unconnected and using an H-bridge motor driver (I think) and it works fine.  This was the maximum rotation speed, You can go much more slowly.

Hi Bruce,

While this approach maybe would have been easier for some, I dont have any microcontroller programming experience, don't have stepper motors handy and the circuit needs to run on battery.
I do, however, have (some) experience with analog circuits, and have a number of geared motors, and am overall more comfortable with them
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
No. that wont work.  As I explained back in reply #36, it *NEEDS* the changeover switching action, so three wires to the switch, wired as I specified in #40.

Ok, i think i understood this time  |O

I attached a crudely drawn schematic to show what i believe you meant how to connect the switch poles.  :)

Still wrong!  As I *EXPLAINED* back in reply #40:  :horse:
To use your preferred switch, connect its NC pin to Gnd,  NO pin to junction of R1+C1 in your "hourglass circuit.asc", and its C (com) pin to the left end of R2.  Arrange two pegs on the mechanism to trip the switch, one for each hourglass orientation, that approach the switch from the hinge end of the lever actuator so they slide over it without catching on it.

R1+C1 provide a delay to allow the motor enough time to drive the peg off the switch actuator when the motor starts, before re-enabling the limit switch to RST circuit.
I'll say that again obnoxiously large:  :blah:
NO pin to junction of R1+C1
« Last Edit: June 01, 2022, 11:02:31 am by Ian.M »
 
The following users thanked this post: vranghel

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
@Ian

I REALLY hope i did it right this time

For some reason i thought you were referring to the R and C that set the oscillations. My bad
« Last Edit: June 01, 2022, 11:10:52 am by vranghel »
 
The following users thanked this post: Ian.M

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Much better.   Now breadboard it so you understand it properly before you build the permanent version.  As drawn you should get about 1 minute delay, great for testing.  Take the output (and feed R1 etc.) from pin 3 for the maximum delay of 15 minutes for the permanent build.
 
The following users thanked this post: vranghel

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3367
  • Country: nl
Hi Bruce,

While this approach maybe would have been easier for some, I dont have any microcontroller programming experience, don't have stepper motors handy and the circuit needs to run on battery.
I do, however, have (some) experience with analog circuits, and have a number of geared motors, and am overall more comfortable with them

I'm not Bruce, and I would definitely not use the cheapest microcontroller I could find (I hate those 8 pin jobbies, especially lots of silly changes that make ATmega's and ATtinies incompatible. It's a real nuisance).

I would use a microcontroller though.
The flexibility of these things, and that you can make them do almost anything by just pushing some buttons on your keyboard make them quite attractive for a lot of quick projects. Power consumption of a microcontroller can also be extremely low. Power consumption can be less then a micro amp when sleeping (with some timer running to occasionally wakeup)

But you have to be interested in these things. A project like this is a good start for learning to use microcontrollers, and if you want to do more with electronics in the future, microcontrollers are hard to avoid. With a microcontroller you can also make other things easier. for example, instead of making something with end switches, you can just glue an accelerometer to your device and then measure it's position.

Combining a microcontroller with a H-Bridge motor driver IC is also easy. It's just two wires. All these IC's are designed to work with mircocontrollers.

For suitable H-bride drivers. Forget about the old L298 and such, but use something modern in a SOIC package or similar. There are lots of variants and you can buy easy to manage breakout boards for them.

I would not use a stepper motor tough. A geared DC motor is a better choice for a low power application.



 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
I like the stepper motor approach.  There is no need for limit switches, just count steps.  Whether the forward-reverse approach or forward-forward wouldn't matter.

I'm late to this thread.

If it was my project I would absolutely use the cheapest microcontroller I could find (or just one of my stock of $1 ATTiny85's which are vast overkill for this, program size-wise) and a cheap stepper motor (which I also have a stock of).

Here is 5 stepper motors and 5 drivers for $14.

https://www.amazon.com/ELEGOO-28BYJ-48-ULN2003-Stepper-Arduino/dp/B01CP18J4A

This is the kind of stepper that is universally used for things such as the louvers on air conditioners. They don't bother with limit switches -- at power-on they just drive the thing all the way in one direction and I think let the drive mechanism slip at the mechanical limit. They have a built in geartrain and rotate slowly and with plenty of torque.

Here's a video from when I first played with one in 2013:

youtube.com/watch?v=-c3MxdvORSA

They have 5 wires. You're supposed to connect the common to ground and pulse each of the other 4 wires in turn, with the direction of rotation determined by which order you pulse them in. But here I was leaving the common wire unconnected and using an H-bridge motor driver (I think) and it works fine.  This was the maximum rotation speed, You can go much more slowly.
There is no mechanical limit in this case, so a switch or optical sensor is necessary.
Hi Bruce,

While this approach maybe would have been easier for some, I dont have any microcontroller programming experience, don't have stepper motors handy and the circuit needs to run on battery.
I do, however, have (some) experience with analog circuits, and have a number of geared motors, and am overall more comfortable with them
I strongly recommend learning to program a microcontroller. It's not that difficult and it can greatly simply projects. Some see it as lazy, but I don't understand how learning something new can ever be lazy.

I'm not Bruce, and I would definitely not use the cheapest microcontroller I could find (I hate those 8 pin jobbies, especially lots of silly changes that make ATmega's and ATtinies incompatible. It's a real nuisance).

I would use a microcontroller though.
Which one would you use then? I consider anything with more than 8 pins to be overkill in this application. Fair enough, you might only stock larger devices, but they do take up more space.
Quote
I would not use a stepper motor tough. A geared DC motor is a better choice for a low power application.
I agree.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Much better.   Now breadboard it so you understand it properly before you build the permanent version.  As drawn you should get about 1 minute delay, great for testing.  Take the output (and feed R1 etc.) from pin 3 for the maximum delay of 15 minutes for the permanent build.

Phew.... :phew:

I am waiting for the 4060s to be delivered and will breadboard it, test it and tweak the circuit so it spins at the right time interval.
Will post updates and pics of the results.

Thanks everyone for your advice, help and patience!
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19537
  • Country: gb
  • 0999
Just use a SPST switch: normally closed to 0V and normally open to +V.

I'd just use 620k for both timing resistors and 100nF for the capacitor. The capacitor needs to be non-polarised and 10µF is quite a big value for such a capacitor.

Here's a more detailed explanation of how the type of oscillator used in the 4060 works and how to calculate the component values. When the two resistor values are the same F = 0.559/(RC). If you really need to add a trimpot, reduce the value of the resistor going to pin 10 of the 4060 to 390k and put your 470k trimmer in series.
https://www.onsemi.com/pub/Collateral/AND9983-D.PDF

Presumably this doesn't need to be accurate. If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock. An RC oscillator won't be stable enough, even with a trimmer.

@Zero999

For the RC oscillator, using same timing resistors, 620k and 100 nF for the cap, i'd get a delay of 17 minutes (from pin 15 (Q10))
It doesnt need to be accurate at all. I have added the resistor and trimmer values you suggested in the schematic.
That doesn't sound right to me. 620k and 100nF should give a frequency of 9Hz. Pin Q10 will go high after 29 = 512 counts, which would 512/9 = 57 seconds. The output needs to be taken from pin 3, which will go high after 213 counts, giving a delay of 910 seconds, which is just over 15 minutes.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Just use a SPST switch: normally closed to 0V and normally open to +V.

I'd just use 620k for both timing resistors and 100nF for the capacitor. The capacitor needs to be non-polarised and 10µF is quite a big value for such a capacitor.

Here's a more detailed explanation of how the type of oscillator used in the 4060 works and how to calculate the component values. When the two resistor values are the same F = 0.559/(RC). If you really need to add a trimpot, reduce the value of the resistor going to pin 10 of the 4060 to 390k and put your 470k trimmer in series.
https://www.onsemi.com/pub/Collateral/AND9983-D.PDF

Presumably this doesn't need to be accurate. If you need precision timing, the only sane way is with a microcontroller using a crystal for the clock. An RC oscillator won't be stable enough, even with a trimmer.

@Zero999

For the RC oscillator, using same timing resistors, 620k and 100 nF for the cap, i'd get a delay of 17 minutes (from pin 15 (Q10))
It doesnt need to be accurate at all. I have added the resistor and trimmer values you suggested in the schematic.
That doesn't sound right to me. 620k and 100nF should give a frequency of 9Hz. Pin Q10 will go high after 29 = 512 counts, which would 512/9 = 57 seconds. The output needs to be taken from pin 3, which will go high after 213 counts, giving a delay of 910 seconds, which is just over 15 minutes.

You're probably right Zero999, and my calculations were most likely wrong. I'll test around the values and see what is the real life delay
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Yep.  Use  pin 15 for ~ 1 minute delay, ideal for bench testing.  15 minutes delay for the actual application, as you noted, and I also mentioned back in reply #57, requires the highest Q output - pin 3.

[sarchasm]
For those still suggesting a MCU, well then this three page thread would be at least a twelve page one!  |O

First you'd have the obligatory three page MCU flamewar with major contributions from the Microchip PIC and Atmel AVR fanbois (though the latter are much deflated since the Microchip takeover of Atmel), while the STM aficionados take pot-shots from the sidelines.  Fortunately the one and only rabid PSOC fanboi hasn't been active here for over three years, so it wont turn into a lynch-mob unless an 8051 enthusiast joins in! 

Then the schematic should only take a page or two, leaving three to four pages for which toolchain to  use and how to get its software components installed in a nonbroken state, then four pages to get the O.P's code up to the point where it can successfully implement a simple action loop, busy-waiting on the switch, with a hard coded delay between turning the motor off and turning it back on.  >:D :popcorn: [/sarchasm]
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4040
  • Country: nz
For those still suggesting a MCU, well then this three page thread would be at least a twelve page one!  |O

First you'd have the obligatory three page MCU flamewar with major contributions from the Microchip PIC and Atmel AVR fanbois (though the latter are much deflated since the Microchip takeover of Atmel), while the STM aficionados take pot-shots from the sidelines.  Fortunately the one and only rabid PSOC fanboi hasn't been active here for over three years, so it wont turn into a lynch-mob unless an 8051 enthusiast joins in! 

How can you forget RISC-V? :p

Quote
Then the schematic should only take a page or two, leaving three to four pages for which toolchain to  use and how to get its software components installed in a nonbroken state, then four pages to get the O.P's code up to the point where it can successfully implement a simple action loop, busy-waiting on the switch, with a hard coded delay between turning the motor off and turning it back on.  >:D :popcorn:

Not really.

ATTiny85 (or 25 etc, but I have a stock of 8 pin DIP 85s) needs zero external components. Just connect power and it runs at 1 MHz. The Arduino IDE perfectly covers up any differences between the Tiny and the Mega. You can program it using an Uno (etc) and a special programmer program that comes with the IDE.

And of course "Blinky" is the standard helloworld for any microcontroller, including Arduino.

File / Examples / 0.1 Basics / Blink

Add a 2nd output pin and digitalWrite(). Add an input pin for some kind of limit sensor. And a handful more lines of logic to deal with it.

Seems like very easy and just about an ideal starter project.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
You did spot the not quite BBCODE tags wrapping my rant?

Adding ATtiny 'board' support to the Arduino IDE is a step too far for some of our more coding-challenged members!  If the O.P. turns out to be one of those poor souls with a negative aptitude for procedural programming, I suspect we'd still be in for four pages of iterative code refinement even starting with 01.Basics:Blink on a 'vanilla' Uno or Nano.  :'(
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
SUCCESS!!  :-+

I built the circuit on a breadboard using 2x680K resistors for the timing.

With the button UNPRESSED, the motor starts spinning after 62 seconds, and stops when the button is momentarily pressed. To reset the timer, the button needs to be (left) unpressed for the timer to re-start counting down.

The way I plan to build the mechanism is to have the hourglass spinning, then pressing the switch, and at the moment the motor needs to stop (while the switch is kept pressed), and the timer needs to run; After 15 minutes, the motor needs to spin UNTIL the switch is pressed again(and kept pressed), at which time the motor will stop and the timer runs again.

I think i need to tweak the wiring of the switch, but I dont think I know how.
« Last Edit: June 03, 2022, 11:29:33 am by vranghel »
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
I modified the circuit so that the switch needs to be PRESSET for the timer to start.
As soon as the motor starts, the hourglass is spinning and slides off the switch, which makes the motor stop.
For the timer to be running, the button needs to be pressed, but this condition cannot be met, therefore, it is stuck.

Is there a way to wire the circuit so that while the button is pressed the circuit counts down, then the motor is running which causes the switch to be depressed, BUT the motor keeps running UNTIL it the switch is pressed, at which time the motor stops, and the timer counts down.


If that's not possible or feasible, then I need to figure out a mechanical way to build it so that the hourglass just momentarily TRIPS the switch.
« Last Edit: June 03, 2022, 11:46:58 am by vranghel »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Explain!  Post your modified circuit, and a sketch of how the motor is going to press the switch.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Attached the modified circuit:

How it currently works with the attached schematic: While the button is PRESSED, the timer runs down. After the countdown, the motor runs, and stops when the button is DEPRESSED

The way I envision it to work: The hourglass is pressing against the arm lever of the switch. After 15 minutes, the motor spins, the hourglass turns 180 degrees and presses the switch again. At that moment, the motor should stop, and the countdown needs to begin.

Now, this is problematic from a mechanical build standpoint: With the circuit as displayed, the motor starts( with the switch pressed) but once the hourglass slides off the switch, the motor stops; Therefore, the mechanism is stuck, with no way to restart (the circuit runs ONLY when the button is PRESSED)

As a side-effect, if the switch is left unpressed, after the countdown the motor 'jerks' for a split second, then stops.


« Last Edit: June 03, 2022, 12:23:32 pm by vranghel »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Redrawn for clarity:

Yes, wiring the switch like that will do that. 
If you rewire it back to my original switch connections:

the motor will run with the switch lever up and stop (reset and start timing) when it is pressed, which is usually mechanically much easier to implement.

If that's not how you want it to work, describe the desired sequence of operations in terms of what the hourglass is doing, when the motor should start and stop, and what's happening to operate the switch, noting any significant time delays between actions and their results.
 
N.B. Its just a schematic, not a sim! Attached for your future edits.
« Last Edit: June 03, 2022, 01:25:53 pm by Ian.M »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3039
  • Country: us
What about this approach...

Use a 15-minute monostable. The monostable is triggered by the switch going from open to closed. The motor is running if and only if the monostable is off.

If we assume the motor is running the sequence of events would be...

1. the motor turns the hour glass
2. the hour glass hits the switch causing an open to closed event
3. the open to closed event triggers the monostable to start running
4. the monostable running turns off the motor
5. when the monostable expires the motor starts running again
6. the hour glass will run past the switch causing a closed to open event but this should not affect anything
7. after rotating 180 degrees the hour glass hits the switch again causing an open to closed event and the sequence repeats

It's key to debounce the switch so you get clean open to closed and closed to open events.
« Last Edit: June 03, 2022, 01:53:39 pm by ledtester »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
There is a simple way to make a RC oscillator CD4060 work as a (retriggerable) monostable, with active low output.  Connect a diode between Qn and CLK, cathode to CLK.   When the output goers high at the end of the timing period, it stops the RC oscillator 'freezing' it until Reset is pulsed to trigger it again.   If you want a non-retriggerable monostable you need to add an AND gate, to drive Reset from combined Trigger and Qn, so Trigger is held off till the timing period ends.   This can be done with diode logic with a pullup on Reset, and two diodes, one cathode to the trigger signal (active high) and the other cathode to Qn, though using two gates of a CD4011 quad NAND may be preferable as one of the remaining gates can be used to invert the Qn output so its active high.

Note there is *NO* way to 'reset' the '4060 monostable on powerup - it *MUST* run till Qn goes high to enter its stable state, waiting for trigger.
« Last Edit: June 03, 2022, 02:11:33 pm by Ian.M »
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
@ Ian:

You explained the operation of the original circuit as follows: 'the motor will run with the switch lever up and stop (reset and start timing) when it is pressed,'
That is correct but describes only half of the operation, with the continuation as follows: The motor then stops when the lever is pressed (the lever is kept pressed by the hourglass, when it reaches the desired position)

Once the sand has flowed, the circuit needs to re-start while the lever is pressed. However, according to but my observation, the motor does not restart (while lever is kept pressed) and only slighty jerks.
It needs to start timing with the lever pressed, and once starts spinning (and the lever is DEpressed) it needs to continue spinning until the lever is pressed again (after rotating 180degrees). But currently it does not spin (after the countdown) with the lever pressed. Hope my explanations are clear now.

I dont understand exactly what does R1and C1 do, what does it delay.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
R1, C1 provides the delay that lets the motor jerk.  It needs to be long enough to get the peg off the switch lever.  Try increasing C1 to 10uF.
 

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
And once that 'jerk' has gotten it off the switch lever will it continue to spin? I'll increase the cap and try to manually test it.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12865
Yes, as once the switch releases, its NC contact holds Reset low (no reset) so the motor stays running (for up to 15 minutes), while C1 continues to charge so the switch can reset the '4060, stopping the motor, when its next hit.
« Last Edit: June 03, 2022, 02:25:26 pm by Ian.M »
 
The following users thanked this post: vranghel

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
Wow! This is great!  ;D
Works as intended now: the 10uF gives it a strong enough 'jerk' so it slides off the lever, then continues to spin 180degrees until it stops and rests on the lever.

Thank you very much for all your help Ian!! Your knowledge as help was invaluable.

I will post pics with the final result.
 
The following users thanked this post: Ian.M

Offline vranghelTopic starter

  • Contributor
  • Posts: 32
  • Country: de
FINISHED!!

I built the circuit and after some mechanical and electrical tweaking it works exactly how I envisioned it.

Video of the spinning hourglass:
https://thumbs.gfycat.com/ZestyBlushingCoral-mobile.mp4

I've added a few additional features:
  • test mode switch: to switch between the 1 minute delay pin and the 15 minute delay pin;
  • power switch
  • female micro USB: to trickle charge the 3 NiMh batteries (via a resistor and diode)
  • solar panel: used as a base and also charges the batteries via a Ge diode

For some reason, I built it with only 3 NiMh batteries in series, which don't give enough power if they are a bit discharged. Will add the 4th to give it more oomph and longer running time.

I am very happy with the result and it works very well and looks quite nice too.

Depending on how it works long term, I might replace the NiMh batteries with a used cell phone battery since it has a much larger capacity and it's easily charged with a small and cheap TP4056 based battery charger board

Thanks again to Ian.M and others for the help!

 
The following users thanked this post: RoGeorge, ledtester


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf