Sunday, 30 April 2017

Clock design log #1 - analogue board

Finally, some real meat! Construction-ish posts. I'll be breaking things up in to two posts from here on. First will be a "design log" where I will talk about the immediate design task and run through its constituent parts, and also provide design files like schematics and what not. Second will be a "build log" where I will build what I just wrote about, and post photos and discuss any troubleshooting etc that I had to do to make it work.

The first board that I'll be building is what I am referring to as the "analogue board". I call it that because it has the most amount of "analogue" electronics on it.

So lets get stuck in to it.

Power supply

I'm designing my clock to work off 9V DC, and the power supply is pretty basic really - it's your bog standard linear regulator circuit, and is mostly a kludge of what ever reference design(s) I could find on-line plus a few suggestions that I've seen thrown around at times. It uses a 7809 linear voltage regulator, a smoothing capacitor for the input side, and a full bridge rectifier - because just like an amp that doesn't go to 11, anything less than a full bridge just isn't worth it.

The power source will be 12V AC from a wall adapter, and it is important to note that a power adapter that outputs AC is essential, as the AC is used to create the most fundamental timing signal within the clock since I'm not using any form of local oscillator.

AC_CLK/ generator

This is a circuit used to generate a clock signal which I call AC_CLK/. This is the most fundamental clock signal, as it is not only used to advance the time of the clock itself, but it is also used to reset various SR latches which generate other signals.

In a nutshell, instead of feeding the AC waveform directly in to my circuit, I first feed it through this circuit which uses three MOSFETs formed as a chain of inverters, and such that its output voltage is the system voltage of 9V DC. As the AC waveform goes high, the output is shunted down to ground. As the AC waveform goes low, the output signal goes high. This produces a roughly square wave output to the tune of the input AC signal.

Other circuits might use something like a schmitt trigger which will produce a "pure" square wave from a sine wave, and can also help to produce a clean square wave from an otherwise noisy signal. I don't expect the input AC waveform to be particularly noisy, so a schmitt trigger is not necessary and this simple circuit should work just fine for my needs. If you're interested in learning some more about how schmitt triggers work, check out this video and this video.

Power on reset delay

This is a "RC" (Resistor Capacitor) circuit. A pair of resistors create a voltage divider of which the high side resistor also limits the amount of current that the capacitor can draw to charge up. As the capacitor is charging it starves the gate of a MOSFET until such a time that it is sufficiently charged that the MOSFET is able to turn on. The MOSFET is actually acting as an inverter or NOT gate. When the MOSFET is off, current is allowed to flow from the output of the gate in to the reset mux, and a high input to the reset mux will assert a reset state within the clock. When the MOSFET eventually turns on, it shunts its output down to ground and the reset state is removed until power cycled.

I don't technically need this, as I could simply reset the clock manually once it is powered on, but I thought it was a nice little addition to ensure it powers up as "all zeros".

Reset mux

The reset mux is just an OR gate. It has two inputs, one of which comes from the power on reset delay circuit as described above, and the other from a button that the user can press to reset the clock at any time. Both signals combine through this circuit to produce a single "master clear" signal (called MCLR in my schematics) which is distributed throughout the clock. When asserted, this signal causes all counters and SR latches that produce the various clock signals to reset to default states (mostly all zeroes).

MCLR is also OR'ed with the output of the AC_CLK/ generator (a signal which starts its life as AC_CLK_GEN/) to produce the final AC_CLK/ signal. When MCLR is asserted by either the power on delay or reset button the AC_CLK/ signal is held high. Basically it ensures that all counters and latches within the clock will reset and be held stable.

Mains frequency prescaler

The mains frequency prescaler is implemented as a 6 bit ripple counter. It is combined with some additional gates which form a reset circuit. Without repeating myself too much (I covered a lot of the operating theory in design notes #5), when the prescaler reaches a certain value, an SR latch is set via an AND gate. When the SR latch is set, it resets the prescaler to zero, and the inverted output generates a new clock signal called 1PPS_CLK/.

I encourage you to read through the post I linked to above because it explains the operating theory in much more detail, including a timing diagram to demonstrate how all of the different signals are produced.

But the basic idea of the prescaler is to produce a clock pulse each second in order to advance the time module of the clock.

Schematics

And that about covers it for the circuits that are on the analogue board, so now lets look at the schematics for it. Full schematics are available within the GitHub repository as usual, and you'll need EAGLE to view them. I also provide them in PDF format if you don't have EAGLE. The schematics for this board are spread across two sheets/pages, one for the "analogue" side and the other for the "digital" side. The two files specific to this blog post are linked directly below.

I've included some notes within the schematics to try and explain briefly what each portion is for and what it does.


And with that, the first design log post is about done I think. The next post will cover the construction of the analogue board, and some details of testing/verification.

8 comments:

  1. Hey, cool that we're "getting to guts" now!

    Just a few remarks:
    - why require a 12V AC (!) power supply - one could just as well put that transformer in, too.
    - re the linked YT vids: funny they are, yes... but maybe also check out Dave Jones' EEVblog or Julian Ilett or ... For example: EEVblog #941 - Schmitt Trigger Tutorial
    - providing .pdfs is great, and even more so in the repo! To make it even easier for ppl you could directly link to the "raw" github file, eg analogue-board.pdf (https://github.com/tomstorey/discrete-nor-logic-clock/raw/master/schematics/analogue-board.pdf)
    - there's a lot of white screen area in the schematics (.pdf), not very convenient. But I guess that's just what comes out of EAGLE export?

    ReplyDelete
    Replies
    1. The white space is a bit of a trade off. There are various "frames" that can be placed on the schematic, some of them are quite big as on page 2, others are a bit smaller as on page 1. But when it comes to export to a file from EAGLE, the scale remains the same across all pages, so it wasnt possible to have them "fill" the entire page. I guess I could put a bigger frame on page 1, but then you end up with more white space inside the frame instead of outside of it. 50/50? :-)

      Its probably a unique problem to this schematic, as most of the others from here on will be a single (big) page.

      I had tried to implement a discrete schmitt trigger based on the one in the videos I linked, but I couldnt get it working on my board for some reason (although it worked just fine on my breadboard mockup), I didnt have an oscilloscope at the time to debug it (but I do have one now!), and TBH I dont think its really that necessary anyway. This works very well for the application, so Im sticking with it. Rise and fall times are on the order of tens of uSec with my circuit and I believe this is plenty quick given the "operating frequency" is only 50hz. :-)

      Will update the URLs, thanks for the tip!

      Delete
    2. Re the external power supply, the transformer would be too bulky to put on to the clock itself. Not to mention that an external power supply is probably a lot safer - all of the high voltage AC is safely contained.

      Of course, anyone choosing to build this themselves can build it how ever they like. :-)

      Delete
  2. Re YT recommendations: I should have also mentioned The Signal Path. Here's him & Dave Jones together. The link is right into the vid where they mention ElectroBoom :)

    Re (extra) power supply: I was guessing that safety was of concern, and that's a perfectly valid concern. Just that a 12V AC seems a bit hard to get.

    ReplyDelete
    Replies
    1. Ah yes, I am a Dave Jones/EEVBlog fan. I saw some recent videos where he and The Signal Path had some discussions. I checked out a couple of videos, really nice technical content in there, may just become a subscriber.

      Then I also stumbled across this last night, pretty impressive, would love to go check it out: https://www.youtube.com/watch?v=lNa9bQRPMB8

      Safety is one concern but not the only concern for using an external plug pack. It should also be possible to use a 15V or potentially even a 9V plug pack too. By the time the AC is rectified and smoothed it ends up some way above what the dropout voltage of the regulator will be. I guess the trick will be that if the load is significant enough, a 9V plug pack might not be able to put out the required voltage to keep the regulator going, so 12V is probably safer.

      Otherwise you'll just need to make sure you have a big enough heatsink on your regulator to handle the extra heat that it might produce from higher input voltages.

      I should take some measurements of input voltage and temperature, and amps consumed as I build up the clock to see how it changes over time - that could be pretty cool. I am aiming to get the next post up in the next few days covering the build of the analogue board, and you'll see that I have a smallish heatsink on my regulator - remains to be seen if that will be sufficient. :-)

      Delete
    2. In my case, the 12V plug pack I am using has a load rating of 400mA. So at 400mA it will be able to output 12V. As it is, with very little load it puts out somewhere around 16V if I remember correctly.

      Delete
    3. What the hell! Thx a lot for pointing me to the Megaprocessor vid! ...and I thought Ben's, and even more so your endeavour were kinda border-line... :)

      Re power supply: it'd great if you could provide some measurements. How much power do you think your clock is going to consume?
      I've still got the idea of an USB-powered version of it in my head with some other kind of base clock signal. At first it'd be a totally simple oscillator, NE555-like. Later on you could go for precision, maybe even using a modified radio clock module... well, pretty absurd, I know - but hey :)

      Delete
    4. I made a change to the analogue board and hooked a 2 pin header in line with the output of the regulator so that I can hook up my multimeter to measure the current draw of each board (as a delta from the previous reading) as I add each of them to the stack.

      So far I see that the analogue board draws "about" 4mA on its own according to a couple of minutes averaging on the multimeter. The next board in the stack looks like its drawing about 9.5mA.

      Bit hard to say what the total draw will be at this time, but if I made a guess I think somewhere upwards of 150mA would be a generous budget for the logic alone. The LED displays will be the biggest consumer of current by far. I expect to drive mine with about 2mA per segment, and there will be a lot of segments active at any one time.

      Im looking at the following oscillator as a potential clock source for another clock project. Its a TCXO (temperature compensated) with frequency stability of +/- 2ppm between 0 and 40 degrees C. Super accurate, but also pricey at £6 each.

      http://uk.rs-online.com/web/p/crystal-oscillators/7327589/

      Delete