The All-Discrete Heavy Duty Square Wave Generator - Page 1
Forum section: electronics / projects

author: GreggTech
author_rank: Contributor
timestamp: October 30, 2024, 08:17:21 pm
content: I wonder if this would work for a solid low frequency. I may use this for an all-discrete digital clock and other things. Might just be cool on its own.

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 12:29:37 am
content: Why so complicated? Isn't that basically just an astable multivibrator?

author: GreggTech
author_rank: Contributor
timestamp: October 31, 2024, 02:56:54 am
content: Isn’t the traditional astable kinda unstable and unpredictable? This should always start right away and be more controlled with a clean output.

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 03:09:09 am
content: Unstable and unpredictable? Not necessarily. You might want to readthis articleon the subject, using BJTs; he shows several variations of the astable multivibrator. Like this one:28 MOSFETs seems a little like overkill to me*. Where did you find that circuit?*Unless that's the schematic of an IC (but can't be, not with those caps).

author: GreggTech
author_rank: Contributor
timestamp: October 31, 2024, 03:35:56 am
content: Yeah I’ve seen a couple different schematics for it. It’s a bit boring though haha. I’m not worried about being efficient…make it big. This is my own schematic, just finished today.

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 03:37:58 am
content: So how does that work?

author: GreggTech
author_rank: Contributor
timestamp: October 31, 2024, 04:08:07 am
content: So there’s 4 latches. Left to right, the first latch charges up and turns on, bringing the output high. That causes the second latch to charge up and turn on, which resets the first latch, which brings the output low. With the second latch on, the third begins to charge up and turn on, which brings the output high again. That causes the fourth latch to charge up and turn on, which resets the second and third latches, bringing the output low. Now the first latch can charge up and turn on again, bringing the output high and resetting the fourth latch. The output is an OR gate connected to the first and third latches.I also just realized the second latch divides the frequency by 2.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 31, 2024, 04:15:59 am
content: Quote from: GreggTech on October 31, 2024, 02:56:54 amThat depends very much on how you design it.It does not need to be anything like that complex to have low element errors, in fact,the fewer parts the better.It is tough to find capacitors with better than 1% tolerance, so a design would try to use the lowest number - ieONE.Resistors sub 1% are more common, (0.1% are practical & even 0.05% in low ppm/K ), but again you try to use the lowest number.AVX says this :C0G (NP0) ceramics offer one of the most stable capacitor dielectrics available. Capacitance change with temperature is 0 ±30ppm/°C which is less than ±0.3% C from -55°C to +125°C. Capacitance drift or hysteresis for C0G (NP0) ceramics is negligible at less than ±0.05% versus up to ±2% for films. Typical capacitance change with life is less than ±0.1% for C0G (NP0), one-fifth that shown by most other dielectrics.NPO CAPs are limited to below ~ 100nFQuote from: GreggTech on October 30, 2024, 08:17:21 pmWhat frequency, precision and stability do you expect to need for thisdigital clock?Even if you manually trim this, the AVX info saysTypical capacitance change with life is less than ±0.1% for C0G (NP0)

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 04:27:54 am
content: If you want to use something like your design, seems like you should be able to get it down to just two latches in a cross-coupled arrangement (like the traditional astable) and get rid of those other pieces. Probably make it more stable and accurate that way.

author: schmitt trigger
author_rank: Super Contributor
timestamp: October 31, 2024, 02:38:19 pm
content: I understand and appreciate the fact that you would like to design and build an unconventional and difficult clock generator. Like George Mallory said about his motivation for scaling the Everest: Because it is there.But like others have already pointed out, the results will be disappointing for the simple reason that the timing components have wide tolerances and tempcos. The frequency accuracy and stability will be anything but “solid”.There is a reason crystals are used as timing components. You want a challenge? Use a common 32.768Khz tuning fork oscillator as your timebase and design the discrete divider chain.

author: GreggTech
author_rank: Contributor
timestamp: October 31, 2024, 03:01:50 pm
content: Yep, I understand about the tolerances. I was planning on having a cal pot or two, and maybe a display to show the frequency. Big ambitions lol. I was thinking 10 Hz to display tenths of a second. Now I'm thinking I might just build it for fun on its own and see what the results are because I think it's cool. And use a more standard circuit for the clock, if I ever get back around to it.I tried building a circuit around a 32.768 Khz oscillator and could only get any kind of oscillation when I touch it or around it, haha. And I don't think it was even the right frequency - pretty sure it was just the inverter oscillating at some random frequency. Maybe I'll post the circuit I was using in another topic to get some feedback on it.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: October 31, 2024, 07:47:06 pm
content: Looks a lot like a ring oscillator. You can make a ring oscillator by chaining together an odd number of logic inverters. A ring oscillator can be easily built on a breadboard. No other parts required, although a power rail decoupling capacitor is still recommended. If you also build one on perf board, or simply dead bug style, you can see the effect of the breadboard capacitance slowing the thing down. With some extra RC combinations you can slow it further down.For the rest, I fail to see the goal of this exercise. RC based circuits are never going to be very stable (1% over a decent temperature is a sort of ball park figure)Using a few NE555 (if you want to adjust frequency & pulse width separately) seems more practial approach, but practicality (or usability?) is apparently not the goal here.

author: GreggTech
author_rank: Contributor
timestamp: October 31, 2024, 08:38:24 pm
content: Yes I have played around with ring oscillators. This is really just for hobbyist fun - not for a commercial product or anything like that. Not for practicality. Just something fun to look at with a modest amount of precision. Perhaps I should have taken out the word "solid" haha.

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 08:42:19 pm
content: I appreciate your hobbyist approach here. Pretty much mine too.1. For any kind of clock, it seems like you really want/need to use a crystal if you want any kind of accuracy.2. If you're going to go down the road of your homebrew design (which is impressive, if a bit clunky and overdone), I'd still really like to see what you can do with just two of those latches toggling each other. Intuitively it would seem that that arrangement would be much more accurate than what you have, since each stage can add its own bobbles to the final signal. Who knows? you might be able to tune it reasonably well to use as a clock base.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: October 31, 2024, 09:04:06 pm
content: Quote from: GreggTech on October 31, 2024, 03:01:50 pmThat's why you need to define what accuracy is acceptable to you, before you start.eg 1 minute per day, is about 0.07% - is that good enough for you ?1 Second per day is about 11.6ppm, outside the reach of RC circuits, and even pushing 32Khz tuning fork crystals.Quote from: GreggTech on October 31, 2024, 03:01:50 pmAlways a good idea to test an idea.Quote from: GreggTech on October 31, 2024, 03:01:50 pm32kHz should be simple. There are many CMOS parts like 4060/4521/4541/AHC1G4215 etc that can oscillate and divide for you.Quote from: GreggTech on October 31, 2024, 03:01:50 pmFrom AC mains, 10Hz is simple, from 32.768kHz that's more of a problem. It can be done, but you need to divide by 3276.8.In practical terms that means alternating /3277/3277/3277/3277/3276 to average an exact /3276.800Easy on any small MCU, not so simple in discrete parts.

author: Analog Kid
author_rank: Super Contributor
timestamp: October 31, 2024, 09:27:29 pm
content: I discovered, when trying to design a device to generate an accurate 60 Hz wave, that a 4.9152 MHz crystal (easily available) will divide neatly down to that (divide by 10, then by powers of 2).

author: GreggTech
author_rank: Contributor
timestamp: November 02, 2024, 06:04:00 pm
content: Quote from: Analog Kid on October 31, 2024, 08:42:19 pmIdk if I'm big-brained enough for it to be anything but that lol. But yes I'd like to revisit the crystal circuit at some point. Would be great to get it working.Quote from: Analog Kid on October 31, 2024, 08:42:19 pmYeah I'd have to go back to the drawing board to figure out how to get two of the latches designed this way to toggle reliably. But I know what you mean. I also have a discrete master-slave T-flip flop design with diodes and FETs that maybe I could modify to be free-running.Quote from: Analog Kid on October 31, 2024, 09:27:29 pmOh yeah, divide by 10 then 2^13. Nice.Quote from: PCB.Wiz on October 31, 2024, 09:04:06 pm1 minute per day would be good enough. I think it would just be fun to look at and set the time.Quote from: PCB.Wiz on October 31, 2024, 09:04:06 pmAh yes, but that'd be cheating. I'd like it to be all-discrete and unconventional. In the crystal circuit, I was using a PMOS/NMOS totem pole for the inverter (BS250P/2N7000), then another one on the output as a buffer.Quote from: PCB.Wiz on October 31, 2024, 09:04:06 pm10Hz would indeed be challenging from a crystal with discrete parts. I may just do seconds. Didn't really want to mess with the mains, but I agree it'd be easier. Leo's Bag of Tricks on YouTube did a nice discrete digital clock using the mains.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 02, 2024, 07:40:05 pm
content: Quote from: GreggTech on November 02, 2024, 06:04:00 pmI posted a variant of a PNP/NPN pair 32kHz oscillator, that is very forgiving, and gives a good output swing.see :https://www.eevblog.com/forum/projects/looking-for-transistor-based-32khz-quartz-test-circuit/msg5652417/#msg5652417Quote from: GreggTech on November 02, 2024, 06:04:00 pmTo get even 1 minute a day, you need low bias currents and low temperature drift.It might be ballpark doable with IC's like low noise opamps or a precision ALD555 (not cheap, but good ppm/K), but using discrete parts you would be forever chasing your tail.Setting the timeis a whole different ball game !Quote from: GreggTechUnderstood, but you can consider SOT23 sized packages pretty much discrete ? .... A clock built entirely of SOT23 sized packages is certainly unconventional !

author: Andy Chee
author_rank: Super Contributor
timestamp: November 02, 2024, 08:38:20 pm
content: Quote from: PCB.Wiz on November 02, 2024, 07:40:05 pmI figure you could just manually press a push button to switch the clock signal from 32kHz to, say, 1MHz. Then release the push button once the clock has arrived at the correct time setting.

author: ArdWar
author_rank: Frequent Contributor
timestamp: November 03, 2024, 02:49:39 am
content: You guys talking about 1% capacitor tolerances when the whole circuit trigger point is at the mercy of whatever VGS(TH)each FET happen to be? Did I miss something here?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 03, 2024, 03:04:14 am
content: Quote from: ArdWar on November 03, 2024, 02:49:39 amOf course, the capacitor tolerance and drift discussion applies to a far better circuit design.Differential circuits and OpAmps / Comparators can remove Vbe or Vgs effects, leaving just some constant * R * C, as the primary equation.Good timing parts can get as low as 10ppm/'C, in the active element.

author: GreggTech
author_rank: Contributor
timestamp: November 03, 2024, 04:31:23 am
content: Quote from: PCB.Wiz on November 02, 2024, 07:40:05 pmCool, thanks - looks similar to mine, just with BJTs and biasing components. I'll have to give it a try.Quote from: PCB.Wiz on October 31, 2024, 09:04:06 pmDo you think I'd get a min/day using something like your 32.768 Khz crystal circuit? It really doesn't matter to me that much - just getting something working that has the appearance of keeping time is good enough for me. I may try to build the square wave generator monstrosity I came up with just for fun with some LEDs and pot controls to display on its own if it works reasonably well.For setting the time, I have a circuit design that would theoretically cut off the oscillator output with a FET (not stopping the oscillator), enable a line that manually toggles the counters, and use an SR latch to toggle another line that determines the counter direction based on if a rotary encoder is turned clockwise or counterclockwise. Some LED indicators for all of that too.You guys have given me some great feedback and resources to look into - thanks! Will share some updates if I manage to get something physically built and working.

author: ArdWar
author_rank: Frequent Contributor
timestamp: November 03, 2024, 05:03:58 am
content: Properly driven 32kHz xtal should easily give you ~1min/month, provided you aren't too crazy with ambient temperature swing.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 03, 2024, 05:09:33 am
content: Quote from: GreggTech on November 03, 2024, 04:31:23 amEasily.A 32.768kHz crystal will get you into the single digit seconds per day ballpark.Do you have a means to measure frequency accurately ?If you can get your hands on a SN74LV8154 (DIP20 or TSSOP20) and borrow a GPS with 1pps, you can check your trim.Every 1 second resolves to ~30ppm, from 32.768, and if you reset and then take a picture of the 8 LEDs after 61 seconds, the LSB is ~ 0.5ppm