Relay switching circuit

dendad

Joined Feb 20, 2016
4,638
Here is a way to "vary" the outputs.
This is not ideal but illustrates one option. Using a diode matrix AND gate allows you to select a range of output times.
To have a time valid, either the count or the NOT_count must be connected to the driver input in question.Irrigation_1.jpg
Now, before I get flamed, I know this is not the the best way but is one of many ways to do it.
Another could be to use a diode matrix from the outputs of the 4017 to the driver inputs.
Pull the driver inputs down and hook the cathodes of the diodes to the inputs. That way you are using an OR gate so 1 OR more 4017 outputs can drive the outputs.
Oh, the diodes can be 1N4148, 1N914 or any other small diode.
I have not built this and hope I got it correct.
I have another way too, but have not drawn it as yet. Maybe later.....
Now I'd best do some real work ;)
 

Thread Starter

Mellisa_K

Joined Apr 2, 2017
391
Thanks Dendad I will print this out tonight and have a look. I won't be able to get back to you for a few days. I very much appreciate your time on this.
Regards
Mellisa
 

dendad

Joined Feb 20, 2016
4,638
Another way to do this is to use a 555 to produce the clock signal, not the RC osc on the 4060.
Then with a diode from each output of the 4017 (cathode to 4017 o/p) and a series resistor or pot, feed the 555 oscillator.
See this blog..
http://www.learningaboutelectronics...d-oscillator-VCO-circuit-with-a-555-timer.php

IrrigationTimerMod.jpg
I unashamedly borrowed the circuit you are using to show you a way to mod it.
I didn't get around to drawing it properly.
Now you can adjust the time of each output.
The 555 values are just a guess, and I have not built this but I think this should work.
Have fun :)
 
Last edited:

Thread Starter

Mellisa_K

Joined Apr 2, 2017
391
Another way to do this is to use a 555 to produce the clock signal, not the RC osc on the 4060.
Then with a diode from each output of the 4017 (cathode to 4017 o/p) and a series resistor or pot, feed the 555 oscillator.
See this blog..
http://www.learningaboutelectronics...d-oscillator-VCO-circuit-with-a-555-timer.php

View attachment 126046
I unashamedly borrowed the circuit you are using to show you a way to mod it.
I didn't get around to drawing it properly.
Now you can adjust the time of each output.
The 555 values are just a guess, and I have not built this but I think this should work.
Have fun :)
thanks Dendad. have printed the two circuits and i will study them and build one. i will give you feedback asap
 

AnalogKid

Joined Aug 1, 2013
12,139
Another way to do this is to use a 555 to produce the clock signal,
With a CMOS 555 you probably can eliminate the CD4060. Also, I don't think the control input will have the desired adjustment range.

MK - in a system with individually adjustable times for each zone, what are the overall minimum and maximum on times?

ak
 

dendad

Joined Feb 20, 2016
4,638
With a CMOS 555 you probably can eliminate the CD4060. Also, I don't think the control input will have the desired adjustment range.

MK - in a system with individually adjustable times for each zone, what are the overall minimum and maximum on times?

ak
That's a good idea AnalogKid. Trying a CMOS 555!
I tried to read the CRO frequency on the video from the bolg link, and looking at the trace, there was a wide range of frequency adjustment. This is something I must have a try at to see how it goes. Oh, this brings back memories of fiddling with circuits from long ago.

Now I just design and make things like this, my latest little board...
OMCB-Btm.jpg
This is the bottom view. And before cleaning.
 

dendad

Joined Feb 20, 2016
4,638
That's good, now I won't have to draw the circuit properly :) Thanks.
This has been a very interesting thread. I may even have a go at building it myself to see how it works.
 

Thread Starter

Mellisa_K

Joined Apr 2, 2017
391
Hello AK,


I need a bit more help, please, calculating the frequency of oscillation of the CD4060 and reconciling with your estimate accompanying your schematic in post #54.


Firstly could you check the following story about the way the IC counts the voltage flips and flops as they ripple across its outputs, and how the oscillator circuit determines the time period of the counting process. I think I have got this right now, after spending some time figuring it out.


What I am currently having trouble with is application of the formula for the frequency of oscillation of the IC. Getting this correct is predicated on my understanding of the how the IC counts time and how the time units are set. So I would like to share with you my understanding of this aspect so as to ensure I have got it right before proceeding to the frequency calculations.


I acknowledge it’s long and detailed and for someone with your knowledge it’s probably tedious to read. But please bear with me. My purpose in writing out a story is as much to force me to understand the subject matter as it is trying to communicate my problem to you.


[Please note that I have written the arithmetic expressions in this post using the MS Excel convention.]



How the CD4060 counts in binary digits

n My understanding of the 4060 oscillator is that, by adjusting the resistor and the capacitor, I am controlling the time over which each output pin goes high. There are 14 output pins, labelled Q4 to Q14, and Q12 to Q14. These represent place makers in the binary counting system. Conceptually the Q pins correspond to ten places in the following string of 14 places: |0|0|0|0|0|0|0|0|0|0|0|0|0|0|. Each of the 14 binary place markers can be unity or zero. The meaning and significance of each place is relative to the first place marker on the extreme right hand side. The first in the series of place-holders counts the 2s. Each place to the left of the last represents twice the value of the last in base ten. So the location of each 1 or 0 in this 14 character string determines its binary position and its corresponding base ten value eg |1|0|0|0|0|0|0|0|0|0|0|0|0|0| shows 1 in the 14th place from the right. The 14th binary holder represents 16,384 in base ten counting since Power(2,14) is 16,384.


n Q4 corresponds to the place-holder for the 16s. And Q14, as shown immediately above, corresponds to the place for the 16,384s. It follows that if Q4 flips at, say t = 30 secs, then Q14 flips at t = 1,024 times later or at t = 30,720 secs (or after 512 mins). This is because 16,384/16 = 1024. And, as one more example, the Q9 output pin would have flipped at 960 secs (or 16 mins) after Q4 went high. This is because Q9 holds the binary place for the 32s in base ten counting. This means that Q9 flips 32 times later than Q4 at t= 390 seconds after Q4 (since 32*30secs = 390secs).


Calculating the period of the oscillation:

Next is the formula for the frequency of oscillations. My aim is to reconcile my calculations with yours, using the circuit you designed as an example.


In your circuit diagram, the values of R1, R2, R3 and C1 and their configuration at the Pins 9, 10 and 11 and 12 of the IC create an RC oscillator with a given frequency of oscillation. The frequency in units of time determines the speed of the progression of the flip flopping voltage pulsing sequentially across each of the 10 Q pins. In other the counting regime remains unchanged but the units of the time being counted changes by manipulating the parameters of the oscillator. In this way the IC counts in fixed increments of time as represented by the actual period of the oscillation.


For example, the counting increment could be: the number x milliseconds, or the number x seconds, or minutes, or hours. Each successive pin goes high for and at the same time period after the last as the pulse generated by the oscillator moves from each output pin to the next. Each escalating pin in this sequence represents the binary count digit moving sequentially to the left from its neighbour to its right.


The binary counting method outlined above allows calculation of the cumulative elapsed time before any one output pin goes high as well as the time period it takes for that pin to go low. This time can also be represented as the elapsed time from the high on any one pin until the high on any other pin.


Formula for the period of oscillation

From the Fairchild 4060 datasheet you included in Post #54, page 7, the formula for the frequency of the oscillations is:


f=1/(2.2*Rt*Ct)


As per your schematic of Post #54, the values of R and C are:

At mid pot, R=(27k/2 = 13.5k) + 27k = 40.5k. And C is 0.22 micro fareds.


Which Q pin does the time period relate to?

At those values you said that:

With R2 centered, the output period will be approximately 5 minutes. You can change R1 and R2 to get different adjustment ranges. The equation is in the 4060 datasheet.

This begs the question: “5 minutes measured from which Q pin” and whether this target pin is the same as that applying to the formula for f above. So we first have to establish which pin the five minute estimate is meant to be measured from.


The estimate of 5 minutes could apply typically to Q1, Q4 or more likely to Q14. I think its more likely to be Q14 since this is the output pin you’ve chosen to connect to the clock pin (input) of CD4017B.


I am assuming therefore that your words “output period” is measured from the pin at Q14. Next I need to be clear if Q14 is the binary place holder that the formula for f relates to.


On the assumption you estimated the 5 minute mark to be at Q14, and from the above discussion of binary counting and the operation of the Q pins, this would mean that flipping Q14 at t = 5mins (or 300 secs) would imply the following times at Q4 and Q1:


Q4

Q4 would go high at t= 300/1024 or after 0.293 secs. This is because Q4 represents the binary place of the 16,384s. The power would reach Q4 earlier than Q14 by, as explained above, a factor (or more correctly a quotient) of 1,024 (since 1,024=16384/16).


Q1

At Q1 the power spike would occur 4 times earlier than at Q4. This is because as explained above, Q1 represents the first binary place holder which holds the 2s. Therefore a binary one at Q1 means 2 in base ten since 2=POWER(2,1). Using this logic, and the conclusions above, if Q14 fires after 300 secs after Q4; and Q4 fires 0.293 secs after Q1 then Q1 must go high at 0.0181 (rounded to 0.02) seconds from the beginning of the counting cycle.

Target time period
I think it probable that this is the target time period (t=0.02 seconds) in respect of Q4 that the equation for f should estimate (and not the 5 minutes pertaining to Q14) .


What are the units of f?

I am assuming the units for f are a rate, such as beats per second. If so, I cannot see how this converts to a time interval of so many minutes or seconds.


Substituting values into the formula

C= 0.22 micro farads (=2.2E-7 or 0.004009 farads); and

R = 40.5k ohms (=40,500 ohms).

(I assume (as per for example ohms law) the units all need to be factored up into ohms and farads.)


So converting the R and C in the equation into these values from your schematic gives:

f=1/(2.2*40500*0.004009)

= 0.0027995, and rounded to 0.003 oscillations (per second?).

Target timing in secs (t=0.02 secs) vs the calculated period of oscillation (f=0.003 cycles per ?second?)
I am hoping you can square this calculation with the target time period of 0.02 seconds from my workings above.
 

AnalogKid

Joined Aug 1, 2013
12,139
This begs the question: “5 minutes measured from which Q pin” and whether this target pin is the same as that applying to the formula for f above. So we first have to establish which pin the five minute estimate is meant to be measured from.
I will respond to all of this, but I'll have to dip in and out throughout the day. Easy parts first:

1. It doesn't beg the question, it raises the question.
https://en.wikipedia.org/wiki/Begging_the_question

2. Which Q pin? - the only one connected to anything on the schematic.

3. "How the CD4060 counts in binary digits" is correct. Note that not all of the 14 output stages are connected to device pins. This was a compromise in the design of the part. Given a desired maximum timing range and a limited number of output pins, which outputs will most people want most of the time? Q1, Q2, Q3, and Q11 didn't make the team.

ak
 

Raygl

Joined Dec 3, 2016
12
Being that the relay load is 12V AC, I would be tempted to use triacks direcly using an Optp-Isolator.I like the zero crossing optos. They make for smooth switching. Some of you on here may know of problems with triacks and inductive loads. If so please add. I like the MOC3042
 

AnalogKid

Joined Aug 1, 2013
12,139
Calculating the period of the oscillation:
Each successive pin goes high for and at the same time period after the last as the pulse generated by the oscillator moves from each output pin to the next. Each escalating pin in this sequence represents the binary count digit moving sequentially to the left from its neighbour to its right.
It is not exactly clear what you mean, so maybe no. The 4060 is not like the 4017. The outputs of a 4017 look more like a shift register than a counter. Only one output is high at any time, and the high output appears to travel along the output pins, moving one step with each input clock pulse. All high output pulses are the same width.

The 4060 is a true binary counter. Each successive output is running at 1/2 the frequency of the previous stage, but all stages are running at all times. Here is a partial timing diagram for a 4-stage counter that counts on the trailing edge of the input:



ak
 

AnalogKid

Joined Aug 1, 2013
12,139
Being that the relay load is 12V AC, I would be tempted to use triacks direcly using an Optp-Isolator.
The forward voltage drop across a TRIAC is not a problem at 120 Vac, but is a significant percentage at 12 Vac and might affect the ability of the solenoids to pull in.

ak
 

AnalogKid

Joined Aug 1, 2013
12,139
Formula for the period of oscillation
That equation is for the frequency and period of the basic oscillator. It is best viewed at pin 9. This is the input to the string of 14 flipflops. The frequency at Q1 is half of that, the frequency at Q2 is half of Q1, etc. The frequency at Q14 is 1/16384th of the main oscillator frequency. Note that the period at P0 is the time for one complete cycle, one positive half cycle and one negative half cycle combined.

The unit of frequency is Hertz (Hz), what used to be cycles per second (cps). The unit of period is the second (seconds per cycle).
1 Hz correlates to 1 s; 10 Hz => 0.1 s.

Jumping ahead -

Substituting values into the formula
C= 0.22 micro farads (=2.2E-7 or 0.004009 farads)

No. 2.2E-7 = 0.00000022 f

ak
 

AnalogKid

Joined Aug 1, 2013
12,139
Q1
At Q1 the power spike would occur 4 times earlier than at Q4.

No, 8 times. 4-1=3, and 2^3=8.

Also, there is no "power spike". There is a signal that can source a small current in one state and sink a small current in the other state. If you are referring to when the output signal has a leading, positive-going edge, then yes, the first one after a reset happens at Q4 on the 8th cycle of Q1. Referring to the graphic in post #136, B0 and B3 also are three bits apart, and show the high-low relationships among the signals.

"Q1 represents the first binary place holder which holds the 2s."

No, it is the first binary output so it "holds" the 1s. It changes state with every 1 clock cycle. Q4 changes state with every 8 clock cycles (low for the first 8 clock cycles after Reset, then high for the next 8, then low for the next 8...).

What are the units of f?
As above, the unit of frequency is the Hertz (Hz). 6,023 cycles per second is expressed as 6.023 kHz (kilohertz). Period is the inverse of frequency, which makes sense. If there are 4 cycles in one second, each cycle must be 1/4 of a second.

Rerun the equation with the correct value of C.

ak
 
Last edited:

Thread Starter

Mellisa_K

Joined Apr 2, 2017
391
Hello again AK,

Once again its good of you to help me like this. I am indeed fortunate to be tutored by someone as patient and skilled as you. I appreciate the time you're spending on this very much. Your time and commitment is my gain. Your and others' efforts here is making a big difference to my learning which is what I am here for.

Capacitance units of conversion
You've corrected my carelessness converting capacitance of mF to Farads. Thankyou. I think this has made all the difference.

The correct capacitance conversion is:
1mF= POWER(10,-6)*1


So 0.22mF= POWER(10,-6)*0.22 F
= 0.00000022


Formula for the frequency and period of oscillation
I have reworded the formula for the frequency with the correct value of C
f=1/2.2*C*R
Where f is the frequency expressed as cycles per second (Hz)

Substituting for R= 40,500 Ohms; and C= 0.00000022 Farads gives a value for f the frequency as follows:
f = (1/(2.2*40500*0.00000022)) Hz
= 51.0Hz or 51 cycles per second

The period, p, (in seconds) is the inverse of the frequency [f = (1/p) Hz] ;
and the frequency, f, (in Hz) is the inverse of the period [p = (1/f) seconds].

In this case, then, since f = 51 Hz, then p=0.02 seconds.

How the CD4060 counts in binary digits
There are 14 output pins, labelled Q4 to Q14, and Q12 to Q14. These represent place makers in the binary counting system. Conceptually the Q pins correspond to ten places in the following string of 14 places: |0|0|0|0|0|0|0|0|0|0|0|0|0|0|. Each of the 14 binary place markers can be unity or zero. The meaning and significance of each place is relative to the first place marker on the extreme right hand side. The first in the series of place-holders counts the 2s. Each place to the left of the last represents twice the value of the last in base ten. So the location of each 1 or 0 in this 14 character string determines its binary position and its corresponding base ten value eg |1|0|0|0|0|0|0|0|0|0|0|0|0|0| shows 1 in the 14th place from the right. The 14th binary holder represents 16,384 in base ten counting since Power(2,14) is 16,384.

Q4 corresponds to the place-holder for the 16s. And Q14, as shown immediately above, corresponds to the place for the 16,384s. It follows that if Q4 flips at, say t = 30 secs, then Q14 flips at t = 1,024 times later or at t = 30,720 secs (or after 512 mins). This is because 16,384/16 = 1024. And, as one more example, the Q9 output pin would have flipped at 960 secs (or 16 mins) after Q4 went high. This is because Q9 holds the binary place for the 32s in base ten counting. This means that Q9 flips 32 times later than Q4 at t= 390 seconds after Q4 (since 32*30secs = 390secs).

The following table shows the multiplicative factors for each of the 10 Q-pins on the CD4060

upload_2017-5-8_19-8-14.png

If we know the oscillator period is 0.02 seconds, then Q14 will go high after this period by a factor of 16,384 times; or after 321.2 seconds (since 0.02*16,384=321 seconds). This is equivalent to 5.4 minutes (since 5.4=321secs/60).

AK, your estimate appears to be confirmed!!
 
Top