6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 9:46 pm

All times are UTC




Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Clock circuit problems
PostPosted: Mon Jun 04, 2007 4:05 pm 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
I have some questions about the clock circuit I'm using.
On one of the sites linked to from the projects section I found this clock circuit:
Image
I don't have a 7404, but I have some 74S37 nand gates, so I connected the inputs on them to make inverters. I put two leds on it to see if it goes high and low, but it only goes high. Could this be because of my makeshift inverters not being able to take it?

Also, it shows a 2MHz crystal, and I have a 1MHz one. Is the frequency of the crystal cut in half or was this circuit designed for a faster processor?

Thanks for any help!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 7:00 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
I've never used the 74Sxx line, and it even took awhile to find a datasheet on the 74S37. It appears that the problem may be that the input current is about 2.5 times as high with the 74Sxx as with 74xx, and by parallelling the inputs, you've doubled it again to about five times as high. For this, you'd have to cut the value of the resistors in five to perhaps 180 or 220 ohms; but then the crystal might get too hot too, depending on its size. This circuit does not divide the frequency by two. You normally use a flip-flop for that.

If you need crystal control, the oscillator cans are an easy solution, and the CMOS 6502 (65c02) even lets you connect the crystal directly to the processor. All the 65c02's made today will run at least at 16MHz, so 2MHz is pretty poky by comparison. If you don't need crystal control, you can even hang an RC on the CMOS processor for a cheap, compact frequency source.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 9:23 pm 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
Thanks for the advice. I found some 270 ohm resistors and got my processor running.

The datasheet for the processor had a clock circuit that didn't have a capacitor in it, so I was wondering about that. I wrote a test program to try to find the clock speed, but I'm unsure of my results.

It sends the a15 line through the parallel port and checks it. It waits for it to change, records the time, then waits for it to change twice again and records the new time. I end up with about 6 seconds to go through the entire address range, and with (2^16 addresses * 2cycles per NOP) / 6 seconds I end up with about 22 KHz. I'm pretty sure that's not right. :oops: Any ideas as to what's wrong with my test?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 9:56 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
If it's really that low, you would be able to divide it by two with a flip-flop and connect a piezoelectric beeper or some kind of transducer and actually hear it. If it's not connected right, the frequency might be controlled by an RC instead of the crystal.

If the frequency is not really that low, I suppose your measurement method could be giving an alias, depending on the speed and software of the computer you're using to test it. What's the sampling rate?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 04, 2007 11:30 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The PC parallel port can handle at most 1 Msps (mega-sample per second) reliably. Different chipsets allow for different rates, but if you're polling the I/O port directly, you can only reliably guarantee 1Msps tops.

Considering the fact that you're likely running under Windows or Linux, which is a multitasking system, AND that you have interrupts enabled, AND that you have to deal with cache miss overhead from other running programs, you're probably not going to get any better than 10Ksps reliably.

So if you're measuring 22KHz frequency, that sounds "about right" considering the parallel port performance.

I used to use the parallel port to download software to the Kestrel-1 program RAM, and it would take about 4 seconds to transfer 8KiB of memory ($E000-$FFFF). I did so via a serial bit-stream not entirely unlike SPI, so each byte took about 32 programmer bits (15 for address, 8 for data, some unused bits, and a small handful left over for bus control signals). So let's estimate at 40 parallel port writes per byte written. 8192 bytes by 4 seconds (average) yields a throughput of 2048 bytes per second, times 40, gives us approximately 80kbps output, again average.

However, I found input rates were substantially less than this, for reasons I still cannot figure out (which is why I gave up on using the parallel port as a Kestrel programmer port, although _somehow_ the ATmega programmers seem to get it to work!!!)

I'm running on an Athlon, slot-A machine, at 800MHz, under Linux. So that gives you some idea as to the performance-suck that modern OSes can have on modern-day bit-banging.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 05, 2007 2:16 am 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
The computer I ran the test on was running in dos. I had a cut-up printer cable from a previous project, so I put it in bidirectional mode and read from it. I can see what you're saying, that I'm just measuring the speed of the parallel port rather than clock, I think it really is that slow because when I put leds on the address pins, I could see them counting up in binary (pretty slowly too). It takes about 3 seconds for the a15 line to change. I've been trying to use a flip-flop to divide the clock signal it and then listen to it like garth said, but it hasn't been working for me. I'm thinking that I'll start from scratch with my clock circuit and order a real 7404 if I can't get this working.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 05, 2007 2:32 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
Well, with DOS, you don't have to deal with multitasking, so you can get the full Msps throughput.

Sounds like it's definitely running that slowly then.

Assuming you're running NOPs, there are 65536 cycles between A15 state changes (32768 bytes times two cycles per byte). 65536/3 = 21.845333 kHz. Yikes. :)

Since they're cheap enough, you might want to get a CMOS 7404 variant, since they're better suited towards using gates-as-amplifiers applications, like the above clock circuit.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 05, 2007 3:37 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
This 2MHz crystal can oscillator at Jameco is an easy solution at under a dollar and a half at fits in an 8-pin DIP socket. It costs about fifty cents more than just the crystal, and has everything built in, ready to go, guaranteed to work-- 5V in, 2MHz out.

Image


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 05, 2007 5:37 pm 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
I'm going to order one of those can oscillators (probably what I should have done in the first place) In the meantime, I'll try a 4049. Thanks for your help.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jun 05, 2007 6:19 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
You may get working results, but the 4000 series is extremely slow at 5V. It's better at 12V or 15V, and I've used it in some of our products where I wanted logic coupled to 12V audio circuits without resorting to voltage-translation parts.

If you use a CMOS inverter IC, you can bump those 1K resistors up to at least 100K if not a meg. CMOS logic is actually able to make simpler oscillators. Check out Fairchild's AN340 at http://www.fairchildsemi.com/an/AN/AN-340.pdf#page=1 .


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Jul 19, 2007 9:39 pm 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
Sorry I haven't posted back. I left for a vacation and then for a camp shortly afterwards. I got the can oscillator and I'm freerunning my processor now. :D


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jul 20, 2007 4:47 pm 
Offline

Joined: Thu Jul 05, 2007 4:11 pm
Posts: 33
I find it more fun to build your own oscillator. I used the same technique as the diagram that RyanS posted, and had great results with a 2Mhz series crystal, 1Kohm resistors, a .05uF capacitor, and a 74LS04 hexinverter.

I put it on a a scope, and the waveform is identical to the one coming off of my Vic20.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Jul 21, 2007 11:34 pm 
Offline

Joined: Mon Jun 04, 2007 12:35 am
Posts: 7
When I ordered the oscillator, I also ordered a couple 7404s. I'll try building my own clock circuit again.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jul 22, 2007 4:26 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The 74LS04 technique may work for chips other than WDC's -- I've found that when WDC says a maximum slew of 5ns is required for the clock, they very much mean it. Even 6ns is enough to produce flakey chip operation in my experience.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jul 23, 2007 3:51 pm 
Offline

Joined: Mon Mar 20, 2006 2:03 am
Posts: 24
At a place I worked at back in the 80's we used to use an inverter circuit like that with a 4MHz crystal, then divide it down with a dual flip-flop to get 2MHz and 1MHz signals. If I recall correctly we did that because at the time 4MHz crystals were smaller and cheaper than 1MHz ones and oscillator modules either didn't exist yet, or were very expensive.

An oscillator module would be the way to go these days, but if you did want to use a circuit like this would running it through a flip-flop help with the slew rate? Also how about using the F series instead of LS?


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 60 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: