# Use a 4060 to divide by 256?

#### frankpc

Joined Jul 25, 2010
41
I need a divide by 256 circuit. The input frequency will be around 600 Hz. The input will come from a slotted opto isolator. The output will have to drive a small electro magnet that I will place a reverse biased diode across. Not sure how much current I will need, but i have to pick up a reed switch in a existing sensor. To maintain the warranty of the sensor, I have to utilize its internal reed switch for activation rather than to bypass the reed switch.

I didn't want to use a clock for the counter.

I think the 4060 would work, but I'm not real sure if it will survive the back emf from the electromagnet. And I don't know whether there might be an inexpensive IC that is more appropriate. If I had to, I could use a driver external to the 4060. But I'd rather not if possible.

Thank you.

#### t06afre

Joined May 11, 2009
5,934
Take a look at this data sheet fig3. http://www.doctronics.co.uk/pdf_files/HEF4060B.pdf
After each Flip-flop. The frequency is dived by 2. So on pin 14 you will have the frequency divided by 2^8 or 256. I have seen other naming for the outputs on other data sheets. They name the pins q4 and up. But still pin 14 will be correct. And pin 11 will be the input. If your input pulses are compatible with the 4060 chip. You should be OK

#### SgtWookie

Joined Jul 17, 2007
22,221
You should use a transistor like a 2N2222 to drive the electromagnet (or a more capable one, depending on the current the electromagnet requires). The electromagnet should have a diode across it in reverse polarity to take care of the reverse EMF when the current through the electromagnet is turned off.

It would help us to help you if you gave us some more information, like what voltage are you planning on using to supply the IC and electromagnet with?

#### frankpc

Joined Jul 25, 2010
41
Thank you for the help folks.

I ordered some 4020's since I don't need the oscillator and I found them pretty cheap. Glad T06 agreed with the use of that series cmos chips. Also I ordered some 2n2222's since I read that the cmos cannot drive anything requiring more than a little current. Glad the Sgt. confirmed that. Also ordered some slotted opto switches.

As far as voltage is concerned, probably around 9 volts will work. But I haven't messed with the electromagnets before. Any ideas to start with would be good... like 12" or 48" (?). I assume some 24 - 26 gauge enameled wire around a 16 penny nail. I don't know how much magnetism the reed switch will require. So I am totally in the dark there. It would seem the DC resistance of the wire will be pretty low and not sure just how much current it will require. The reed switch is enclosed in plastic so I have no idea what it looks like. Actually I am assuming it is a reed switch since its state is changed when a magnet passes by.

Thanks for the support with this.

Frank

#### SgtWookie

Joined Jul 17, 2007
22,221
Rather than attempting to make your own electromagnet, I suggest that you instead cannibalize a relay or solenoid for its' coil. Automotive relays are pretty inexpensive and available at any auto parts store - or junkyard/breakers.

Such devices use a particular type of silicon steel for a core that won't permanently magnetize like a nail would. Nails make rather poor electromagnet cores.

The strength of an electromagnet is related to its' ampere-turns; how many turns of magnet wire you have wrapped around the core, and how much current is passed through the winding. A reed switch won't require a really strong field to activate it. However, you would need to use a very fine gauge wire in order to keep the resistance fairly high, or you would need a LOT of current to drive the electromagnet.
AWG-24 (IEC 0.5mm) has a resistance of 25.67 Ohms per 1000 feet.
AWG-26 (IEC 0.4mm) has a resistance of 40.81 Ohms per 1000 feet.

A typical automotive relay might have a coil resistance of 400 Ohms. If you wound a core with AWG-26 to get that resistance, you would need 9,801 feet of wire, and a forklift to carry it around with!

As you might now imagine, automotive relay coils are wound with many turns of a very fine gauge of wire; so fine that it's difficult for a person to try winding one by hand, as you would wind up breaking the wire very frequently.

For example, AWG-46 (IEC 0.04mm) wire is 4,196 Ohms per 1000 feet, so you'd need just 95.33 feet of it. However, just one OUNCE of copper made into AWG-46 wire would be nearly 1-1/2 statute miles (~2.4km) long! AWG-46 is 0.00157" / 0.0399mm in diameter, which is roughly 1/2 to 2/3 the diameter of a typical human hair - but not as strong as hair.

Since you mentioned 9v, it sounds like you might be considering operating the circuit from a 9v "transistor" PP3 battery. The CMOS 4020 IC will run fine for a very long time on one of those batteries, but a relay coil will drain it rather quickly.

Once you decide what you will actually use for an electromagnet and measure its' resistance, let us know what it is and what you are considering using for a power supply, and we will help you figure out what to use as a base current limiting resistor between the output of the 4020 and the base of the transistor.

Last edited:

#### frankpc

Joined Jul 25, 2010
41

I'll find an existing relay and use the coil and core from it. I've noticed the fine wire and lots of turns before. All you've stated makes sense. Since we're on the subject, any chance the wire from a speaker coil would work? Not sure what would be used for the core. But an existing relay makes much more sense since it would be ready to go.

This project does have access to 110 VAC. I just mentioned 9v because I knew it had to be between 3 and 15 vdc. And I do have some small power supplies that are around 9 volts. They aren't well regulated, but I figure that won't matter a lot as long as the voltage doesn't drop too much during the period the magnet is energized. Perhaps the period of the pulse might not be long enough. May have to use something like a 555..... I wonder if a 555 would be able to drive the magnet rather than the 2n2222 (?)

I'll look around for a relay. Again, thanks for the detailed help.

Frank

#### SgtWookie

Joined Jul 17, 2007
22,221
I'll find an existing relay and use the coil and core from it. I've noticed the fine wire and lots of turns before.
You can experiment with other ideas as much as you like, but you should find that cannibalization of an auto relay is relatively cheap, easy, and effective. The hardest part will be removing the plastic case without damaging anything inside. You might wreck one or two in the process, but the first one will show you how they're constructed inside; then you'll know where to cut. A fine bladed hacksaw is a likely candidate for a tool to slice through the plastic case at the base. Easy does it. A small vice to hold the relay will be a big help.
Since we're on the subject, any chance the wire from a speaker coil would work?
Most typical speakers are rated for either 4 or 8 Ohms at 1kHz. Their resistance to DC is very low. If you had a great big pile of speakers you wanted to salvage wire from, I suppose you could use the wire - but why work that hard, when a relay coil is so easy?

This project does have access to 110 VAC. I just mentioned 9v because I knew it had to be between 3 and 15 vdc. And I do have some small power supplies that are around 9 volts. They aren't well regulated, but I figure that won't matter a lot as long as the voltage doesn't drop too much during the period the magnet is energized. Perhaps the period of the pulse might not be long enough. May have to use something like a 555..... I wonder if a 555 would be able to drive the magnet rather than the 2n2222 (?)
A 555 can be used to drive a 2N2222 transistors' base. It's better to do that, than to try to directly drive an inductor from a 555's output; as if the transistor gets "zapped" it's easier and cheaper to replace than a 555.

A 9v unregulated supply would be OK to use, but you should use a 12 Zener across the output to make sure that spikes from the line won't kill your circuit. Radio Shack sells 12v Zeners, along with a 15-pack of NPN transistors that generally contains five 2N2222's - and LM555 timers.

#### frankpc

Joined Jul 25, 2010
41
Thanks Sgt.

I'll take your advice regarding the spike protection. I have some 1 amp 12 volt regulators. One of those along with a couple of caps should protect the circuit. I believe I have some 12 volt and 15 volt power supplies lying around. I could easily use one of those.

Let's just forget about the speaker coil idea.

Also, I will plan to use the 2n2222 to drive the magnet. In that case, I'll hold off on the 555 until I prove that it will be needed. If my calculations are correct, there could be 2.5 pulses per second maximum. If you think the hold up and release time could be a factor, I will figure the duration of the pulse. I just don't know how quickly the field will collapse.

Thanks again for the help.

Frank

edit: The resulting pulse could be about 2 ms in width if left untreated. Perhaps too short? Perhaps I could make it somewhere around 150 to 200 ms for a 50% duty cycle at the highest frequency using the 555.

Last edited:

#### SgtWookie

Joined Jul 17, 2007
22,221
Hmm. A pulse that short might be too short to let the current in the coil build up to create a strong enough field.

You'll probably need a 555 in monostable multivibrator mode. You will also probably need a method to kill the current flow quickly; that can be done using a Zener (say, 5.1v) and a 1N914/1N4148 back to back across the coil.

If your frequency will be as high as 2.5Hz, then that's 400mS per complete cycle, so 200mS would be a good pulsewidth to shoot for. If you might have a higher frequency, then you'll need to decrease the pulsewidth.

#### frankpc

Joined Jul 25, 2010
41
Yep. The frequency cannot go above 2.5. And, more typically, it will be at about 1.5 or lower. So 200 ms would be a nice value.

And insofar as the protection diodes are concerned, I believe you are saying to use a standard diode reverse biased across the coil and then a zener of a value greater than the voltage of the coil such that it will conduct when its value is exceeded.

I hadn't heard of putting two across like that, but it sounds reasonable to shunt the spikes both ways. It just seems that only one direction is typically protected.

Now, i just need some parts to breadboard this thing.

Thanks,
Frank

#### SgtWookie

Joined Jul 17, 2007
22,221
A 1N914/1N4148 switching diode works well for the flywheel diode; they are extremely fast. You really don't want a slow or unspecified speed diode like a 1N400x series.

But for the Zener, use a 5.1v or less - or you can also use a fairly low-value resistor.

Whatever your coil current will be, use a resistor that will drop somewhere around 3v when that amount of current is flowing through it. For example, if the coil will have 50mA current, then 3/50mA = 60 Ohms. 62 Ohms is a standard value; so is 56, 51, 47, and in the other direction, 68, 75, 82, etc. You don't want the resistor too large, or you can exceed the base-emitter breakdown voltage of the transistor, which will permanently reduce it's gain. All you want to do is to stop the current flow through the coil quickly, and at the same time not have a big reverse voltage spike.

#### frankpc

Joined Jul 25, 2010
41
Sgt...

just to ensure I understand: In your example, if I was using a 100 ohm coil at 5 volts, and therefore it drew 50 ma, I would place a reversed biased 1N914 across it along with a ~60 ohm resistor in parallel. Or would the resistor be in series with the parallel network of the coil and diode?

Is there a common/standard program you guys use to create schematics?

#### SgtWookie

Joined Jul 17, 2007
22,221
LTSpice has been very convenient for drawing schematics and performing LTSpice simulations. It's available for a free download at Linear Technology's site.

There is also the LTSpice Users' Group on Yahoo! Groups. You should sign up for the group, as there are plenty of PSPICE models available. You'd want the CD4000 library and symbols for starters.

Cadsoft's Eagle is a good & powerful schematic capture and PCB tool, if you're interested in that. It's available in a freeware version for hobbyists/students where you can make up to a 2-layer and 3"x 4" board.

There is also ExpressSCH/ExpressPCB, DipTrace, TinyCad, and a number of other programs available in freeware/hobbyist mode. LTSpice has no size limit for circuit simulation, and comes with a fairly decent library of its' own.

As far as my example, if you were using a 100 Ohm coil at 5v so that it drew 50mA, you would place a reverse biased diode and ~60 Ohm resistor in series, then that series network in parallel with the coil.

#### frankpc

Joined Jul 25, 2010
41
I've installed LTSpice and have opened a 4020 into a new schematic. I am currently attempting to paste other components into the schematic, but can't seem to figure out how to do that simple task. I've watched two tutorials, but they just explain how to place discreet componets into a page. But even those components are dimmed when the 4020 schematic page is selected.

It looks like a great program with simulation and all. I've watched some analog simulation with waveforms.

Work continues...

#### SgtWookie

Joined Jul 17, 2007
22,221
I'll bet that you are trying to add other parts to the symbol file (.asy) instead of a schematic (.asc). You can't do that. The symbol editor is for the creation and editing/revision of symbols, not schematics.

Take a look at the name of your current file; it's in the upper left-hand corner of the window. If it ends in .asc, then you're in a schematic.

There is a menu bar that has some generic parts, like resistors, caps, inductors, diodes - and then there is what looks like an AND gate. That's where all of the other parts are.

In order to use the CD4000 parts, you need to include a SPICE directive in your schematic. On the far right of the menu bar, you'll see '.op'. Click that, and type:
Rich (BB code):
.lib cd4000.lib
into the box, and click OK.

#### frankpc

Joined Jul 25, 2010
41
OK. Thanks Sgt. I'll look for those things.

I appreciate the help. I know that once I figure it out, it'll be a lot nicer than drawing by hand.

Frank

#### SgtWookie

Joined Jul 17, 2007
22,221

#### frankpc

Joined Jul 25, 2010
41
Sgt...

Thanks for the help with LTSpice. It works perfectly. I was just wanting a program to help draw schematics. I didn't know there was such a thing as circuit simulation. It's amazing!

I am attaching the asc file below in case you care to point out design issues. Not sure which libraries I used that you wouldn't have.

I used a couple of pulse sources to drive opto isolators to simulate the slotted opto isolators that I will actually use. I used relays in the output to simulate the coils and reed switches.

Again, thanks for the help. I am waiting for parts to show up.

Frank

#### Attachments

• 7.4 KB Views: 17
Last edited: