Why is my shift register latching in garbage data?
Answer: Garbage In ... Garbage out
It seems to me you want to make a better switch debounce circuit. Although you could make it a Morse Code binary display on "Dah's" and "Dit's by using the switch duration trailing edge to decode the duration of the switch after it is debounced for 10 ms. Then yank HC04, Q1 and 555.
Let's define the "Dah" as > 150 ms and "Dit" as < 150 or make it X with a single R to control the Morse Code delay threshold..
To debounce to ~20 ms with a button switch bounce time of 5ms use 22 nF and 1Meg or 2.2 nF//10Meg pulldown.
Then use a LPF to define the delay of CLK relative to debounced D. Let LPF RC=T=150 ms then with 50% threshold +/-33% the delay will be roughly 150 ms on the training edge of the buffered inverted switch = CLK . Meaning a short "Dit" CLK's a 0 and a long Dah clocks a 1. Now your binary shift register will display your Morse Code at any repetition rate but active Pulse width modulated when pressed on trailing edge.
Now you use the debounced switch for SI (data) and the decoded delay
I don't know how you can use a switch to clock events with a shift register that is not a counter other than like Morse Code Events. But the leading edge must be filtered to 10ms Thus a "Dit" event is a time window comparator between 10 ms and 150 ms clocked event and anything longer is a "Dah". But this does not decode the Morse Code into characters or counter characters. That's something else.
YOur choice is to define if a Dah = 0 or 1. I would choose 0 as it takes longer to say like Dah.
The SCK or shift clock is your decoded switch delay output rising clock and RCK is the register latch which is just any delay of say > 1 us after rising edge of SCK but < 10 ms. So in total you need 4 caps for charge storage
- Vdd denoise < 1us
- Switch denoise < 10ms
- Morse dah/dit decode > 150 ms
- RCLK Register latch CLocK
simulate this circuit – Schematic created using CircuitLab
In the meantime, I'll send you a pattern to use.
• • • – – – • • •
A picture is worth a thousand words.
The experts might notice a POR (reset) added RC circuit or if you did, bravo.