6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 5:49 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 11, 2021 2:55 pm 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
Fans of 1980s Japanese animation will immediately understand the project naming convention.

I am making a computer without fancy test equipment. This may seem like a foolhardy exercise but I am having great success by breaking the task into a tree of modules which can be built and tested separately. Project A-Frame is an idiot-proofed LED which greatly aids circuit debug. Project B-Frame is a small circuit board with six logic chips. The purpose of the board is to divide megahertz pulses down to a rate which can be observed visually.

I am concerned this project may be a significant step for newbies. For me, this is only a minor extension of previous work. I've previously made a flip-flop circuit and chain of 4017 decimal counters as part of a motion capture system. I've also made animatronic ears (see username) with an optional debug board which similarly used chains of 4017 counters to divide 400Hz servo pulses down to 0.4Hz. I have also soldered crystals and ceramic resonators to DIP AVR microcontrollers. I am now combining this previous expertise into a six chip, divide by 16777216 board. Despite this being a very similar size and shape to the animatronic debug board, this is the most advanced circuitry that I have attempted due to its operational speed. Therefore, newbies are strongly advised to start with a two transistor flip-flop circuit and then advance to one or more 4017 (or 4094) counter chips. These can be used to make pleasing light sequences.

I ultimately require an oscillator somewhere in the range 1Mhz to 25MHz. I also require a circuit which can divide pulses by one million or more so that I can see what the blazes is happening. This can be achieved very easily with five or more 4 bit binary counters. During development, this requires about 20 74HC161 counter chips and two or more breadboards. That's the easy part. The part that gives me great trepidation is the oscillator which feeds into the divider circuitry. I've been in this situation with a flip-flop circuit. I had migrated all of my breadboard to a soldered prototype board with the exception of the flip-flop oscillator. With no redundant parts, I then found myself at a critical juncture where I had to migrate the oscillator across. Thankfully, my very slow oscillator worked first time. A similar but more drastic situation (directly related to 6502 development) may have occurred during the development of the Acorn Proton. This did not work first time due the significantly faster speed of the oscillator, possibly in combination with a ground loop. This was dramatized in (the inaccurately named) Micro Men and I am very disappointed that the 6502 forum makes minimal reference to this production. Among a large amount of extraneous material, Micro Men contains information which is of direct relevance to the 6502 oscillator experimenter. This situation may be avoided by following advice (possibly from BigEd) to buy at least two full sets of components. This is particularly true for oscillators.

A very important consider for oscillators is the speed of light which travels at a maximum of three centimetres per nanosecond and a little less in air or wire. A 25MHz oscillator should have a high phase of 20ns and a low phase of 20ns. While this appears to set a generous constraint for the maximum round-trip length of any oscillator circuit of 25MHz or less, it is preferable to keep this distance considerably shorter and avoid any ground loops which exceed this constraint. This consideration also explains the popularity of 25MHz quartz crystals and frequency doubling circuits. Starting from the base frequency of 25MHz, if we double it and double it again, we get 100MHz. If we double that and double it again, we get 400MHz which is the bit-rate of USB2. If we double that and double it again, we get 1600MHz which is suitable for 2x oversampling of USB3.

I left a gap on a breadboard sufficiently large for a 14 pin inverter chip, crystal, capacitors and possibly other components. I began work on a chain of five 74HC161 counter chips. The Texas Instruments datasheet suggests pulsing all of the chips synchronously and using inhibit signals to make them count correctly. Whatever. I'm going to wire them like 4017 chips and daisy-chain the carry outputs. (Note: do it properly if you require the output bits.) For each 74HC161, connect pin 8 to ground. Connect pins 1, 7, 9, 10 and 16 to power. Input pins 3, 4, 5, 6 *should* be connected to ground or power but I'm lazy. This bad practice allows the circuit to be most easily adapted into jfoucher's variant of Dr. Jefyll's clock stretching circuit which itself benefited from a back-and-forth with BigDumbDinosaur and other contributors. Pin 15 of one chip can be fed to pin 2 of the next. Pin 2 of the first chip is the input. Pin 11 of the last chip (with 1/2 duty ratio, not pin 15 with 1/16 duty ratio) can be connected to a diagnostic light. Indeed, for testing, pin 11 of every counter chip can be connected to a separate diagnostic light.

Returning to the oscillator, I have become a customer of Mouser, an official distributor of Western Design Center products. Unfortunately, in my first order to Mouser (an unresolved escapade), I neglected to purchase oscillator components of any form. In my second order, intended to cover the deficiencies of my first order, I also neglected to purchase oscillator components. Therefore, I was reduced to looking through a small and scant bag of surplus components from which I emerged triumphant, victorious and several other synonyms with a 3 pin, 16MHz ceramic oscillator. 2 pin variants are commonly used on Arduino boards and I've had previous success soldering 3 pin variants to DIP AVR. However, I am aware of some cleverness inside AVR. Specifically, each has its own reset circuit and config settings for such minor mysteries as a "full swing oscillator". (Wrong choice led me brick my first two Arduino boards.)

How difficult can it be to run a ceramic resonator without an AVR? After spending two hours stripping wires for my chain of binary counters, I then wired the ceramic resonator like a crystal oscillator using two gates of a 74HC04 inverter chip. When I powered it, nothing interested happened. The power lights worked but that was all. Dang it. This is why I had such trepidation. I smothered the circuit with indicator lights and confirmed that it was definitely dead everywhere. Perhaps the resonator works with one inverter rather than two? That worked immediately. This is winning. I spent eight hours on preparation and less than five minutes fixing bugs.

Abraham Lincoln wrote:
If I had eight hours to chop down a tree, I'd spend six sharpening my axe.


Abraham Lincoln: 8 Bit Computing Enthusiast may be improbable but perhaps a more recent quote may persuade you:

ttlworks on Fri 29 Jan 2021 wrote:
If you want to roughly measure frequency, but you lack an oscilloscope and a frequency counter,
one option would be to build a binary counter from, let's say, 74HCT393 chips.

For instance, if you have a 12 Bit counter with the outputs Q11..Q0,
and a LED tied to Q11 (don't forget the resistor in between) would be blinking at ca. 1.17 times per second,
you know that the counter is clocked with 1.17Hz * 2^12 = ca. 4792Hz.


With such encouragement, I added a sixth stage to the counter chain. This had problems working with the indicator lights because I forgot to ground the last stage. This was easily connected and noted for future diagnostics. For completeness, I replaced the 74HC04 inverter chip with a 74HC00 quad NAND gate. Specifically, the 16MHz ceramic resonator uses one of the four NAND gates. Regulars of the 6502 forum will immediately understand the significance of this arrangement. GARTHWILSON and many other contributors highly recommend 6502 address decode using three NAND gates. The remaining gate may be used in conjunction with a ceramic resonator. Unfortunately, I cannot recommend this arrangement until an expert has corrected a minor mistake. Even then, a ceramic resonator is at least five times less accurate than a quartz crystal. This may adversely affect UART and other functionality.

In particular, I have subsequently discovered that the ceramic resonator sometimes sits in a pregnant pause for 20 seconds or more before it begins ticking. I presume that a lack of Schmitt gates may be significant. Or perhaps a resistor would promote oscillation. Regardless, when short of parts, it is better than nothing. Therefore, it is suitable as a temporary placeholder. Indeed, this bodging now makes me strongly appreciate the merits of a tested rest module and a tested oscillator module. However, it is only by tinkering and failing that it becomes apparent. It is also apparent that I have to re-think the probability of failure. I'm exactly the type of cheapskate who buys a pack of 10 clone Arduino boards from a dodgy supplier of a random marketplace and a pack of three accelerators from an equally dodgy supplier. However, this practice doesn't scale. When I require a reliable processor, RAM, ROM, I/O and glue logic with zero redundancy, probability of success may be less than 10% That's just betting against yourself. I have therefore divided my components into "dodgy components from ebay, aliexpress and local makerspace" and "quality components from reputable distributors". This is, of course, completely unrelated to [url=XX]my component give-away for newbies[/url]. Don't thank me now. Thank me later.

My oscillator is unreliable but the dividing circuitry can be compacted down to an arrangement of 2*3 chips on a 5cm*7cm prototyping board. Indeed, this can be reduced to a module with four wires: power, ground, input, output. It also raises reliability because when it is soldered onto one board, I don't have to worry about loose wires in the holes of a breadboard. There is the consideration of sockets or no sockets. Sockets can be a source of failure. However, if you have terrible soldering, like me, then sockets are an obvious choice. Use of sockets may also be a budget consideration because it eases scavenging of chips from previous projects. To keep wires short, I recommend a serpentine arrangement. I also strongly recommend making a minimum of two debug boards and it is for this reason that I suggest buying a minimum of 20 counter chips: six on breadboard, six on each prototype board plus two spares. This was extremely useful for the next stage.

As a programmer, I am accustomed to copying source code infinitely, text editors with infinite undo and strict use of version control. With hardware hacking, I am not accustomed to 1-5 week lead times for components and a shocking lack of undo. A practice mentioned in The Soul of a New Machine by Tracey Kidder provides the next best option. Specifically, develop two or more copies of hardware in parallel. This provides a minimal backup and undo to the last (assumed) good state. At the very least, it is unlikely that all copies with fail in the same manner simultaneously. Obviously, this increases cost and slows forward progress. However, it remains worthwhile because it almost completely eliminates back-tracking and delay. Therefore, I strongly recommend making at least two boards which divide pulses by at least 20 bits.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 11, 2021 9:04 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
Sheep64 wrote:
A very important consider for oscillators is the speed of light which travels at a maximum of three centimetres per nanosecond and a little less in air or wire.

I think you were thinking 30mm/ns, which is 3cm/ns. The speed of light in free space is 30cm/ns though, making things a little easier. In a transmission line on FR4 PCB, it's around 2/3 of that speed.

Regarding the frequency doubling, I believe the more common thing is to use a PLL.

Quote:
I'm going to wire them like 4017 chips and daisy-chain the carry outputs.

"Like" is the key word. The 4017's propagation delays are in the hundreds of ns, ie, very, very slow. There's a 74HC version, the 74HC4017, which is 5x as fast or faster. There does not appear to be a 74AC4017.

For the ceramic resonator circuit, a good source might be https://ecsxtal.com/store/pdf/cer_prin.pdf (from a quick web search.

Many DMMs today have a frequency-counter function. It may not go beyond 200kHz (it wouldn't makes sense with their long, single-wire probes anyway), but you won't have to divide your frequency down so much, and then you'll get three or four digits without having to time an LED for some amount of time with a stopwatch.

Regarding re-usable modules: You can make plug-in ones like I have done mostly for my analog needs, although I do have a 74AC14-based one that's a variable-frequency oscillator (VFO) for digital use up to 75MHz:
Attachment:
5-pin_modulesB.jpg
5-pin_modulesB.jpg [ 81.75 KiB | Viewed 622 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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

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