Hi there,
I'm working my way through building an 8-bit breadboard computer (following Ben Eater's very excellent project at eater.net/8bit which I'd highly recommend).
As part of that, I've build a clock module, and it has successfully driven an ALU, 2 registers, RAM module, etc, so I'm pretty sure the clock works. It uses a set of 555 timers both in astable mode (variable resistor controls the automatic clock in this mode), and, via a debounced toggle switch, I can go into mono-stable mode which is useful for manually driving the clock via a push button for stepping manually. This clock module has been used as inputs to the modules mentioned above, so, I'm "pretty confident" it's good and I don't see funny behavior like non-debounced multiple jumps per clock cycle, etc. Also (important when you read below) don't see any weird behavior like downstream circuits acting on the falling edge (everything only acts on rising edges of the clock, as it should).
In any event, I am building a program counter using a 74LS161 now. Essentially, on each rising edge of the clock it should increment the 4-bit output number by one.
First, let me describe how the 161 is set up (maybe this is easier than drawing out a schematic, happy to upload a drawing if not).
Pin1 : Clear. Tied High
Pin 2: Clock. Connected to my clock.
Pins 3-6: Data inputs. Unused, so tied via 1k ohm resistor each to GND.
Pin 7: Enable P. Tied to Pin 10 and tied to Vcc
Pin 8: GND.
Pin 9: Load. Tied to Vcc
Pin 10: Enable T. Tied to pin 7 and tied to Vcc
Pins 11-14: output lines. Each has it's own LED going to GND. (Note: no resistor here, but seems to work w/o burning out LEDs)
Pin 15: Ripple Carry Output: Tied through 1k ohm resistor to GND
Pin 16: Vcc.
Attempt #1: Hook up power, with Vcc=5V. the counter behaves incorrectly, it's like the 2 least significant bits are in fact one, they come on and off together, most of the time (Sort of like it's a 3-bit counter). but it's somewhat random / non-repeated as well.
Fix: Added a 0.1uF decoupling capacitor across Vcc and Gnd of the 161 chip. When I do that, the chip starts counting correctly in proper binary using all 4 LEDs as it should.
However, it's counting at twice the rate I'd expect, it increments at every clock rising edge (as it should), but also every clock falling edge.
Fix #2: Turn off power supply, and put it in 3.3V mode, instead of 5V mode. Now things work fine, it counts only on clock rising edges (and LEDs are somewhat dimmer as I'd expect).
(I'm using this power supply: https://www.amazon.com/gp/product/B010UJFVTU/ ).
A volt-meter confirms the power supply is behaving properly, I read 4.9V in 5V mode, 3.2V in 3.3V mode.
So, I then went into "add 0.1uF decoupling capacitors to all the ICs to see what happens" mode. So they've now been added to all the 555 timers and logic gate ICs of my clock breadboard module, but I still see the above issue with 2x the counting frequency, when in 5V mode.
Just for fun, I added a decoupling capacitor to the clock output (thinking maybe there was some high frequency transient that makes the falling edge have a rising edge embedded into it). But that makes things worse, now LEDs are counting incorrectly, so I removed it (also, if that were true, I would have expected to see odd behavior from other users of the clock, e.g. RAM module, other ICs, etc. And everything else was okay).
At this point, I've reached the limit of my knowledge or debugging intuition (I'm a newbie to this stuff), so I thought I'd ask for help, in case this is obvious to those with more experience than I. If I've glossed over any details that are critical to a diagnosis please accept my apologies, and let me know what information you'd like to have.
Thank you for reading and thank you in advance for any advice/help you may have! I don't own an oscilloscope, but, I'm open to getting a cheaper one if that's the only way to make progress on this.
-Alex
I'm working my way through building an 8-bit breadboard computer (following Ben Eater's very excellent project at eater.net/8bit which I'd highly recommend).
As part of that, I've build a clock module, and it has successfully driven an ALU, 2 registers, RAM module, etc, so I'm pretty sure the clock works. It uses a set of 555 timers both in astable mode (variable resistor controls the automatic clock in this mode), and, via a debounced toggle switch, I can go into mono-stable mode which is useful for manually driving the clock via a push button for stepping manually. This clock module has been used as inputs to the modules mentioned above, so, I'm "pretty confident" it's good and I don't see funny behavior like non-debounced multiple jumps per clock cycle, etc. Also (important when you read below) don't see any weird behavior like downstream circuits acting on the falling edge (everything only acts on rising edges of the clock, as it should).
In any event, I am building a program counter using a 74LS161 now. Essentially, on each rising edge of the clock it should increment the 4-bit output number by one.
First, let me describe how the 161 is set up (maybe this is easier than drawing out a schematic, happy to upload a drawing if not).
Pin1 : Clear. Tied High
Pin 2: Clock. Connected to my clock.
Pins 3-6: Data inputs. Unused, so tied via 1k ohm resistor each to GND.
Pin 7: Enable P. Tied to Pin 10 and tied to Vcc
Pin 8: GND.
Pin 9: Load. Tied to Vcc
Pin 10: Enable T. Tied to pin 7 and tied to Vcc
Pins 11-14: output lines. Each has it's own LED going to GND. (Note: no resistor here, but seems to work w/o burning out LEDs)
Pin 15: Ripple Carry Output: Tied through 1k ohm resistor to GND
Pin 16: Vcc.
Attempt #1: Hook up power, with Vcc=5V. the counter behaves incorrectly, it's like the 2 least significant bits are in fact one, they come on and off together, most of the time (Sort of like it's a 3-bit counter). but it's somewhat random / non-repeated as well.
Fix: Added a 0.1uF decoupling capacitor across Vcc and Gnd of the 161 chip. When I do that, the chip starts counting correctly in proper binary using all 4 LEDs as it should.
However, it's counting at twice the rate I'd expect, it increments at every clock rising edge (as it should), but also every clock falling edge.
Fix #2: Turn off power supply, and put it in 3.3V mode, instead of 5V mode. Now things work fine, it counts only on clock rising edges (and LEDs are somewhat dimmer as I'd expect).
(I'm using this power supply: https://www.amazon.com/gp/product/B010UJFVTU/ ).
A volt-meter confirms the power supply is behaving properly, I read 4.9V in 5V mode, 3.2V in 3.3V mode.
So, I then went into "add 0.1uF decoupling capacitors to all the ICs to see what happens" mode. So they've now been added to all the 555 timers and logic gate ICs of my clock breadboard module, but I still see the above issue with 2x the counting frequency, when in 5V mode.
Just for fun, I added a decoupling capacitor to the clock output (thinking maybe there was some high frequency transient that makes the falling edge have a rising edge embedded into it). But that makes things worse, now LEDs are counting incorrectly, so I removed it (also, if that were true, I would have expected to see odd behavior from other users of the clock, e.g. RAM module, other ICs, etc. And everything else was okay).
At this point, I've reached the limit of my knowledge or debugging intuition (I'm a newbie to this stuff), so I thought I'd ask for help, in case this is obvious to those with more experience than I. If I've glossed over any details that are critical to a diagnosis please accept my apologies, and let me know what information you'd like to have.
Thank you for reading and thank you in advance for any advice/help you may have! I don't own an oscilloscope, but, I'm open to getting a cheaper one if that's the only way to make progress on this.
-Alex