Designing a digital watch from scratch ...

SokaMoka

Banned
Feb 24, 2006
521
1
0
I made a challenge for myself to design a digital watch, I am not going to build it in reality(though I might but most probably just simulate it), just intrested in doing it via software ATM.

And I know the process can be mae easy using some complicated IC's but that takes the fun away from it all IMHO.

I don't have anytime restrictions, and no this is not a HW!
The challenge that I find in it, is trying as much as possible to stick to logic gates ONLY, and 0-9 display LED's, I want to use AND OR NOT NAND XOR NOR (in pure form), forget IC's I am focusing on pure logic gates.
I know this will be very messy but it will entertain me to see how it will all come together at the end ;).

Am I going to drive myself crazy here or is this objective feasible (after some considerable effort)?
I like working with boolean logic and gates, and this sounds like a very good exercise to me.
What I need is some pointers so that I invest my freetime learning / applying something of benefit.

Your input is appreciated.
 

TerryMathews

Lifer
Oct 9, 1999
11,464
2
0
Easy way to do it - assuming that you're able to cherry pick perfect components (especially crystal)...

First off, determine if you're watch is going to display seconds or not. For simplicity, my example is not but if you understand what is going on, taking it the next step and adding seconds should be easy.

One crystal oscillaing once per minute (or more aptly a circuit stepping it down, but for simplicity's sake...).

You need a counter that can count from 0 to 59 (for minutes). 59 should be wired to the clock input on a counter that can count from 0 to 23 (hours) and to the clear pin on itself. 23 on the hours counter should be wired to clear on itself.

Then all you need is to feed those binary output lines into the inputs (or driver logic) for your LEDs. Depending on the circuits you select, you may need to do slight modifications to the rollovers at 23:59 and 59 on each hour to make it count right.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
It is possible.

I suggest you do a search and read up a little bit on Combinatorial logic versus Sequential logic. You will need sequential blocks (flip-flops). Granted, you can build those (latches and flip-flops) with AND - OR - ..... gates too.

You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You will need to build digital counters (sing flip-flops and combinatorial logic gates) to count the time base to come up with different units of time (seconds, minutes, hours, ...)
 

SokaMoka

Banned
Feb 24, 2006
521
1
0
OK I am pretty much getting the picture thanks to you guys, so I was thinking what software you think is best for this design process ?
 

alpha88

Senior member
Dec 29, 2000
877
0
76
Once you figure out the gates need for a flip flop, and for an adder you should be set.

If you don't know much about flip flops/latches just read up on them - a certain type will work far better in this situation. (The differences are in how they are triggered)

I'm not sure what kind of software you have, but if possible, design up some flip flops and half adders. Then ctrl-c ctrl-v to make many more and wire those suckers up.
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: alpha88
Once you figure out the gates need for a flip flop, and for an adder you should be set.

If you don't know much about flip flops/latches just read up on them - a certain type will work far better in this situation. (The differences are in how they are triggered)

I'm not sure what kind of software you have, but if possible, design up some flip flops and half adders. Then ctrl-c ctrl-v to make many more and wire those suckers up.

why do you need an adder? ive actually built binary, octal, and decimal clocks and never needed an adder.
 

smack Down

Diamond Member
Sep 10, 2005
4,507
0
0
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: Navid
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!

why would it sometimes measure a minute as 3 minutes? do you even know what you are talking about?
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: MrDudeMan
Originally posted by: Navid
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!

why would it sometimes measure a minute as 3 minutes? do you even know what you are talking about?

Any oscillator can be used as the time base. Not every oscillator is accurate. That is why crystal oscillators are used as time bases. You even have one on your motherboard. A crystal oscillator oscillates at a known frequency and its accuracy over temperature and supply voltage is extremely high. A crystal oscillator is not perfect. But, relatively speaking, it is very accurate.

You can also build an oscillator using capacitors and resistors and logic gates as mentioned before. Such an oscillator will oscillate at a frequency that is very sensitive to temperature and supply voltage.

Let's say you use an oscillator that runs at 13MHz as your time base. You use a counter to divide it down by 13000000. Now, you have a signal with a 1Hz frequency (1 second). But, if your time base oscillator is not accurate and as temperature goes up, it oscillates at 5MHz instead, the output of the counter will run at 5MHz/13000000 = 0.38Hz. Now, all your time units will be off by (1 - 0.38)/100 = 62%.

Do you get it?

Now, go troll somewhere else.
 

blahblah99

Platinum Member
Oct 10, 2000
2,689
0
0
You should read up on sequential logic design before doing this... Crystal oscillators go down to a few kilohertz, so you will need a counter to divide down to the second.

Then all you need after that is another counter to count up to 86,400 seconds, which is at least a 17-bit counter for 1-sec precision.

Now, Displaying the clock with leds is a different story... that requires more logic.
 

smack Down

Diamond Member
Sep 10, 2005
4,507
0
0
Originally posted by: Navid
Originally posted by: MrDudeMan
Originally posted by: Navid
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!

why would it sometimes measure a minute as 3 minutes? do you even know what you are talking about?

Any oscillator can be used as the time base. Not every oscillator is accurate. That is why crystal oscillators are used as time bases. You even have one on your motherboard. A crystal oscillator oscillates at a known frequency and its accuracy over temperature and supply voltage is extremely high. A crystal oscillator is not perfect. But, relatively speaking, it is very accurate.

You can also build an oscillator using capacitors and resistors and logic gates as mentioned before. Such an oscillator will oscillate at a frequency that is very sensitive to temperature and supply voltage.

Let's say you use an oscillator that runs at 13MHz as your time base. You use a counter to divide it down by 13000000. Now, you have a signal with a 1Hz frequency (1 second). But, if your time base oscillator is not accurate and as temperature goes up, it oscillates at 5MHz instead, the output of the counter will run at 5MHz/13000000 = 0.38Hz. Now, all your time units will be off by (1 - 0.38)/100 = 62%.

Do you get it?

Now, go troll somewhere else.

Of courses it is easy to hold temparture and supply voltages stable in a simulation.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: smack Down
Originally posted by: Navid
Originally posted by: MrDudeMan
Originally posted by: Navid
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!

why would it sometimes measure a minute as 3 minutes? do you even know what you are talking about?

Any oscillator can be used as the time base. Not every oscillator is accurate. That is why crystal oscillators are used as time bases. You even have one on your motherboard. A crystal oscillator oscillates at a known frequency and its accuracy over temperature and supply voltage is extremely high. A crystal oscillator is not perfect. But, relatively speaking, it is very accurate.

You can also build an oscillator using capacitors and resistors and logic gates as mentioned before. Such an oscillator will oscillate at a frequency that is very sensitive to temperature and supply voltage.

Let's say you use an oscillator that runs at 13MHz as your time base. You use a counter to divide it down by 13000000. Now, you have a signal with a 1Hz frequency (1 second). But, if your time base oscillator is not accurate and as temperature goes up, it oscillates at 5MHz instead, the output of the counter will run at 5MHz/13000000 = 0.38Hz. Now, all your time units will be off by (1 - 0.38)/100 = 62%.

Do you get it?

Now, go troll somewhere else.

Of courses it is easy to hold temparture and supply voltages stable in a simulation.

You are right. I stand corrected. Thanks.
 

MrDudeMan

Lifer
Jan 15, 2001
15,069
94
91
Originally posted by: Navid
Originally posted by: MrDudeMan
Originally posted by: Navid
Originally posted by: smack Down
You need a time base. This can be a crystal oscillator. This is an analog part. You cannot get away from that. Other than that, everything else can be digital.

You can make a clock, not a good clock, by using inverters, resistors, and capacitor which might be a better option if the op doesn't have any crystals.

Yes, if you can call something a clock that sometimes measures a minute as 3 minutes, and as temperature or the battery voltage varies so does its accuracy!

why would it sometimes measure a minute as 3 minutes? do you even know what you are talking about?

Any oscillator can be used as the time base. Not every oscillator is accurate. That is why crystal oscillators are used as time bases. You even have one on your motherboard. A crystal oscillator oscillates at a known frequency and its accuracy over temperature and supply voltage is extremely high. A crystal oscillator is not perfect. But, relatively speaking, it is very accurate.

You can also build an oscillator using capacitors and resistors and logic gates as mentioned before. Such an oscillator will oscillate at a frequency that is very sensitive to temperature and supply voltage.

Let's say you use an oscillator that runs at 13MHz as your time base. You use a counter to divide it down by 13000000. Now, you have a signal with a 1Hz frequency (1 second). But, if your time base oscillator is not accurate and as temperature goes up, it oscillates at 5MHz instead, the output of the counter will run at 5MHz/13000000 = 0.38Hz. Now, all your time units will be off by (1 - 0.38)/100 = 62%.

Do you get it?

Now, go troll somewhere else.

go troll somewhere else? please.

thanks for your math demonstration but all i have to say back is "duh" :roll: i have designed oscillators and obviously there is one on a motherboard. you still havent convinced me you know what you are talking about. i knew everything you said BEFORE i went to college to be an engineer.

if you choose to use a battery, then fine it will be increasingly inaccurate, but why cant he make a rectifier and use wall power? it isnt going to magically heat up and cool off after it is turned on and stabilizes. once it reaches that state, nothing will vary and you no longer have to worry about 50+% variations like you claim.
 

skimple

Golden Member
Feb 4, 2005
1,283
3
81
I seem to recall constructing an oscillator using only a loop of inverters. It had to be an odd number, but the gate delay of the inverter could be used to establish the period of the clock. For example, using 9 gates with a 10ns delay yields a period of 90ns.

Of course, the question was "why would you use this when you can just get a crystal?" The answer is - if you need to construct a clock on-chip that was isolated from the main clock. Very handy if you are trying to construct an all digital gate circuit.

Need a preset/reset pulse though to get the clock going.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Originally posted by: skimple
I seem to recall constructing an oscillator using only a loop of inverters. It had to be an odd number, but the gate delay of the inverter could be used to establish the period of the clock. For example, using 9 gates with a 10ns delay yields a period of 90ns.

Of course, the question was "why would you use this when you can just get a crystal?" The answer is - if you need to construct a clock on-chip that was isolated from the main clock. Very handy if you are trying to construct an all digital gate circuit.

Your tolerance is going to be very high though... even at the same voltage and temperatures two dies are going to run at different frequencies. When you bring voltage and temperature variation into the picture, you're going to have a heck of a time keeping it accurate.

Need a preset/reset pulse though to get the clock going.
Really? I'd think just powering on, due to device variation one of the nodes on the chain would get flipped one way or the other, and it'd oscillate from there.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
That is correct, a ring oscillator does NOT need a reset. However, a simulator may.
 

skimple

Golden Member
Feb 4, 2005
1,283
3
81
Originally posted by: CTho9305

Your tolerance is going to be very high though... even at the same voltage and temperatures two dies are going to run at different frequencies.

That is true. I'm thinking VSLI circuitry, so all inverters would be on the same chip, and inverter to inverter variation would be minimal.

Don't you still need a reset pulse to get all gates to a known state? What if two sequential gates come up both at low output? The gate delays would propagate this through the ring. I think the correct configuration is to inject a reset pulse. After one period of the ring, all gates are at a known state.

 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Don't you still need a reset pulse to get all gates to a known state? What if two sequential gates come up both at low output? The gate delays would propagate this through the ring. I think the correct configuration is to inject a reset pulse. After one period of the ring, all gates are at a known state.

http://www.ece.cmu.edu/~cst/inverterOscillator.png - 5 inverters in a ring (nmos is 16 lambda/2 lambda, pmos is 32/2, 180nm TSMC process we're using for a class, 1.8V Vdd). Note that with these initial conditions, even in simulation it started oscillating (I guess due to accuracy limitations of the simulator). I'm not sure if a known state really matters - being off by a few picosends either way seems irrelevant. You could work around that by ignoring the first few toggles and waiting until it's in the state you want.

If you were worried about a particular node starting high or low, you could skew some of the inverters so they're biased towards specific transitions (of course, that that point you might as well just have it be resetable ;)).
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
If he can get hold of a wall-wart power supply which supplies low voltage AC - then he can count the power cycles instead of using an oscillator. As there are tight controls on mains power frequency, in particular, deviations are supposed to be averaged out over the course of 24 hours, his clock should keep good time.

This was a very common design in many clocks - both digital and analogue. The analogue ones were driven by a synchronous AC motor. These days, most clocks will use their own crystal oscillator - because it means you no longer need a seperate design for 50 and 60 Hz mains supplies.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: skimple[/i]
Don't you still need a reset pulse to get all gates to a known state? What if two sequential gates come up both at low output? The gate delays would propagate this through the ring. I think the correct configuration is to inject a reset pulse. After one period of the ring, all gates are at a known state.

You may be confusing a ring oscillator (a ring of inverters) with a ring counter (a ring of flip-flops).

If you connect an odd number of inverters in a ring, you will have a circuit that does not have a stable condition (state).

Let's say at power-up, a ring of five inverters comes up at 10101.

Then, it will go to 00101, 01101, 01001, 01011, 01010, 11010, 10010, 10110, 10100, and finally back to the original state of 10101.

It will go through these states repeatedly, hence being called an oscillator.
No matter what state you start from, it will find its way to the above sequence.

The only problem is that some simulators may need a start-up kick to capture an oscillation. This is what noise is sufficient to guarantee in the real world though.
 

Navid

Diamond Member
Jul 26, 2004
5,053
0
0
Originally posted by: skimple
I'm thinking VSLI circuitry, so all inverters would be on the same chip, and inverter to inverter variation would be minimal.

That is not going to help keep the frequency constant!

The frequency of the ring is a function of the absolute delay through the ring, which has nothing to do with the inverter-to-inverter variation.
 

ng12345

Senior member
Jan 23, 2005
408
0
86
Originally posted by: MrDudeMan

if you choose to use a battery, then fine it will be increasingly inaccurate, but why cant he make a rectifier and use wall power? it isnt going to magically heat up and cool off after it is turned on and stabilizes. once it reaches that state, nothing will vary and you no longer have to worry about 50+% variations like you claim.


Originally posted by: Mark R
If he can get hold of a wall-wart power supply which supplies low voltage AC - then he can count the power cycles instead of using an oscillator. As there are tight controls on mains power frequency, in particular, deviations are supposed to be averaged out over the course of 24 hours, his clock should keep good time.

This was a very common design in many clocks - both digital and analogue. The analogue ones were driven by a synchronous AC motor. These days, most clocks will use their own crystal oscillator - because it means you no longer need a seperate design for 50 and 60 Hz mains supplies.

the OP mentions making a digital "watch." Wouldn't this rule out the possibility of using "wall power?" I'm assuming watch defines it as a "time telling" device that is portable. if he were trying to make a clock, using a wall AC supply would be possible.

as defined by webster: 6 : a portable timepiece designed to be worn (as on the wrist) or carried in the pocket
 

Bobthelost

Diamond Member
Dec 1, 2005
4,360
0
0
Originally posted by: MrDudeMan
if you choose to use a battery, then fine it will be increasingly inaccurate, but why cant he make a rectifier and use wall power? it isnt going to magically heat up and cool off after it is turned on and stabilizes. once it reaches that state, nothing will vary and you no longer have to worry about 50+% variations like you claim.

Nice watch that would make :D
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: Navid
That is correct, a ring oscillator does NOT need a reset. However, a simulator may.

I agree with the above. It either needs a reset or at least an initial condition. Most simulators start off transient simulations at steady state and at any initial inputs. A ring of inverters will start off all in the metastable state and will probably stay there until some rounding error comes along to make the oscillator start. The easy way is to set an initial condition of any random node to 0V. Either that or make the voltage supply also ramp up from 0 to vcc in your simulations and 99.999% of the time it'll be enough to get your oscillator going.