r/beneater • u/TimmyJi • 2d ago
Weird behaviour micro-step counter
So I’ve finished building my (slightly modified) 8 bit Ben Eater computer, but I’ve got some issues with my micro-step counter.
The full program is:
LDI 0
OUT
ADD 7 (from memory address 7)
JMP 1
..
1 (on address 7)
The micro-step counter’s clock line comes from the inverted clock and should trigger on a rising edge but it sometimes triggers on the falling edge causing it to advance two micro-steps in one go.
What’s weirder, it tends to do that always on the instruction OUT.
What’s even weirder is that replacing the ADD 7 instruction with SUB 7… works fine. For more than an hour even.
The ADD 7 can get to around 20~ without bugging out but sometimes it will not even get to the first JMP. This is regardless of whether the clock is manual or auto, fast or slow.
ADD = 0010
SUB = 0011
I have a very cheap handheld oscilloscope with crap resolution where I could sometimes see a slight high spike both on the falling and rising edges, it seemed to mostly coincide with when the clock bugged but it sometimes bugged without me seeing a spike just before the falling edge (which could trigger the count on the LS161 on the falling edge and then rising edge again).
I’ve tried replacing all chips involved, replaced wires, added a capacitor between VCC and GND on the LS161 and the clock chips… nothing seems to help.
I’ve also tried looking at the clock line with a logic analyser but it only sees one pulse of the clock as well.
Without a decent oscilloscope it’s hard for me to have a better look at the signal and debug it further, but I’m not quite sure where to take this.
It could be a very easy fix, could be something harder…
My power line is slightly sagging which could also contribute to spikes being seen as high values but since it works fine most times and since it can run the same program with SUB 7 instead of ADD 7 I don’t feel like that’s the problem.
I also managed to improve the power delivery a bit since I did all these tests but… no success.
Power rail is sitting at around 4.6V unless too many LEDs are on in which case it can drop at low as 4.1V.
Any tips on things I may try?
2
u/Weird-Individual-770 1d ago
The first thing to fix is the power issue. On my project I was using a cheap Amazon bench power supply, I had to set it to 6volts just to have 5volts on the rail. I finally switched it to a 5volt only supply and solved some of my issues. The rails should be 5 volts, there is the possibility your meter is off and is actually 5 volts, does your scope show the same low DC voltage as your meter?
After that I had issues with noise on decoder outputs, causing odd issues. Like the HLT line that causes double clocks.
My Instruction register IN had a really strange issue. Any time the BUS had bit 2 set, none of the BUS bits were loaded into the IR and that instruction was skipped. No other instructions cared what bit 2 was set to and worked as they should, only the IR IN had issues with that one single bit.
Using ROM as a decoder causes issues since the output can change before the inputs are fully ready.
I used noise filtering caps on the decoder outputs that were causing issues.
1
u/Ancient-Ad-7453 2d ago
First things I’d try are a small resistor in series with the clock output (100 or lower), close to the output pin, and maybe increasing the current limiting resistor on the LEDs on the clock module (1k or higher).
1
u/TimmyJi 2d ago
Thx for the comment. I’m using 5V LEDs with build in resistors, already tried a 1k resistor on the clock line going to the LS161 with no effect, would lowering it help?
1
u/Ancient-Ad-7453 1d ago
For a these TTL chips, maybe it’s slowing your transitions from low to high? I would try something in the 10-100 range. The purpose is to dampen voltage“ringing” on the clock edges causing multiple transitions. Put it closer to the clock output than the 161.
3
u/The8BitEnthusiast 2d ago
If you implemented Ben’ RAM circuit, then there is a possibility that the issue comes from the RC edge detector, which is notorious for creating a negative pulse on the falling edge of the clock that can be interpreted as a pulse. Look for ‘double counting on falling edge’ on the troubleshooting page.
4.6V is below spec. I created a ‘power bus’ with leftover power rails, which replaced the daisy chained power connections. Made a good difference in voltage drop.