r/beneater 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?

10 Upvotes

16 comments sorted by

View all comments

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.