Electronics Dopers: Timebase from 60Hz power. How?

I’m thinking of building a power supply for breadboarding purposes. I want to take a signal tap from the 60Hz AC between the stepdown transformer and the bridge rectifier, and turn it into a TTL level clock signal. I want the clock pulse to be no more than about 10-15 milliseconds wide, but I would prefer it to be 1 ms or less, as long as it’s still within TTL specs. I intend to run that 60Hz clock through a divide-by-6 counter to get a 10Hz output, then a divide-by-10 to get a 1 second clock, too, so that I have three clock signals available: 60Hz, 10Hz, and 1Hz.

I haven’t decided what voltage I’m going to use for the transformer. I’m leaning toward something above 15v, so I can have regulated 15 & 12 volt outputs, as well as a 5v, but my primary use for the power supply is a Basic Stamp development board that uses a 9v battery, so 9v unregulated can power that, and still give me 5v regulated. I’ll take that, if that’s what will give me 9v for the board, plus the clocks for whatever I’m designing*****. The higher regulated voltages are optional. The clock signals aren’t.

Ideas on actual circuits, or links to webpages that describe how to turn AC into narrow TTL level DC pulses are welcome.

*****Current project is a rechargeable battery (AA and AAA) tester. Charge the battery, put it in the tester, which will discharge it through a standard resistor, and time how long it takes to discharge to a ‘low battery’ level. I need a reliable timebase for that. Basic Stamp (from what I can see, RTFM) uses a temperature-uncompensated RC circuit for it’s clock, so you will get a different result, from the same battery, on a 90 degree day vs. a 70 degree day. Not good. Need reliable timebase. If I’m wrong about the unreliable accuracy of Basic Stamp clocks, hints on timing in Basic Stamp programs are also welcome.

Attach a resistor and zener diode to the 15V AC and you’ll get a clamped squarish sort of wave at 60 Hz. Run that into a Schmitt triggered gate of some sort (I used to use inverters since they were cheap) and you’ll square it up nicely into a clock signal. You can then run this into a counter to generate your various clocks. You can then use more logic to create shorter pulses if desired.

The AC frequency is guaranteed in the long term, but not in the short term. Clocks based on AC main frequency timing tend to run a bit slow during the day and catch up at night.

I haven’t taken too close of a look at the Basic Stamp circuits they sell these days, but every microcontroller circuit I ever designed used a crystal to generate the microcontroller’s clock. As long as you use a decent crystal you can get accuracy that is much better than what you get from the AC line. I didn’t hunt down a schematic for the Basic Stamp that you linked to, but I do see a 20 MHz crystal in the picture of the board. I would be very surprised if that wasn’t used for the microcontroller clock.

Run it through a largish resistor and series capacitor, then clamp the high level with a zener, and the low level with a Schottky diode. The low forward drop of the Schottky will insure that the low will not turn on the body diode of your logic and cause latchup, and will also prevent forward biasing the zener, which is not great. Vz should be a volt or so lower than your logic supply rail. Clamp the signal to the supply rail with a second Schottky as insurance, and to prevent latchup at power-on. Run this through a Schmidt trigger for a bit of line noise rejection. This will give you an approximately 50% duty cycle. If you really need narrower pulses, then you could use a one shot. You may be able to find a one-shot with a Schmidt trigger on the input and kill two birds with one stone.

ETA, I been Ninjaed!

I used to use a single 7400 quad nand to produce a square wave, but I’d have to look for a schematic now. The same thing was used on a lot of early microcomputers. Not sure how well it work with such a slow clock rate. Basically, you’re signal goes into both inputs of the first gate to get the curve out, then the output is fed to the next gate to invert it, and the original signal and the output of the second gate go through the 3rd gate to get the signal squared. And I forget if it can be further tuned using the fourth gate. Man, this goes back in time, it was probably 30 years ago the last time I looked at this. A friends computer kept freezing after it got warm. I poked around with a scope and found the clock signal got all fuzzy, traced it back and saw the clock running through a 7400, replaced that, and all was well.

My experience has been that just clipping the AC signal from a transformer tends to make a clock that runs a bit fast, due to noise at zero-crossing. Even using a Schmitt trigger doesn’t eliminate the problem. A better solution is to use a comparator and set the trigger at 50% of the peak voltage.

Thanks for the replies, all. One of those is bound to be usable. Just one question… How do I ensure that the output is TTL logic compatible. I don’t want to fry anything, and I sometimes use a supply of 30-40 yr old TTL chips I’ve had since I was a kid when breadboarding.

Just make sure the output never goes above Vcc and also doesn’t swing below ground and you’ll be OK. If you are worried, you can put a Zener on the input.

A zener diode ought to take care of it. If you’re worried, switch the output with a transistor. And I do the same thing, just use old chips that are around. I end up pulling them off of old projects to use again.

Why? A basic comparator circuit doesn’t have any hysteresis, so you will have more, not less, noise than with a Schmitt trigger (as shown here), especially if you use a CMOS version, which has a larger hysteresis (such as a 74HC14; there isn’t really any reason to use 30-4o year old 7400 TTL anymore unless you don’t have a CMOS version handy). To be safe, you can also add a capacitor at the input to ground to filter out noise.

Also, to generate a narrower pulse, you can use another Schmitt trigger inverter and an RC network at the input (capacitor to output of first inverter and resistor to power or ground, depending on desired pulse polarity, connecting to power will give a high going pulse and vice-versa).

I guess I should have said comparator with Hysteresis, like this:

Why do you do that? For what I do it wouldn’t be that practical at all, since I use chips literally by the hundred and parts by the thousand, and do point-point wiring on perfboard with hot-melt glue used to hold parts and wires down (I design things to last, I still have stuff I made almost 20 years ago). Even with actual PCBs, it isn’t exactly easy to remove chips (I put the board on a heating element to melt the solder, after removing other parts and stuff that could melt). Of course sockets can make it easy to remove chips, but they often cost more than the chips themselves, which makes a big difference when you buy $400 worth of parts (plus those that I remove from discarded electronics).

I use 'em because I have 'em. I don’t want to buy more until I need 'em.

As for the rest of your post, Noted, and thanks.

Re: old TTL vs new CMOS, CMOS can handle TTL signals, but not vice verse. I pretty much design all my things to TTL standards, for that reason. So do computer OEMs. Much of the logic on a PCI bus is to the TTL standard. So’s everything on an S100 bus. You can’t go wrong sticking to the TTL standard. So I do.

That’s just asking for trouble, these days.
More and more components (especially microcontrollers) are only available in 3.3v (or lower) voltages. Often, these parts won’t have 5v-tolerant inputs. Designing with 40 year old technology for your random logic is just making your life difficult.

That isn’t really true; if they run of the same supply voltage, you can go either way, although to interface TTL to CMOS you may need to add a pull-up resistor (since the TTL logic high output may be as low as 3 V). Of course, there is also CMOS that is designed to have TTL logic input levels; the majority of logic nowadays is CMOS due to speed and power (also hard to really make anything complex with TTL, as bipolar transistors are limited to the micron range), regardless of what the input logic levels are. There is also the cost issue; for example, a 74HC595 ($0.42 for one and $0.29 each for 100) costs far less than a 74LS595 ($10.69 for one and $8.79 for 100); both of these are the cheapest versions I could find in a DIP package, but even the cheapest 74LS595 in a SMT package is only slightly less, at $10.40 for one; now imagine buying 500 of those as I did once, which would cost $145 for the HC version and $4,395(!!!) for the TTL version (I bought them as column drivers for a LED dot matrix display built up from many smaller displays, which is also easier with CMOS since if you supply around 3 volts, about 20 mA of current will flow through an LED connected with no series resistor; TTL either won’t work at 5 volts or will waste too much power).

That said, like you, I will use TTL if I don’t have a CMOS version handy, usually something that I don’t use many of, thus don’t buy them (most of what I buy are buffers, latches and similar functions).

That depends on what you are doing though, and there still are plenty of things that run off of 5 volts (of course, most CMOS can run off of lower voltages, even the old 4000 series, albeit at very low speeds, although it is useful if you need a higher voltage, like when I make my own switchmode power supply controllers, rather than using commercial chips). Some logic families are also made without internal protection diodes to power so you can input a voltage higher than the supply voltage, which is useful when converting to a lower logic voltage (why use a higher voltage at all? CMOS is faster at higher voltages, the same reason people overvolt their computer CPUs when overclocking, or if you make a video signal generator out of discrete logic and memory chips like I do).

Also, Cheshire Human, why do you need a narrow pulse, since it sounds as if you just need the 1 Hz signal, which will be a (near) square wave after being divided down (depending on what counter you use); the last time I used a microcontroller to read a clock signal for timing, I wrote the routine so it would only trigger on a state change, not just checking for a logic high, like this example:

      if(TC == 0){
        // TimebaseClock is a port pin connected to 1 Hz timebase signal
        if(TimebaseClock == 1){
          TC = 1;
          // Increment counter on logic low-high transition
        if(TimebaseClock == 0){
          TC = 0;
          // Put code here if you want to trigger on logic high-low transition

Note that the pulse width, either logic low or high, has to be larger than the interval between reads on the port or it will drop pulses (e.g. if 1 ms between reads, maximum frequency is 500 Hz). Of course, you can also use an interrupt, but sometimes you don’t want to be interrupted (pardon the pun), like if you are also refreshing a display and the interrupt routine takes too long to avoid flicker.

I have tons of sockets, and stuff i build from scratch is usually wire wrapped in sockets, and I usually stick discreet components into the sockets also. So removing components is easy. And why? Because I hardly do anything with hardware anymore. My bench isn’t set up, and now I just fool around with things when I get curious, so it’s not worth ordering up a bunch of stuff. Back in the day, I was stocked to the gills, everything in parts cabinets, neatly labeled. The local supply houses would *call me *when someone needed a part.

And most of those are either a) SMC, which I can’t deal with, or b) a heluvalot more complex than anything I’ll ever be able to design something to use. So really, designing to a 40 year old standard just means I’m designing to a standard that I can do without looking up specs every time, And can buy cheap components for. The Basic Stamp, which I mentioned in the OP, uses TTL spec. And that’s about my speed. I could, if I really had to, design something that uses an 8080 or 6502 processor, but those are both far beyond anything I’ve ever done, and also use TTL spec, anyway. So does USB. And, of course, so does anything that uses RS232. It hasn’t been abandoned, by any means.

Feel free to show me how a 3.3v RS232 or USB connection might even work, if you really think 3.3v matters.

Designing to modern standards that I would have to learn, and get SMC tools, would make my life more difficult than sticking to what I know. I’m not a professional.

Gimme a break. I’m a moronic old fart hobbyist. I don’t do it for a living.

Here you go:

Umm… OK.

Shit. I hate it when I have to learn a new spec.