6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Nov 12, 2024 10:48 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Flexible clock circuit
PostPosted: Sat Nov 23, 2019 10:58 am 
Offline
User avatar

Joined: Thu Apr 11, 2019 7:22 am
Posts: 40
Hi All,

I'm aware this is not a 6502 specific question but I thought I could get good answers from here.

I am looking for a clock circuit that would allow me to select clock frequencies in a wide range including step by step operations. Ideally, I would want it to be able to work in 3 possible modes. (1) Full speed, possibly driven by a crystal oscillator. (2) Adjustable slow speed, in the range of almost zero to just few Hz, which I guess can be achieved with a 555 based circuit. (3) Step mode, where single pulsations of a push button will make the clock cycles.

I have found some easy designs on the internet (most of them based on the Ben Eater series nowadays), but all of them seem to overlook the possible bad effects of switching modes while in operation. For example, when the clock is switched from step mode to low speed mode, it is desirable that the circuit waits for the next clock edge before continuing with the selected frequency period. Also switching from slow speed to full speed modes should be seamless.

Thanks in advance for any pointers.

John


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 23, 2019 5:49 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Hi Joan,

I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.

http://forum.6502.org/viewtopic.php?f=4&t=3493&start=225#p54027

Hope that helps.

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 23, 2019 5:54 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
I see Drass posted while I was writing. I'll keep going anyway.

I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02). I don't have a full do-everything circuit for you, but I would base it on at least 74HC, if not 74AC, Schmitt-trigger logic. My 6502 primer's clock-generation page shows a single-cycler clock-generation circuit about 3/4 of the way down the page, and there are links there to related forum topics. See especially viewtopic.php?p=10619#p10619 where I show a variable-frequency oscillator I use. In viewtopic.php?p=378#p378, I tell of a couple of programmable oscillators from Dallas Semiconductor. (That was 16 years ago, so I'm sure they have improved ones by now.)

For clock stretching without glitches, see this experiment I did 21 years ago. (Don't use 4000-series logic though. I only used it because it's really slow, and I wanted it slow enough that if there were any runt pulses, they would show up on my 20MHz analog 'scope.)
Attachment:
CycleStretch.jpg
CycleStretch.jpg [ 316.9 KiB | Viewed 1498 times ]

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 23, 2019 6:09 pm 
Offline
User avatar

Joined: Sun Oct 18, 2015 11:02 pm
Posts: 428
Location: Toronto, ON
Hi Garth,

The single-pulse circuit I used is taken from your clock generation page (although I mentioned it was yours, I failed to include a link in the schematic :roll: ).

I also used your VFO circuit when building my own, so I can vouch for it. :)

_________________
C74-6502 Website: https://c74project.com


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2019 2:30 pm 
Offline
User avatar

Joined: Thu Apr 11, 2019 7:22 am
Posts: 40
Drass wrote:
Hi Joan,

I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.

http://forum.6502.org/viewtopic.php?f=4&t=3493&start=225#p54027

Hope that helps.


Yes, this helps. Ultimately I realised that what I really wanted is a clock switching circuit with two independent clock sources, so googling the right words I found this on the internet: https://www.eetimes.com/document.asp?doc_id=1202359.

I figured out that I could combine that with the ideas on your circuit, and I came up with this logisim simulation:

Attachment:
ClockCircuit.png
ClockCircuit.png [ 31.64 KiB | Viewed 1425 times ]


There are two clock input sources and a manual tick button:

- The fast clock source will be a crystal oscillator.

- I want the slow source to be variable along the few Hz range (maybe up to 10 Hz or so), so I think the 555 timer circuit described in the "digital computer electronics" book should do it.

The circuit seems to work fine on logisim although the clock exchange takes some time because it does not happen until both sources have completed its own cycle. That's not a major issue for me though. The circuit uses quite a number of ics but I assume it can't be simplified given the specs.

Joan


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2019 2:46 pm 
Offline
User avatar

Joined: Thu Apr 11, 2019 7:22 am
Posts: 40
GARTHWILSON wrote:
I see Drass posted while I was writing. I'll keep going anyway.

I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02).

Thanks for the tip. I only aim for very slow clock rates (in the range of just a few Hz) for the 555 based source. I think that if I connect the output of the 555 to a flip-flop I will get a perfect square wave with proper edges and half the frequency, no?. A Ben Eater video on youtube shows an even simpler approach that seems to work. He just directly connects the 555 output to a few logic gates he uses for switching purposes, and then uses the output of that gates to clock a 6502. Is there something inherently wrong with that?

Thanks

Joan


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2019 3:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
(Just possibly worth picking gates with Schmidt inputs, if the input is slow, and you really don't want glitches.)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 25, 2019 6:27 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
joanlluch wrote:
Thanks for the tip. I only aim for very slow clock rates (in the range of just a few Hz) for the 555 based source. I think that if I connect the output of the 555 to a flip-flop I will get a perfect square wave with proper edges and half the frequency, no?. A Ben Eater video on youtube shows an even simpler approach that seems to work. He just directly connects the 555 output to a few logic gates he uses for switching purposes, and then uses the output of that gates to clock a 6502. Is there something inherently wrong with that?

As Ed says, a Schmitt-trigger input will go a long ways. I'm not sure it would totally eliminate the possibility of noise picked up from heavy ringing on another part of the circuit causing unwanted pulses between intended phase-2 edges though; and these pulses' speed may be too fast for the processor to handle, and cause a crash. We like Ben's enthusiasm; but he has a number of practices that could cause (and sometimes have caused) problems for others in their circuits. (There's one right now in the "6502 Homebrew Hardware and Programming" facebook group, where Ben's reset with only an RxC isn't working for the OP, even though it's on a PCB.) When this is the case, the "It works for me" argument may only prove that the failure rate is not 100%. That's not very useful information. Fortunately the actual performance of various ICs is better than the specs guarantee, but again, we can't depend on non-guaranteed behavior unless we do enough testing to get a good feel for how much margin we're leaving. In the case of a gate with a Schmitt-trigger input, the specs may guarantee a certain amount of hysteresis, but there will probably be a little more. How much? Are we operating so close to the edge that a change in temperature, or the moving of a couple of wires, will make it stop working?

So we have to find a balance between, on the one hand, overburdening the beginner with excessive and complicated implementation details, and on the other hand, ignoring those and letting him build something that takes months to debug and he finally gives up. The goal of course is to maximize the success rate.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 2:11 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8482
Location: Midwestern USA
joanlluch wrote:
- I want the slow source to be variable along the few Hz range (maybe up to 10 Hz or so), so I think the 555 timer circuit described in the "digital computer electronics" book should do it.

A problem with using a 555 timer, as previously mentioned, is the output transition time is much too slow for the 65C02. Also, you need to try for 50/50 symmetry, which is hard to attain from a relaxation oscillator.

Something I use in some of my designs that require a slow but stable symmetric "tick" is a comparator oscillator, such as the below illustration.

Attachment:
File comment: Comparator Oscillator Illustration
comparator_oscillator_application.gif
comparator_oscillator_application.gif [ 19.63 KiB | Viewed 1373 times ]

This particular application is a model railroad grade crossing signal flasher, with the comparator oscillator cycling the signal lights at the rate of 1 Hz. The circuit has near-perfect symmetry and is relatively insensitive to Vcc.

The circuit works because the input transition threshold of a comparator is extremely narrow, at most a few millivolts. Hence the oscillation frequency is a function of the R-C time constant of R5 and the C4/C5 combination. R5 is both charge and discharge path for the capacitors, which means symmetry is as good as that of the comparator "crossover" characteristics. The ratio between R4 and R5 is not critical, so you could use a pot in place of R5 to create a low-speed variable clock.

The comparator's output is an open collector, so it has to be pulled up to Vcc—anything from 1K to 4.7K is usually sufficient. Open collector outputs are somewhat on the slow side, relatively speaking, with a high-to-low transition typically around 1 µs. A Schmidt trigger, such as a 74AC14, should be used to condition the oscillator's output so as to satisfy the 65C02's Ø2 clock requirements.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 8:04 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10977
Location: England
BigDumbDinosaur wrote:
... you need to try for 50/50 symmetry, which is hard to attain from a relaxation oscillator.

Hmm, the only reason to aim for 50/50 is when you're running at full speed, and you need both clock phases to be as short as practical. At any slower speed all that matters is that each phase is within spec - has at least some minimum length.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 2:31 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
Agree with Ed (above).


And, as for 555 or a discrete circuit, it occurs to me that 74HC221 or '123 would be much better choices, given that they belong to the 74xx family. And, a quick check shows their output rise/fall spec (22 ns, assuming a 50 pF load) is roughly equal to that of an 'HC14 Schmitt Trigger, suggesting the latter will not be required or helpful for conditioning the output.

But even the 'HC14 isn't clearly within spec for driving a 65xx clock input. The 'HC specs don't tell us what the figure is for loads less than 50 pF. :|

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 8:02 pm 
Offline
User avatar

Joined: Tue Jul 17, 2018 9:58 am
Posts: 107
Location: Long Island, NY
Would something like the 74HC40103 work to clock a 65xx? That'd get you 8 bits of digital control over your clock speed, and you wouldn't have to mess with capacitances/resistances or carefully twiddle a pot.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 8:06 pm 
Offline
User avatar

Joined: Thu Apr 11, 2019 7:22 am
Posts: 40
Hi Jeff,

I am not going to drive a 6502 with it, but a home made cpu, but I suppose this should make little difference. (The build thread describing the architecture and software tools I implemented is this: http://anycpu.org/forum/viewtopic.php?f=23&t=583)

The only purpose of such ultra low frequency mode is having visible blinking lights on the front panel showing registers and control line values. I though a 555 configured as a astable multivibrator with a potentiometer, followed by a J-K flip flop to obtain proper edges and 50% duty cycle, would do it just fine, as I do not need any frequency accuracy for that. I can also insert a Schmidt trigger buffer before the J-K as suggested.

Please can you point me to a circuit schematic that would do a 50-50 square signal with continuously adjustable frequencies in the range of a few Hz (such as from 0.25Hz to 10Hz) using one of the ics you suggest?

Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 10:16 pm 
Offline
User avatar

Joined: Wed Mar 01, 2017 8:54 pm
Posts: 660
Location: North-Germany
I apologies I haven't read all of this thread, just jumping in ;)

If i would need such a low frequency oscillator I would use a CMOS (hex) schmitt trigger inverter (40106 or 4584) with a large resistor or trim pot (2.5 or 5 M) wired from output to input and an (tantal) elco e.g. 47uF/10V or more.
To obtain lower frequencies (and square waves) a 4024 (2^7) or 4040 (2^12) binary counter could be used.
If you need fast rise/fall times a 74HC4040 should work as well.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 26, 2019 11:06 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8539
Location: Southern California
GaBuZoMeu wrote:
I would use a CMOS (hex) schmitt trigger inverter (40106 or 4584) with a large resistor or trim pot (2.5 or 5 M) wired from output to input and an (tantal) elco e.g. 47uF/10V or more.

74xC14 (74HC14, 74AC14, etc., but not 74C14) would be the 74-series equivalent, with much faster rise and fall times.

I was going to post links to NSC (later Fairchild) ap. notes, but when ON Semi took over Fairchild, they wiped them out. I've been able to get them to re-post some of them, and now I just sent another email asking for these two, which I have old links to on my 6502 primer's clock-generation page and just realized I still need updated links to:

HCMOS crystal oscillators (AN-340) and
CMOS oscillators (AN-118)

I have them on paper but unfortunately not in electronic form to attach here. I plan to update this (as well as the links on my website) when I hear back from ON Semi.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: